PyTorch torch.sign function
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
)
(
result
)