PyTorch torch.divide 関数
torch.dividePyTorch で要素ごとの除算に使用される関数です( div と同等)。
関数定義
torch.divide(input, other, *, rounding_mode=None, out=None)
使用例
例
import torch
# 要素ごとの除算の例
x = torch.tensor([10.0, 20.0, 30.0])
y = torch.tensor([2.0, 4.0, 5.0])
result = torch.divide(x, y)
print(result) # tensor([5.0000, 5.0000, 6.0000])
# 要素ごとの除算の例
x = torch.tensor([10.0, 20.0, 30.0])
y = torch.tensor([2.0, 4.0, 5.0])
result = torch.divide(x, y)
print(result) # tensor([5.0000, 5.0000, 6.0000])
その他の拡張
Pytorch torch リファレンスマニュアル