Pruning models from tf.keras.applications (efficientnet, resnet etc)
See original GitHub issueI am finetuning the tf.keras.applications model on my data for the problem of image classification. I was able to complete training and test results look good. In order to deploy the model, I wanted to perform some pruning and optimization. I tried following the Keras Pruning tutorial, but I could not figure out how to enable pruning on the efficientnet layer. If we could have a tutorial on this or a worked out example, that would be great, thank you!
Here is the model summary:
Model: "model_3"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_8 (InputLayer) [(None, 224, 224, 3)] 0
_________________________________________________________________
efficientnetb0 (Functional) (None, 7, 7, 1280) 4049571
_________________________________________________________________
global_average_pooling2d_3 ( (None, 1280) 0
_________________________________________________________________
dense_6 (Dense) (None, 8) 10248
_________________________________________________________________
dropout_3 (Dropout) (None, 8) 0
_________________________________________________________________
dense_7 (Dense) (None, 1) 9
=================================================================
Total params: 4,059,828
Trainable params: 10,257
Non-trainable params: 4,049,571
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Pruning in Keras example | TensorFlow Model Optimization
Train a tf.keras model for MNIST from scratch. Fine tune the model by applying the pruning API and see the accuracy. Create 3x...
Read more >Keras Applications
Model Size (MB) Top‑1 Accuracy Top‑5 Accuracy Parameters Depth Time (ms) per infer...
Xception 88 79.0% 94.5% 22.9M 81 109.4
VGG16 528 71.3% 90.1% 138.4M...
Read more >Model Pruning in Deep Neural Networks Using the ...
Pruning a machine learning model consists of removing (setting to 0 permanently) certain weights. Usually the weights that are pruned are those that...
Read more >EfficientNet: Theory + Code - LearnOpenCV
Model Scaling: The final option is to use a standard network like GoogleNet or ResNet and scale it up (i.e. use larger parameters)...
Read more >New mobile neural network architectures - Machine, Think!
We'll use the ImageNet test set accuracy as an indicator of how good the model architecture is, but keep in mind this is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thanks for reporting the error. I’m working on a change to support pruning a model recursively. Will let you know once it’s checked-in.
You may have to build from source at the moment: https://www.tensorflow.org/model_optimization/guide/install#installing_from_source
Will let you know once we have a new release.