torch.neg¶
- torch.neg(input, *, out=None) → 张量 ¶
返回一个新张量,其元素为
input
元素的相反数。- 参数:
input (Tensor) – 输入张量。
- 关键字参数:
输出(张量,可选)- 输出张量。
示例:
>>> a = torch.randn(5) >>> a tensor([ 0.0090, -0.2262, -0.0682, -0.2866, 0.3940]) >>> torch.neg(a) tensor([-0.0090, 0.2262, 0.0682, 0.2866, -0.3940])