mindspore.ops.Abs
- class mindspore.ops.Abs[source]
Returns absolute value of a tensor element-wise.
Refer to
mindspore.ops.abs()
for more details.- Inputs:
x (Tensor) - The input tensor.
- Outputs:
Tensor, has the same shape as the x.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> import numpy as np >>> from mindspore import Tensor, ops >>> x = Tensor(np.array([-1.0, 1.0, 0.0]), mindspore.float32) >>> abs = ops.Abs() >>> output = abs(x) >>> print(output) [1. 1. 0.] >>> x = Tensor(3.6) >>> output = abs(x) >>> print(output) 3.6