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

PyTorch torch.sign function

PyTorch torch.sign function


PyTorch torch reference manual PyTorch torch reference manual

torch.sign is a function in PyTorch used to return the sign element-wise. It returns -1 (negative), 0 (zero), or 1 (positive).

Function definition

torch.sign(input, out=None)


Usage examples

Example

import

torch

Return the sign element-wise

x

=

torch.

tensor

(

[

2.0

,

0.0

,

3.0

]

)

result

=

torch.

sign

(

x

)

print

(

result

)


PyTorch torch reference manual PyTorch torch reference manual