0

I would like to count the number of parameters of a Object Detection model loaded from TensorFlow Hub, for example https://tfhub.dev/tensorflow/ssd_mobilenet_v2/2. I've tried this:

hub_model = hub.load("https://tfhub.dev/tensorflow/ssd_mobilenet_v2/2")
print(len(hub_model.signatures['serving_default'].variables))

But the output is not very readable and I'm not even sure if it's correct. I've also tried this way:

malli = hub.KerasLayer("https://tfhub.dev/tensorflow/ssd_mobilenet_v2/2")
print("Thickness of the model:", len(malli.weights))

But it returns just an empty list [] of length 0.

It would be nice to be able to use the Keras summary() method on these models, but it cannot be called on a KerasLayer, so would incorporating this layer into a model with Keras.Sequential work?

  • You could try hub.load() followed by https://stackoverflow.com/questions/38160940/how-to-count-total-number-of-trainable-parameters-in-a-tensorflow-model – Andrey Khorlin Oct 20 '21 at 19:12

1 Answers1

0

There is a tool that counts total number of parameters for a checkpoint file: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/inspect_checkpoint.py

$ python inspect_checkpoint.py --file_name=/checkpoint/file/name --all_tensors