2
$\begingroup$

I'm using Keras, and I am struggling to know how many parameters Resnet-50 has. Keras documentation says around 25M, while if I use model.param_count() when loading a Resnet-50 model, it says 234M. Which one is correct? I'm confused.

model.summary prints this:

Total params: 234,355,586
Trainable params: 210,767,874
Non-trainable params: 23,587,712
$\endgroup$
4
  • 1
    $\begingroup$ call model.summary, there's no way it hat 230 million trainable parameters $\endgroup$ – Brale May 10 '20 at 20:54
  • 1
    $\begingroup$ The number of parameters depends on your input size and number of classes. Like @Brale_ said call model.summary() to be sure. $\endgroup$ – Djib2011 May 10 '20 at 22:20
  • 1
    $\begingroup$ How is model.summary() different from param_count()? $\endgroup$ – Tina J May 11 '20 at 4:04
  • $\begingroup$ Total params: 234,355,586 ... Trainable params: 210,767,874... Non-trainable params: 23,587,712 $\endgroup$ – Tina J May 11 '20 at 4:06
2
$\begingroup$
from keras.applications.resnet50 import ResNet50

resnet_model = ResNet50(weights='imagenet')

#resnet_model.count_params()
resnet_model.summary()

Total params: 25,636,712
Trainable params: 25,583,592
Non-trainable params: 53,120

Check your code once to be sure that it is ResNet50

$\endgroup$
1
$\begingroup$

Call model_name.summary()

This will return you the correct value for the total number of parameters.

$\endgroup$
2
  • $\begingroup$ That's what I did (look above). It's a saved fine-tuned model from ResNet-50. It shouldn't change the number of parameters, right? $\endgroup$ – Tina J May 11 '20 at 17:38
  • $\begingroup$ Well, typically a ResNet-50 contains around 25.6 million parameters including trainable parameters, maybe you didn't load the correct model, the number of parameters should never be that much $\endgroup$ – AKIB MOHAMMED KHAN May 12 '20 at 22:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.