abs

paddle. abs ( x, name=None )

Warning: API “paddle.fluid.layers.layer_function_generator.abs” is deprecated since 2.0.0, and will be removed in future versions. Please use “paddle.abs” instead.

Abs Operator.

This operator is used to perform elementwise abs for input $X$. \(out = |x|\)

Parameters
  • x (Tensor) – (Tensor), The input tensor of abs op.

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

Returns

(Tensor), The output tensor of abs op.

Return type

out (Tensor)

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]