PyTorch torch.eq 関数
torch.eqこれは、PyTorch において要素ごとの等価比較を行うための関数です。
関数定義
torch.eq(input, other, out)
使用例
例
import torch
a = torch.tensor([1, 2, 3, 4])
b = torch.tensor([1, 2, 0, 4])
result = torch.eq(a, b)
print(result)
a = torch.tensor([1, 2, 3, 4])
b = torch.tensor([1, 2, 0, 4])
result = torch.eq(a, b)
print(result)
出力結果は次のとおりです:
tensor([True, True, False, True])
その他の拡張
Pytorch torch リファレンスマニュアル