Thank you very much, but the code I gave produces an error. it says:
fc doesnt have any attribute named parameters()
so instead I did :
for _, param in resnet18.fc._parameters.items(): 
    print(param.requires_grad)
    param.requires_grad = True

and interestingly for  this  to work I have to do :
for module in resnet18.modules():
    if module._get_name() != 'Linear':
        print('layer: ',module._get_name())
        for param in module.parameters():
            param.requires_grad_(False)
    elif module._get_name() == 'Linear':
        for param in module.parameters():
            param.requires_grad_(True)

again if I just do :
for module in resnet18.modules():
    if module._get_name() != 'Linear':
        print('layer: ',module._get_name())
        for param in module.parameters():
            param.requires_grad_(False)

and print
for param in resnet18.parameters():
    print(param.requires_grad)

all parameters are set as False!
This is really puzzeling.