PyTorch torch.neg Function
PyTorch torch Reference Manual
torch.negis a function in PyTorch used for element-wise negation.
Function Definition
torch.neg(input, out=None)
Usage Example
Example
import torch
# Element-wise negation
x = torch.tensor([1.0, 2.0, 3.0])
result = torch.neg(x)
print(result)
# Element-wise negation
x = torch.tensor([1.0, 2.0, 3.0])
result = torch.neg(x)
print(result)
Other Extensions