mindspore.numpy.reciprocal
- mindspore.numpy.reciprocal(x, dtype=None)[source]
Returns the reciprocal of the argument, element-wise.
Calculates
1/x
.Note
Numpy arguments casting, order, subok, signature, and extobj are not supported. When where is provided, out must have a tensor value. out is not supported for storing the result, however it can be used in combination with where to set the value at indices for which where is set to False.
- Parameters
x (Tensor) – Input array. For integer arguments with absolute value larger than 1 the result is always zero because of the way Python handles integer division. For integer zero the result is an overflow.
dtype (
mindspore.dtype
, optional) – defaults to None. Overrides the dtype of the output Tensor.
- Returns
Tensor or scalar, this is a scalar if x is a scalar.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore.numpy as np >>> x = np.arange(1, 7).reshape(2, 3).astype('float32') >>> output = np.reciprocal(x) >>> print(output) [[1. 0.5 0.33333334] [0.25 0.2 0.16666667]]