Hi Anne!



 amahoro12:

RuntimeError: Expected 4-dimensional input for 4-dimensional weight [8, 4, 3, 3], but got 1-dimensional input of size [16] instead
…
self.conv1 = nn.Conv2d(in_channels, 8, kernel_size=3, stride=1, padding=1)


You are passing a 1D tensor of shape [16] into your model as its
input.  But the first layer of your model is a Conv2d (with
in_channels = 4).
Your Conv2d layer, and hence your model, requires an input of shape
[nBatch, in_channels = 4, height, width].  (nBatch can be 1,
but it has to be there.)
You would typically be passing into your model a batch of multi-channel
2D images.  (Because of your choice of having in_channels = 4 for
conv1, in this specific case you need to pass in a batch of four-channel
images.)
Best.
K. Frank