Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

added reduction_utils.py in the utils directory for 'model surgery' #309

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

sharmaprakhar
Copy link

This utility is an add on to Keras to perform model 'surgery'. The utility provides functions to modify the model json and saved model h5 definition to restructure and rearrange the model architecture kernels, WITHOUT retraining.

The current version is tested with Tensorflow and Theano on python 3.5 and 3.6. Testing wasn't done with CNTK

It is recommended to copy the model h5 file before performing model surgery using the following command:

h5repack -i <model_h5_file> -o <new_model_h5_file>

and run the provided functions on the new h5 file generated. The docstrings provide full description of the method functionality but in case of assistance, please reach out to me via github.

REDUCTION_UTILS:
reduction_utils.py can be used to prune or modify the model architecture. The flexibility of changing kernel matrices, not just removing them enables advanced pruning methods like cosine similarity based pruning (included in reduction_utils.py), correlation coffecient based pruning and just average percentage of zeros pruning methods.

Along with the addition of reduction utils, changes has been made to keras_contrib/layers/convolutional.py. For details, see this fix (#292):
#292

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant