create_random_permute

torchhd.create_random_permute(dim: int) None[source]

Creates random permutation functions.

Parameters:

dim (int) – dimension of the hypervectors

Examples:

>>> a = torchhd.random(3, 10)
>>> a
tensor([[-1.,  1.,  1.,  1., -1., -1., -1., -1.,  1., -1.],
        [-1., -1., -1.,  1., -1.,  1., -1., -1.,  1., -1.],
        [ 1.,  1.,  1., -1., -1.,  1., -1.,  1.,  1.,  1.]])
>>> p = torchhd.create_random_permute(10)
>>> p(a, 2)
tensor([[ 1.,  1., -1., -1., -1.,  1., -1., -1.,  1., -1.],
        [ 1., -1., -1., -1.,  1.,  1., -1., -1., -1., -1.],
        [ 1.,  1.,  1., -1.,  1., -1., -1.,  1.,  1.,  1.]])
>>> p(a, -2)
tensor([[-1.,  1.,  1.,  1., -1., -1., -1., -1.,  1., -1.],
        [-1., -1., -1.,  1., -1.,  1., -1., -1.,  1., -1.],
        [ 1.,  1.,  1., -1., -1.,  1., -1.,  1.,  1.,  1.]])