PyTorch torch.sgn Function
Pytorch torch Reference Manual
torch.sgnis a function in PyTorch used to return the sign vector element-wise. For complex numbers, it returns the unit complex number.
Function Definition
torch.sgn(input, out=None)
Usage Example
Example
import torch
# Return sign vector element-wise
x = torch.tensor([-2.0, 0.0, 3.0])
result = torch.sgn(x)
print(result)
# Return sign vector element-wise
x = torch.tensor([-2.0, 0.0, 3.0])
result = torch.sgn(x)
print(result)
Other Extensions