permute

torchhd.permute(input: VSATensor, *, shifts=1) VSATensor[source]

Permutes hypervector by specified number of shifts.

The permutation operator is used to assign an order to hypervectors.

\[\Pi: \mathcal{H} \to \mathcal{H}\]
Parameters:
  • input (VSATensor) – input hypervector

  • shifts (int, optional) – The number of places by which the elements of the tensor are shifted.

Shapes:
  • Input: \((*)\)

  • Output: \((*)\)

Examples:

>>> a = torchhd.random(1, 10)
>>> a
tensor([[-1., -1., -1.,  1., -1., -1.,  1., -1., -1., -1.]])
>>> torchhd.permute(a)
tensor([[-1., -1., -1., -1.,  1., -1., -1.,  1., -1., -1.]])