0

I am applying the pruning function from tensorflow_model_optimization, tfmot.sparsity.keras.prune_low_magnitude() to MobileNetV2.

Is there any way to set only some layers of the model to be prunable? For training, there is a method "set_trainable", but I haven't found any equivalent for pruning.

Any ideas or comments will be appreciated! :)

asti205
  • 154
  • 7

1 Answers1

0

In the end I found that you can also apply prune_low_magnitude() per layer.

So the workaround would be to define a list containing the names or types of the layers that shall be pruned, and iterate the layer-wise pruning over all layers in this list.

asti205
  • 154
  • 7
  • 1
    For anyone trying to do something similar, the docs for the same are available [here](https://www.tensorflow.org/model_optimization/guide/pruning/comprehensive_guide#prune_some_layers_sequential_and_functional) – SajanGohil Oct 26 '20 at 07:29
  • Thanks for the link, this documentation was not available back then :) It is very helpful, indeed! – asti205 Oct 28 '20 at 14:10