mindspore.ops.reciprocal

mindspore.ops.reciprocal(input)[source]

Returns reciprocal of a tensor element-wise.

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

input (Tensor) – The input tensor.

Returns

Tensor, has the same shape as the input.

Raises

TypeError – If input is not a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore as ms
>>> from mindspore import ops
>>> import numpy as np
>>> input = ms.Tensor(np.array([1.0, 2.0, 4.0]), ms.float32)
>>> output = ops.reciprocal(input)
>>> print(output)
[1.   0.5  0.25]