TUTORIALAI & dataFETCHED

PyTorch torch.negative 函数

PyTorch torch.negative 函数 Pytorch torch 参考手册 torch.negative 是 PyTorch 中用于逐元素取负的函数。与 torch.neg 功能相同。 函数定义 torch.negative(input, out=None) 使用示例 实例 [mycode4 type='python'] import torch # 逐元素取负 x = torch..

Updated 7/16/2026

Tutorial detail pages default to noindex.

PyTorch torch.negative 函数


Pytorch torch 参考手册 Pytorch torch 参考手册

torch.negative 是 PyTorch 中用于逐元素取负的函数。与 torch.neg 功能相同。

函数定义

torch.negative(input, out=None)

使用示例

实例

import torch

# 逐元素取负
x = torch.tensor([1.0, 2.0, 3.0])
result = torch.negative(x)
print(result)

Pytorch torch 参考手册 Pytorch torch 参考手册