sign¶
- paddle.fluid.layers.nn. sign ( x ) [source]
-
This OP returns sign of every element in x: 1 for positive, -1 for negative and 0 for zero.
- Parameters
-
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.
- Returns
-
The output sign tensor with identical shape to input
x
. - Return type
-
Variable, the output data type is the same as input data type.
Examples
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'))