PyTorch torch.hash_tensor function
PyTorch torch reference manual
torch.hash_tensor A function in PyTorch for hashing a tensor. Returns the hash value of the tensor.
Function definition
torch.hash_tensor(tensor)
Usage examples
Example
import
torch
Creating tensors
x
=
torch.
tensor
(
[
1
,
2
,
3
,
4
,
5
]
)
y
=
torch.
tensor
(
[
1
,
2
,
3
,
4
,
5
]
)
Get the hash value
hash_x
=
torch.
hash_tensor
(
x
)
hash_y
=
torch.
hash_tensor
(
y
)
(
f
"Hash of x: {hash_x}"
)
(
f
"Hash of y: {hash_y}"
)
(
f
"Hashes equal: {hash_x == hash_y}"
)