abs

paddle. abs ( x, name=None ) [source]

Abs Operator. Perform elementwise abs for input X.

\[out = |x|\]
Parameters
  • x (Tensor) – The input tensor of abs op.

  • out (Tensor) – The output tensor of abs op.

  • name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Examples

import paddle

x = paddle.to_tensor([-0.4, -0.2, 0.1, 0.3])
out = paddle.abs(x)
print(out)
# [0.4 0.2 0.1 0.3]