Hi
I want to make a CNN with 3 convolution layers and 3 pooling layers, the net is like this :
convolution-pooling-convolution-pooling-convolution-pooling-fc1-fc2
the pooling is 2x2 and its stride is 1 and the convolutions are 5x5
the output sizes are respectively : 32,64,128,512,64
my network code is this :
class Net(nn.Module):
def init(self):
super(Net, self).init()
self.conv1 = nn.Conv2d(3, 32, 5)
self.pool = nn.AvgPool2d(2, 2, 1)
self.conv2 = nn.Conv2d(32, 64, 5)
self.conv3 = nn.Conv2d(64, 128, 5)
self.fc1 = nn.Linear(128 * 5 * 5, 512)
self.fc2 = nn.Linear(512, 64)
def forward(self, x):
    x = self.pool(F.relu(self.conv1(x)))
    x = self.pool(F.relu(self.conv2(x)))
    x = self.pool(F.relu(self.conv3(x)))
    x = x.view(-1, 128 * 5 * 5)
    x = F.relu(self.fc1(x))
    x = F.relu(self.fc2(x))
    return x

I got this error :   x = x.view(-1, 128 * 5 * 5)
RuntimeError: invalid argument 2: size ‘[-1 x 3200]’ is invalid for input with 512 elements at /opt/conda/conda-bld/pytorch_1524577177097/work/aten/src/TH/THStorage.c:37