Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.hash_tensor function

PyTorch torch.hash_tensor function


PyTorch torch reference manual 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

)

print

(

f

"Hash of x: {hash_x}"

)

print

(

f

"Hash of y: {hash_y}"

)

print

(

f

"Hashes equal: {hash_x == hash_y}"

)


PyTorch torch reference manual PyTorch torch reference manual