Skip to content

Instantly share code, notes, and snippets.

@Tony607
Created May 19, 2019 12:22
Show Gist options
  • Save Tony607/a1c4936ce3de60f13a153c083ee378db to your computer and use it in GitHub Desktop.
Save Tony607/a1c4936ce3de60f13a153c083ee378db to your computer and use it in GitHub Desktop.
How to compress your Keras model x5 smaller with TensorFlow model optimization | DLology
from tensorflow.keras.models import load_model
model = load_model(final_model)
import numpy as np
for i, w in enumerate(model.get_weights()):
print(
"{} -- Total:{}, Zeros: {:.2f}%".format(
model.weights[i].name, w.size, np.sum(w == 0) / w.size * 100
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment