Fine tuning resent 152

I was trying to fine-tune resent 152 and I was using this piece of code:

> for param in list(model.parameters())[:-1]:
>     param.requires_grad = False

but I notice this was not working I changed it to :

> child_counter = 0
>  for child in model.children():
>        if child_counter < 9:
>            for param in child.parameters():
>                 param.requires_grad = False
>       child_counter += 1

it seems the second piece of code does the job, but I’m confiused, aren’t these two pieces of code doing the same thing ?

In the first code snippet you are setting all requires_grad flags to False except the model.fc.bias, while the second code snippet additionally keeps model.fc.weight.requires_grad as True.