Hi gkrisp!



 gkrisp9:

Expected 5-dimensional input for 5-dimensional weight [64, 3, 7, 7, 7]


This is telling you that the first Conv3d layer of your resnet has a
weight with shape [64, 3, 7, 7, 7], which is to say that is is a
Conv3d (in_channels = 3, out_channels = 64, kernel_size = 7).
Therefore the input to your resnet (and hence to this Conv3d) must
have shape [nBatch, nChannels = 3, height, width, depth].
Your first error was caused because your input didn’t have the nBatch
dimension.  This dimension can have size one if you want, but it has to
be present.
unsqueeze() provided the required nBatch dimension, but you then
get the second error because your input only has 2 channels, while
this particular Conv3d is expecting 3 channels.
Because your resnet is pretrained (and I assume that you don’t want
to throw that away), you should probably add a third channel to your
input, using something redundant like a duplicate of your second channel
or the average of your two “real” channels.
Best.
K. Frank