mindspore.numpy.absolute
- mindspore.numpy.absolute(x, dtype=None)[source]
Calculates the absolute value element-wise.
Note
Numpy arguments out, where, casting, order, subok, signature, and extobj are not supported. Currently the backend kernel only supports float calculation, if the input is not a float, then it will be casted to
mstype.float32
and casted back.- Parameters
x (Tensor) – Tensor to be used for calculation.
dtype (
mindspore.dtype
, optional) – defaults to None. Overrides the dtype of the output Tensor.
- Returns
Tensor.
- Raises
TypeError – If input arguments have types not specified above.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore.numpy as np >>> x = np.asarray([1, 2, 3, -4, -5], np.float32) >>> output = np.absolute(x) >>> print(output) [1. 2. 3. 4. 5.]