Skip to content

Instantly share code, notes, and snippets.

@naviocean
Created November 17, 2020 07:46
Show Gist options
  • Save naviocean/37d5cb35b4dff4541c6598ac152ffaf7 to your computer and use it in GitHub Desktop.
Save naviocean/37d5cb35b4dff4541c6598ac152ffaf7 to your computer and use it in GitHub Desktop.
Check the number of parameters of a model
# reference
# https://discuss.pytorch.org/t/how-do-i-check-the-number-of-parameters-of-a-model/4325
def get_n_params(model):
pp=0
for p in list(model.parameters()):
nn=1
for s in list(p.size()):
nn = nn*s
pp += nn
return pp
model = LambdaResNet50()
print(get_n_params(model)) # 14.9M (Ours) / 15M(Paper)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment