PyTorch torch.neg 函数
torch.neg 是 PyTorch 中用于逐元素取负的函数。
函数定义
torch.neg(input, out=None)
使用示例
实例
import torch
# 逐元素取负
x = torch.tensor([1.0, 2.0, 3.0])
result = torch.neg(x)
print(result)
# 逐元素取负
x = torch.tensor([1.0, 2.0, 3.0])
result = torch.neg(x)
print(result)

Pytorch torch 参考手册