Fix backbone and task1 parameters, fine-tune task2 's parameters

I test task1’s acc after resume model. And accuracy value match to resume file at first. But after some iterations of training , task1’s accuracy has changed. Don’t know what’s wrong about training. I think fix backbone and task1 parameters should get always the same task1’s accuracy .

code of fix backbone and task1 parameters:

for p in self.model.parameters():
    p.requires_grad = False
for q in self.model.task2.parameters():
    q.requires_grad = True

Besides setting the requires_grad attribute to False, you might need to call .eval() on the layers involved for “task1”.
This will make sure to disable dropout and use the running stats of batchnorm layers.
If you keep the model in train() mode, the batchnorm stats will be updated and might thus change the accuracy during evaluation.

1 Like

Thank you very much !!! :100: :100: :100: