Created
May 19, 2019 12:21
-
-
Save Tony607/7fb1f27d896ef817be67202f332c1934 to your computer and use it in GitHub Desktop.
How to compress your Keras model x5 smaller with TensorFlow model optimization | DLology
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add a pruning step callback to peg the pruning step to the optimizer's | |
# step. Also add a callback to add pruning summaries to tensorboard | |
callbacks = [ | |
sparsity.UpdatePruningStep(), | |
sparsity.PruningSummaries(log_dir=logdir, profile_batch=0) | |
] | |
new_pruned_model.fit(x_train, y_train, | |
batch_size=batch_size, | |
epochs=epochs, | |
verbose=1, | |
callbacks=callbacks, | |
validation_data=(x_test, y_test)) | |
score = new_pruned_model.evaluate(x_test, y_test, verbose=0) | |
print('Test loss:', score[0]) | |
print('Test accuracy:', score[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment