mindspore.mint.reciprocal

mindspore.mint.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

Examples

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