记录randperm用法。
方法介绍torch.randperm(n)
这个方法将[0, n)中的元素随机排列,函数名randperm是random permutation缩写。
permutation的意思是排列。
import torch torch.randperm(10) # 注意返回的是张量 tensor([1, 5, 6, 8, 4, 0, 7, 2, 3, 9]) # 张量转list的方法 torch.randperm(10).tolist() [4, 8, 6, 9, 3, 0, 5, 2, 1, 7]



