Hi, trying to make a CNN work but i am getting errors regarding the input to the fc. I understand that it is the input that is wrong but i cant seem to get it right any help would be much appreciated.
Here is the network
class Net(nn.Module): def __init__(self): super(SecondCNN, self).__init__() self.conv1 = nn.Conv2d(3, 6, 5) self.pool = nn.MaxPool2d(1, 1) self.conv2 = nn.Conv2d(6, 16, 5) self.conv3 = nn.Conv2d(16, 32, 5) self.fc1 = nn.Linear(32 * 20 * 20 , 120) self.fc2 = nn.Linear(120, 84) self.fc3 = nn.Linear(84, 10) def forward(self, x): x = self.pool(F.relu(self.conv1(x))) print(x.shape) x = self.pool(F.relu(self.conv2(x))) print(x.shape) x = self.pool(F.relu(self.conv3(x))) print(x.shape) x = F.relu(self.fc1(x)) print(x.shape) x = F.relu(self.fc2(x)) x = self.fc3(x) return x
Here is the size of the first input to the network: torch.Size([4, 3, 32, 32])
And as you can see im printing out the shape along the way as im trying to debug this, i only get the first three as it throws the runtime error before the fc.
Here are the shapes:
torch.Size([4, 6, 28, 28]) torch.Size([4, 16, 24, 24]) torch.Size([4, 32, 20, 20])