Mobilenet v2 - How to fine tune?

There’s two ways you could do that:

  1. Split the model into groups as @florianl mentioned above. You can then do learn.freeze_to(...). However, I think this freezes a bunch of layers sequentially, so if you need to only tweak a specific part, the method below is better
  2. Access the specific layer, and turn off logging gradients by changing the requires_grad attribute. For example:
learn = cnn_learner(dls, model)
for p in learn.model[1][3].parameters():
    p.requires_grad = None
    # p.requires_grad = False
    # I remember reading somewhere `None` is better, but can't remember why

EDIT: I meant for p in model[...].parameters()

2 Likes