mindspore.Tensor.abs

View Source On Gitee
Tensor.abs() Tensor

Returns absolute value of a tensor element-wise.

\[out_i = |self_i|\]
Returns

Tensor, has the same shape as self.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import numpy as np
>>> import mindspore
>>> from mindspore import Tensor
>>> x = Tensor(np.array([-1.0, 1.0, 0.0]), mindspore.float32)
>>> output = Tensor.abs(x)  # x.abs()
>>> print(output)
[1. 1. 0.]