PyTorch torch.hash_tensor 関数
torch.hash_tensorは PyTorch でテンソルのハッシュ化に使用される関数です。テンソルのハッシュ値を返します。
関数定義
torch.hash_tensor(tensor)
使用例
実例
import torch
# テンソルを作成
x = torch.tensor([1, 2, 3, 4, 5])
y = torch.tensor([1, 2, 3, 4, 5])
# ハッシュ値を取得
hash_x = torch.hash_tensor(x)
hash_y = torch.hash_tensor(y)
print(f"Hash of x: {hash_x}")
print(f"Hash of y: {hash_y}")
print(f"Hashes equal: {hash_x == hash_y}")
# テンソルを作成
x = torch.tensor([1, 2, 3, 4, 5])
y = torch.tensor([1, 2, 3, 4, 5])
# ハッシュ値を取得
hash_x = torch.hash_tensor(x)
hash_y = torch.hash_tensor(y)
print(f"Hash of x: {hash_x}")
print(f"Hash of y: {hash_y}")
print(f"Hashes equal: {hash_x == hash_y}")
その他の拡張
Pytorch torch リファレンスマニュアル