RuntimeError: Given groups=1, weight of size 32 3 3 3, expected input[1, 224, 224, 3] to have 3 chan

RuntimeError: Given groups=1, weight of size 32 3 3 3, expected input[1, 224, 224, 3] to have 3 channels, but got 224 channels instead问题。

我的代码出现这个问题是因为我的input是batchsize*size*size*channels,而model所需要的输入是batchsize*channels*size*size的形式,因此只需要    img_new= np.transpose(img_old, (0,3,1,2))   即可。

你可能感兴趣的:(pytorch)