Each parameters of the model have requires_grad flag:
For resnet example in the doc, this loop will freeze all layers
for param in model.parameters(): param.requires_grad = False
For partially unfreezing some of the last layers, we can identify parameters we want to unfreeze in this loop. setting the flag to True will suffice.