Model giving same prediction

Hi, I have nueral network that is used to classify a patch as eye or not, give eye landmark and bounding box predictions.

All the three output layers are fully connected linear layers.

The problem with the model is, it is giving same output for the first output layer which has two nodes.

Here is my model architecture.

class Net(torch.nn.Module):
def init(self):
super(Net, self).init()
self.conv1 = nn.Conv2d(3, 32, 3)
torch.nn.init.xavier_normal_(self.conv1.weight)
self.pool1 = nn.MaxPool2d(3,stride=2,ceil_mode=True)
self.conv2 = nn.Conv2d(32, 64, 3)
torch.nn.init.xavier_normal_(self.conv2.weight)
self.pool2 = nn.MaxPool2d(3,stride=2,ceil_mode=True)
self.conv3 = nn.Conv2d(64, 64, 3)
torch.nn.init.xavier_normal_(self.conv3.weight)
self.pool3 = nn.MaxPool2d(2,stride=2,ceil_mode=True)
self.conv4 = nn.Conv2d(64, 128, 2)
torch.nn.init.xavier_normal_(self.conv4.weight)
self.fc1 = nn.Linear(31128, 256)
self.cls_prob_fc = nn.Linear(256,2)
self.bbox_pred_fc = nn.Linear(256,4)
self.lm_pred_fc = nn.Linear(256,12)

def forward(self, x):
    x = self.pool1(F.relu(self.conv1(x)))
    x = self.pool2(F.relu(self.conv2(x)))
    x = self.pool3(F.relu(self.conv3(x)))
    x = F.relu(self.conv4(x))
    x = x.view(x.size(0), 1*3*128)
    x = F.relu(self.fc1(x))
    x_cls_prob = self.cls_prob_fc(x)
    x_bbox_pred = self.bbox_pred_fc(x)
    x_lm_pred = self.lm_pred_fc(x)    
    return x_cls_prob,x_bbox_pred,x_lm_pred

Could anyone please help me with this

It your model is not training properly I would generally recommend to try to overfit a small dataset, e.g. just 10 samples, and make sure your model is able to do so by playing around with some hyperparameters.
If this is not possible, you might have some bugs in the code, e.g. forgetting to zero out the gradients.

PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier :wink: