I’m new to Pytorch and trying to implement the BKNet network from the article “Facial smile detection using convolutional neural networks”.
I wrote the following Neural network code:
model = nn.Sequential(nn.Conv2d(32, 32, kernel_size=(3,3), stride=1),
                      nn.Conv2d(32, 32, kernel_size=(3,3), stride=1),
                      nn.MaxPool2d(kernel_size=(2,2), stride=2),
                      nn.ReLU(),
                      nn.Conv2d(64, 64, kernel_size=(3,3), stride=1),
                      nn.Conv2d(64, 64, kernel_size=(3,3), stride=1),
                      nn.MaxPool2d(kernel_size=(2,2), stride=2),
                      nn.ReLU(),
                      nn.Conv2d(128, 128, kernel_size=(3,3), stride=1),
                      nn.Conv2d(128, 128, kernel_size=(3,3), stride=1),
                      nn.Conv2d(128, 128, kernel_size=(3,3), stride=1),
                      nn.MaxPool2d(kernel_size=(2,2), stride=2),
                      nn.ReLU(),
                      nn.Conv2d(256, 256, kernel_size=(3,3), stride=1),
                      nn.Conv2d(256, 256, kernel_size=(3,3), stride=1),
                      nn.Conv2d(256, 256, kernel_size=(3,3), stride=1),
                      nn.MaxPool2d(kernel_size=(2,2), stride=2),
                      nn.ReLU(),
                      nn.Linear(256,256),
                      nn.Linear(256,256),
                      nn.ReLU(),
                      nn.Linear(256,2),
                      nn.LogSoftmax(dim=1))

And trained it using the training code here 1 and an image database with many images of size 178x218, which are transformed in the following way:
data_transforms = {
    'train': transforms.Compose([
        transforms.Resize(178),
        transforms.CenterCrop(178),
        transforms.RandomHorizontalFlip(),
        transforms.ToTensor(),
        transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])
    ]),
    'val': transforms.Compose([
        transforms.Resize(178),
        transforms.CenterCrop(178),
        transforms.ToTensor(),
        transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])
    ]),
}

But I’m getting the following error:
RuntimeError: Given groups=1, weight of size 32 32 3 3, expected input[32, 3, 178, 178] to have 32 channels, but got 3 channels instead
What have I done wrong?