Hi, I have the following model:
class LeNet(nn.Module):
    def __init__(self):
        super(LeNet, self).__init__()
        self.conv1 = nn.Conv2d(3, 6, 5)
        self.conv2 = nn.Conv2d(6, 16, 5)
        self.fc1 = nn.Linear(16*4*4, 120)
        self.fc2 = nn.Linear(120, 84)
        self.fc3 = nn.Linear(84, 10)

    def forward(self, x):
        out = F.relu(self.conv1(x))
        out = F.max_pool2d(out, 2)
        out = F.relu(self.conv2(out))
        out = F.max_pool2d(out, 2)
        out = out.view(out.size(0), -1)
        out = F.relu(self.fc1(out))
        out = F.relu(self.fc2(out))
        out = self.fc3(out)
        return out

I want to load a pre-trained file for it, remove the last FC layer and use it as a feature extractor by:
sourceCNN = nn.Sequential(*list(sourceCNN.children())[:-1])
But now sourceCNN.forward throws the error:
RuntimeError: matrices expected, got 4D, 2D tensors at /b/wheel/pytorch-src/torch/lib/TH/generic/THTensorMath.c:1232

Where, if I do not convert the model to sequential model it works perfectly. Now, I have seen some existing posts with these kind of errors on forum being solved with .view however, I do not know what exactly is going on and why do we need to call .view and what should be the arguments of it?
Thanks!