mindspore.ops.Abs

class mindspore.ops.Abs(*args, **kwargs)[source]

Returns absolute value of a tensor element-wise.

\[out_i = |x_i|\]
Inputs:
  • input_x (Tensor) - The input tensor. The shape of tensor is \((x_1, x_2, ..., x_R)\).

Outputs:

Tensor, has the same shape as the input_x.

Raises

TypeError – If input_x is not a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> input_x = Tensor(np.array([-1.0, 1.0, 0.0]), mindspore.float32)
>>> abs = ops.Abs()
>>> output = abs(input_x)
>>> print(output)
[1. 1. 0.]