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

PyTorch torch.negative function

PyTorch torch.negative function


PyTorch torch reference manual PyTorch torch reference manual

torch.negative is a function in PyTorch used to take the element-wise negative. Similar to torch.neg in functionality.

Function definition

torch.negative(input, out=None)


Usage examples

Example

import

torch

Element-wise negation

x

=

torch.

tensor

(

[

1.0

,

2.0

,

3.0

]

)

result

=

torch.

negative

(

x

)

print

(

result

)


PyTorch torch reference manual PyTorch torch reference manual