Skip to content

Instantly share code, notes, and snippets.

@brodzik
Created August 9, 2020 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brodzik/1f905a924b115a5ca5be1dc836e03593 to your computer and use it in GitHub Desktop.
Save brodzik/1f905a924b115a5ca5be1dc836e03593 to your computer and use it in GitHub Desktop.
Get the number of trainable parameters in PyTorch
def count_parameters(model):
return sum(p.numel() for p in model.parameters() if p.requires_grad)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment