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 layer.name in ['block5_conv3']: #,'block5_conv2','block5_conv1']:|
||layer.trainable = True|
||else:|
||layer.trainable = False|
|||
||for layer in vgg16_trainable.layers:|
||print(layer.name, 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?

thanks

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.