mindspore.ops.Reciprocal
- class mindspore.ops.Reciprocal[源代码]
Returns reciprocal of a tensor element-wise.
\[out_{i} = \frac{1}{x_{i}}\]- Inputs:
x (Tensor) - The input tensor. \((N,*)\) where \(*\) means, any number of additional dimensions, its rank should be less than 8.
- Outputs:
Tensor, has the same shape as the x.
- Raises
TypeError – If x is not a Tensor.
- Supported Platforms:
Ascend
GPU
Examples
>>> x = Tensor(np.array([1.0, 2.0, 4.0]), mindspore.float32) >>> reciprocal = ops.Reciprocal() >>> output = reciprocal(x) >>> print(output) [1. 0.5 0.25]