PyTorch torch.neg 関数


Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

torch.negPyTorch で要素ごとに符号を反転させるための関数です。

関数定義

torch.neg(input, out=None)

使用例

実例

import torch

# 要素ごとに符号を反転
x = torch.tensor([1.0, 2.0, 3.0])
result = torch.neg(x)
print(result)

Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

その他の拡張