随机打乱函数 torch.randperm的使用(类似tensorflow中的tf.random_shuffle)
例:一维x=torch.tensor([2,5,16,10,0,5618,81,8,18])indices=torch.randperm(x.numel())shuffled_x=x[indices]print(shuffled_x)#tensor([2,18,5618,81,5,10,8,0,16])indices=torch.randperm(x.numel())shuffled_x=x.vi