'How to freeze a sub-model for one model, without affecting another sub-model with same pretrianed weightes?
I have a model composed of model_1, model_2, model_3. and the flow is model_1 and model_2 >>> model_3, how can I set that model _1 do not update and model_2 update. Note that the model_1 and model_2 with same structure and pretrained weights in the beginning of the training process. When I load one pretrained weight for model_1 and model_2, and frezze model_1 in the init, and I find that both models (model_1 and model_2 ) do not update in the trianing.
Solution 1:[1]
You can overwrite the train() and eval() methods of your model such that they will only alter your desired sub-model.
An example and some more info regarding train():
What does model.train() do in PyTorch?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tamir |
