PyTorch torch.hash_tensor Function
PyTorch torch Reference Manual
torch.hash_tensorIt is a function in PyTorch used for tensor hashing. Returns the hash value of the tensor.
Function Definition
torch.hash_tensor(tensor)
Usage Example
Example
import torch
# Create tensor
x = torch.tensor([1, 2, 3, 4, 5])
y = torch.tensor([1, 2, 3, 4, 5])
# Get hash value
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}")
# Create tensor
x = torch.tensor([1, 2, 3, 4, 5])
y = torch.tensor([1, 2, 3, 4, 5])
# Get hash value
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}")
Other Extensions