PyTorch torch.neg Function


Pytorch torch 参考手册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)

Pytorch torch 参考手册PyTorch torch Reference Manual

Other Extensions