Skip to content

Instantly share code, notes, and snippets.

@Quetzalcohuatl
Created October 16, 2022 22:18
Show Gist options
  • Save Quetzalcohuatl/8b9477bfd00ba34df457ffdfcb6654c5 to your computer and use it in GitHub Desktop.
Save Quetzalcohuatl/8b9477bfd00ba34df457ffdfcb6654c5 to your computer and use it in GitHub Desktop.
# View layers with model.children()
# Get params with module.parameters()
m = resnet50(pretrained=True)
_ = m.train()
for param in list(m.children())[0].parameters():
param.requires_grad = False
_ = m.resnet50.eval() # disables dropout
Then:
optimizer = Adam(filter(lambda p: p.requires_grad, m.parameters()), lr=3e-4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment