PyTorch torch.bitwise_xor 関数
torch.bitwise_xorは PyTorch で要素ごとのビット単位XORを行う関数です。
関数定義
torch.bitwise_xor(input, other, *, out=None)
使用例
実例
import torch
# ビット単位XORの例
x = torch.tensor([5, 3, 7], dtype=torch.int8)
y = torch.tensor([1, 3, 4], dtype=torch.int8)
result = torch.bitwise_xor(x, y)
print(result) # tensor([4, 0, 3], dtype=int8)
# ビット単位XORの例
x = torch.tensor([5, 3, 7], dtype=torch.int8)
y = torch.tensor([1, 3, 4], dtype=torch.int8)
result = torch.bitwise_xor(x, y)
print(result) # tensor([4, 0, 3], dtype=int8)
その他の拡張
Pytorch torch リファレンスマニュアル