-
-
Save AkiyonKS/dfaefed629c92e0562397be53074f28a to your computer and use it in GitHub Desktop.
This file contains 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
converter = tf.lite.TFLiteConverter.from_keras_model(model_for_export) | |
converter.optimizations = [tf.lite.Optimize.DEFAULT] | |
quantized_and_pruned_tflite_model = converter.convert() | |
_, quantized_and_pruned_tflite_file = tempfile.mkstemp('.tflite') | |
with open(quantized_and_pruned_tflite_file, 'wb') as f: | |
f.write(quantized_and_pruned_tflite_model) | |
print('Saved quantized and pruned TFLite model to:', quantized_and_pruned_tflite_file) | |
print("Size of gzipped baseline Keras model: %.2f bytes" % (get_gzipped_model_size(keras_file))) | |
print("Size of gzipped pruned and quantized TFlite model: %.2f bytes" % (get_gzipped_model_size(quantized_and_pruned_tflite_file))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment