RuntimeError: Expected 4-dimensional input for 4-dimensional weight [6, 1, 3, 5], but got 3-dimensional input of size [10, 32, 32] instead

Hello, trying to train model on 32x32 images. but got dimensional error.

Here is my Module.

And here is an error

i just don’t get where is that 4th input?

The fourth dimension is the number of channels. Currently you only have batch size and x and y. You need to add the number of channels. To just do it simply in your forward function you can do this

def forward(self, x):
     x = x.unsqueeze(1)

Finally, thank you. I thought that color channels were the first input in self.conv1