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

PyTorch torch.neg function

PyTorch torch.neg function


PyTorch torch reference manual 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

)

print

(

result

)


PyTorch torch reference manual PyTorch torch reference manual