sign

dragon.vm.tensorflow.math.sign(
  x,
  name=None
)[source]

Compute the sign indication of input.

\[\text{out}_{i} = \begin{cases} -1, & \text{ if } x_{i} < 0 \\ 0, & \text{ if } x_{i} = 0 \\ 1, & \text{ if } x_{i} > 0 \end{cases} \]

Examples:

x = tf.constant([-2, 0, 2])
print(tf.math.sign(x))  # [-1, 0, 1]
Parameters:
  • x (dragon.Tensor) – The input tensor.
  • name (str, optional) – A optional name for the operation.
Returns:

dragon.Tensor – The output tensor.