Created
November 17, 2020 07:46
-
-
Save naviocean/37d5cb35b4dff4541c6598ac152ffaf7 to your computer and use it in GitHub Desktop.
Check the number of parameters of a model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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