Skip to content

Instantly share code, notes, and snippets.

@Rishit-dagli
Created October 16, 2020 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rishit-dagli/1a29b58075bd3d9c37809fdf356be5d6 to your computer and use it in GitHub Desktop.
Save Rishit-dagli/1a29b58075bd3d9c37809fdf356be5d6 to your computer and use it in GitHub Desktop.
Post-training weight quantization, TFLite
converter = tf.lite.TFLiteConverter.from_keras_model(model)
converter.experimental_new_converter = True
# Post training quantization
converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]
tflite_quant_model = converter.convert()
tflite_model_quant_file = "model.tflite"
tflite_model_quant_file.write_bytes(tflite_quant_model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment