Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.sgn function

PyTorch torch.sgn function


PyTorch torch reference manual PyTorch torch reference manual

torch.sgn is 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 examples

Example

import

torch

Return the sign vector element-wise

x

=

torch.

tensor

(

[

2.0

,

0.0

,

3.0

]

)

result

=

torch.

sgn

(

x

)

print

(

result

)


PyTorch torch reference manual PyTorch torch reference manual