paddle.fluid.layers.nn. sign ( x ) [source]

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

This OP returns sign of every element in x: 1 for positive, -1 for negative and 0 for zero.

x(Variable|numpy.ndarray): The input variable could be N-D tensor or N-D numpy array,

the input data type is float32 or float64.


Variable, the output data type is the same as input data type. : The output sign tensor with identical shape to input x.

import paddle.fluid as fluid
import numpy as np

# [1.0, 0.0, -1.0]
data = fluid.layers.sign(np.array([3.0, 0.0, -2.0], dtype='float32'))