参考:https://stackoverflow.com/questions/44738273/torch-how-to-shuffle-a-tensor-by-its-rows
一维的:
x = torch.arange(0, 10)
print(x)
b=torch.randperm(x.size(0))
print(x[b])
a=torch.rand(3,5)
print(a)
a=a[torch.randperm(a.size(0))]
print(a)
a=a[:,torch.randperm(a.size(1))]
print(a)