Given groups=1, weight of size 1 64 9 9, expected input[1, 1, 16, 16] to have 64 channels, but got 1 channels instead

Hi,

I’m using PyTorch to implement a CNN model for collaborative filtering but I got an error like this:
Given groups=1, weight of size 1 64 9 9, expected input[1, 1, 16, 16] to have 64 channels, but got 1 channels instead .

Input for the model is a tensor having torch.Size([1, 1, 256, 64])
Code for the CNN:

CNN_modules = []
CNN_modules.append(nn.Conv2d(1, 64, (225, 33)))
CNN_modules.append(nn.ReLU())	
CNN_modules.append(nn.Conv2d(64, 1, (17, 17)))
CNN_modules.append(nn.ReLU())
CNN_modules.append(nn.Conv2d(64, 1, (9, 9)))
CNN_modules.append(nn.ReLU())
CNN_modules.append(nn.Conv2d(64, 1, (5, 5)))
CNN_modules.append(nn.ReLU())
CNN_modules.append(nn.Conv2d(64, 1, (3, 3)))
CNN_modules.append(nn.ReLU())
CNN_modules.append(nn.Conv2d(64, 1, (1, 1)))
CNN_modules.append(nn.ReLU())

I want to keep 64 features for all hidden conv layers. I think the error may come from the data because this tensor is not a grayscale image. Can anybody help me to solve the problem? Thank you so soo much !!!
This is data of the input tensor:

Your second conv layer is returning an activation with a single output channel, while the next conv layer expects 64 input channels (same issue in all following layers).
You should set the number of output channels to 64 and your model should work.

It works, I have misunderstanding of what out_channels is. Thank you so much for your solution.