A question about the parameters()

I read two lines of codes as follows

for param in resnet.parameters():
param.requires_grad = False

And it is for fintune only top layer of the model, but I cant understand why?
Is there anyone who can explain it to me! Thank you very much!

That 2 lines of code freezes the whole model. If you want to finetune few layers, you need to get the parameters of those layers and make the ‘requires_grad’ as True, so that you can finetune those layers.