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) Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True, [0.40000001, 0.20000000, 0.10000000, 0.30000001])