Adding fc layers to a model

I’m trying to extend this VGG network by adding 2 FC layer but seems like I failed at something. Original one:

class VGG(nn.Module):
    def __init__(self, vgg_name):
        super(VGG, self).__init__()
        self.features = self._make_layers(cfg[vgg_name])
        self.classifier = nn.Linear(512, 7)

    def forward(self, x):
        out = self.features(x)
        out = out.view(out.size(0), -1)
        out = F.dropout(out, p=0.5, training=self.training)
        out = self.classifier(out)
        return out

What I did is:

class VGG(nn.Module):
    def __init__(self, vgg_name):
        super(VGG, self).__init__()
        self.features = self._make_layers(cfg[vgg_name])
        self.fc1 = nn.Linear(512, 4096)
        self.fc2 = nn.Linear(4096, 4096)
        self.classifier = nn.Linear(4096, 7)

    def forward(self, x):
        out = self.features(x)
        out = out.view(x.size(0), -1)
        out = F.relu(self.fc1(x))
        out = F.dropout(out, p=0.5, training=self.training)
        out = F.relu(self.fc2(x))
        out = F.dropout(out, p=0.5, training=self.training)
        out = self.classifier(x)
        return out

You are currently passing x instead of out to all linear layers.

I think you should make sure of inputs and outputs of each layer. take your time.