PyTorch torch.neg function
PyTorch torch reference manual
torch.neg is a function in PyTorch used to take the element-wise negative.
Function definition
torch.neg(input, out=None)
Usage examples
Example
import
torch
Element-wise negation
x
=
torch.
tensor
(
[
1.0
,
2.0
,
3.0
]
)
result
=
torch.
neg
(
x
)
(
result
)