How to unfreeze specific layers in a pretrained model?

hi there,
this article describes how to unfreeze specific layers in a pretrained model in Keras.

with something like this

||for layer in vgg16_trainable.layers:|
| --- | --- |
||if in ['block5_conv3']: #,'block5_conv2','block5_conv1']:|
||layer.trainable = True|
||layer.trainable = False|
||for layer in vgg16_trainable.layers:|
||print(, layer.trainable)|

Now i wonder: how is the same thing done in fastai / pytorch?
can the freeze() unfreeze() functions be as specific as in that Keras example?


Refer this piece for PyTorch. 06. PyTorch Transfer Learning - Zero to Mastery Learn PyTorch for Deep Learning

For fastai, this thread can be a good starting point - Understanding gradual unfreezing of model - #5 by AmorfEvo. Refer to the chapter of the book mentioned in the thread for more details

1 Like

amazing, thanks for those links.