Hi, I am trying to train a model with transfer learning. When I set requires_grad=True for a few layers, but I send all my model parameters to the optimizer (by using model.parameters()), I see that even layers with requires_grad=False gets its weights updated. However, if instead I use filter(lambda p: p.requires_grad, net.parameters()) to set my model parameters in the optimizer, the correct weights get updated.
Is this the correct behavior, or is there some error in my code?
If this is the correct behavior, then how does my optimizer update weights when requires_grad=False?