target.permute([0, 3, 1, 2])
一定要使用permute以及中括号
一些在我这里没起到作用的网上的例子:
1. https://blog.csdn.net/zouxiaolv/article/details/80936725
preds = to_numpy(preds)#preds是[2985x16x2] preds = preds.transpose(2, 1, 0)#preds[2x16x2985]
2. https://www.jb51.net/article/152793.htm
import torch x = torch.linspace(1, 9, steps=9).view(3, 3) b=x.permute(1,0) print(b) print(b.permute(1,0))