I’m starting with CNN on MNIST dataset and I have a question: why must we have 128 in self.fc1 = nn.Linear(128, 4096). We have 32 filters in conv3, then in max_pool2D. The kernel size is 3 by 3, shouldn’t we have 32 x 3 x 3 = 288?
import torch.nn as nn
import torch.nn.functional as F

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(1, 32, kernel_size=3, stride=(1, 1))
        self.conv2 = nn.Conv2d(32, 64, kernel_size=3, stride=(1, 1))
        self.conv3 = nn.Conv2d(64, 32, kernel_size=3, stride=(1, 1), padding=1)
        self.fc1 = nn.Linear(128, 4096)
        self.fc2 = nn.Linear(4096, 10)
        
    def forward(self, x):
        x = F.relu(self.conv1(x))
        x = F.relu(self.conv2(x))
        x = F.max_pool2d(x, 3)
        x = F.relu(self.conv3(x))
        x = F.max_pool2d(x, 3)
        x = x.view(-1, 128)
        x = F.relu(self.fc1(x))
        x = F.dropout(x, training=self.training)
        x = self.fc2(x)
        return F.log_softmax(x, dim = 0)