randperm

dragon.vm.torch.randperm(
  n,
  out=None,
  dtype='int64',
  device=None,
  requires_grad=False
)[source]

Return a tensor with value in the permuted range.

Specify n to determine an interval \([0, n)\):

print(torch.randperm(4))
Parameters:
  • n (number) – The end of interval.
  • out (dragon.vm.torch.Tensor, optional) – The optional output tensor.
  • dtype (str, optional, default='int64') – The optional data type.
  • device (dragon.vm.torch.device, optional) – The optional device of returned tensor.
  • requires_grad (bool, optional, default=False) – True to record gradient for returned tensor.
Returns:

dragon.Tensor – The output tensor.