Skip to content

Instantly share code, notes, and snippets.

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 rahulremanan/c2d904007284c35ddcd0e6111cb0c558 to your computer and use it in GitHub Desktop.
Save rahulremanan/c2d904007284c35ddcd0e6111cb0c558 to your computer and use it in GitHub Desktop.
Post-training dynamic range quantization
def dynamic_range_quantize_model(model):
_converter = tf.lite.TFLiteConverter.from_keras_model(model)
del model
_converter.optimizations = [tf.lite.Optimize.DEFAULT]
_converter.target_spec.supported_ops = [
tf.lite.OpsSet.TFLITE_BUILTINS, # enable TensorFlow Lite ops.
tf.lite.OpsSet.SELECT_TF_OPS # enable TensorFlow ops.
]
_tflite_model = _converter.convert()
del _converter
return _tflite_model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment