question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pruning models from tf.keras.applications (efficientnet, resnet etc)

See original GitHub issue

I 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:open
  • Created 2 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
liyunlu0618commented, Apr 7, 2021

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.

0reactions
liyunlu0618commented, Apr 20, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found