Can we add 2 type of classifier using transfer learning?

well it was bit wrong but this is correct I got 85% accuracy on VGG with 50 epochs I think it can be increased if I use modified resnet in same manner

class Mymodel(nn.Module):
    def __init__(self):
        super(Mymodel, self).__init__()
        self.hidden_layer_output = nn.Sequential(*list(vgg.children())[:-1])
        self.vow_output = nn.Sequential(
                nn.Linear(512 * 7 * 7,4096),
                nn.ReLU(True),
                nn.Dropout(),
                nn.Linear(4096, 4096),
                nn.ReLU(True),
                nn.Dropout(),
                nn.Linear(4096, 10)
                )
        self.const_output = nn.Sequential(
                nn.Linear(512 * 7 * 7,4096),
                nn.ReLU(True),
                nn.Dropout(),
                nn.Linear(4096, 4096),
                nn.ReLU(True),
                nn.Dropout(),
                nn.Linear(4096, 10)
                )
    def forward(self, x):
        x=self.hidden_layer_output(x)
        x = x.view(x.size(0),-1)
        x_vow_output = self.vow_output(x)
        y_const_output = self.const_output(x)
        return x_vow_output,y_const_output
    

Also i would prefer using a bottleneck after avgpool in the feature extractor itself before passing through the classifiers.

For reference check the comment you marked as solution.

Yeah actually I’ll use resnet pretrained models, VGG have too many parameters in linear layers so it is taking time to train, resnet have very few parameters , also I don’t know but after training when I’m evaluating my test_set, it is giving change values every time. Any Idea why it is happening ? I’ll update my code here too, if required

One reason could be that you aren’t using model in eval mode for inference. That affects the dropout and adds stochasticity(randomness) to the model ouputs/predictions.

but that is not reason , I returned my model in eval mode and when I was applying model on my test data set, there I also explicitly mentioned model.eval(),. But still it is giving random value

Could you upload your testing code here?

Herevow and const are thye name of nodel

vow.eval()
const.eval()
vow_const = []
pic_id = []
for i, data in enumerate(test_loader,0):
    vow_out=vow(data[0].to(device))
    const_out=const(data[0].to(device))
    vow_list = vow_out.argmax(1).tolist()
    for i in list(data[1]):
        pic_id.append(i)
    const_list = const_out.argmax(1).tolist()
    for v,c in zip(vow_list,const_list):
        string = "V"+str(v)+"_"+"C"+str(c)
        vow_const.append(string)