permutation#
- deeptrack.backend.array_api_compat_ext.torch.random.permutation(x: int | Tensor) Tensor#
Return a permuted sequence or tensor.
Mirrors numpy.random.permutation.
Parameters#
- x: int | torch.Tensor
If an integer, returns a permutation of torch.arange(x). If a tensor, returns a permuted copy along the first axis.
Returns#
- torch.Tensor
A permuted tensor.
Examples#
>>> import deeptrack.backend.array_api_compat_ext.torch.random as rnd
>>> rnd.permutation(5) tensor([2, 4, 0, 1, 3])
>>> import torch >>> >>> a = torch.arange(12).reshape(3, 4) >>> rnd.permutation(a).shape torch.Size([3, 4])