mindspore.ops.inv

mindspore.ops.inv(x)[source]

Computes Reciprocal of input tensor element-wise.

\[out_i = \frac{1}{x_{i} }\]
Parameters

x (Tensor) – Tensor of any dimension. Must be one of the following types: float16, float32 or int32.

Returns

Tensor, has the same type and shape as input shape value.

Raises
  • TypeError – If x is not a Tensor.

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

Supported Platforms:

Ascend GPU CPU

Examples

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