sign¶
dragon.vm.tensorflow.math.
sign
(
x,
name=None
)[source]¶Compute the sign indication of input.
\[\text{out}_{i} = \begin{cases} -1, & \text{ if } \text{input}_{i} < 0 \\ 0, & \text{ if } \text{input}_{i} = 0 \\ 1, & \text{ if } \text{input}_{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) – The operation name.
- Returns:
dragon.Tensor – The output tensor.