mindspore.ops.Inv

class mindspore.ops.Inv(*args, **kwargs)[source]

Computes Inv(Reciprocal) of input tensor element-wise.

Inputs:
  • input_x (Tensor) - The shape of tensor is \((x_1, x_2, ..., x_R)\). Must be one of the following types: float16, float32, int32.

Outputs:

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

Raises

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

Supported Platforms:

Ascend

Examples

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