It may work for you. please see this part of the page I send in the following link (github page):
Freezing parameters of some layers to prevent them from retraining

  
      
      GitHub
  
  
    

mortezamg63/Accessing-and-modifying-different-layers-of-a-pretrained-model-in-py... 988

Contribute to Accessing-and-modifying-different-layers-of-a-pretrained-model-in-pytorch development by creating an account on GitHub.