sign

dragon.vm.torch.sign(
  input,
  out=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 = torch.tensor([-2, 0, 2])
print(torch.sign(x))  # [-1, 0, 1]
Parameters:
Returns:

dragon.vm.torch.Tensor The output tensor.