mindspore.ops.Inv

class mindspore.ops.Inv[source]

Computes Reciprocal of input tensor element-wise.

\[out_i = \frac{1}{x_{i} }\]
Inputs:
  • x (Tensor) - Tensor of any dimension. Must be one of the following types: float16, float32 or int32.

Outputs:

Tensor, has the same shape and data type as x.

Raises
  • TypeError – If x is not a Tensor.

  • TypeError – If dtype of x is not one of float16, float32, int32.

Supported Platforms:

Ascend

Examples

>>> inv = ops.Inv()
>>> x = Tensor(np.array([0.25, 0.4, 0.31, 0.52]), mindspore.float32)
>>> output = inv(x)
>>> print(output)
[4.        2.5       3.2258065 1.923077 ]