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

PyTorch torch.randperm function

PyTorch torch.randperm function


PyTorch torch reference manual PyTorch torch reference manual

torch.randperm is a function in PyTorch used to create a random permutation of the integers from 0 to n-1.

Function definition

torch.randperm(n, dtype, device, requires_grad)


Usage examples

Example

import

torch

Create a random permutation of 0 to 9

x

=

torch.

randperm

(

10

)

print

(

x

)


PyTorch torch reference manual PyTorch torch reference manual