torch.sgn#
- torch.sgn(input,*,out=None)→Tensor#
This function is an extension of torch.sign() to complex tensors.It computes a new tensor whose elements havethe same angles as the corresponding elements of
inputandabsolute values (i.e. magnitudes) of one for complex tensors andis equivalent to torch.sign() for non-complex tensors.- Parameters
input (Tensor) – the input tensor.
- Keyword Arguments
out (Tensor,optional) – the output tensor.
Example:
>>>t=torch.tensor([3+4j,7-24j,0,1+2j])>>>t.sgn()tensor([0.6000+0.8000j, 0.2800-0.9600j, 0.0000+0.0000j, 0.4472+0.8944j])