PyTorch torch.sub 関数


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

torch.subPyTorch で要素ごとの減算を実行するための関数です。

関数定義

torch.sub(input, other, out=None)

使用例

実例

import torch

# 要素ごとの減算
x = torch.tensor([5.0, 6.0, 7.0])
y = torch.tensor([1.0, 2.0, 3.0])
result = torch.sub(x, y)
print(result)

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

その他の拡張