PyTorch torch.randperm Function


Pytorch torch 参考手册PyTorch torch Reference Manual

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

Function Definition

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

Usage Example

Example

import torch

# Create a random permutation from 0 to 9
x = torch.randperm(10)

print(x)

Pytorch torch 参考手册PyTorch torch Reference Manual

Other Extensions