torch.sgn¶
-
torch.
sgn
(input, *, out=None) → Tensor¶ For complex tensors, this function returns a new tensor whose elemants have the same angle as that of the elements of
input
and absolute value 1. For a non-complex tensor, this function returns the signs of the elements ofinput
(seetorch.sign()
)., if , otherwise
- Parameters
input (Tensor) – the input tensor.
- Keyword Arguments
out (Tensor, optional) – the output tensor.
Example:
>>> x=torch.tensor([3+4j, 7-24j, 0, 1+2j]) >>> x.sgn() tensor([0.6000+0.8000j, 0.2800-0.9600j, 0.0000+0.0000j, 0.4472+0.8944j])