Last active
May 1, 2023 05:45
-
-
Save rahulremanan/c2d904007284c35ddcd0e6111cb0c558 to your computer and use it in GitHub Desktop.
Post-training dynamic range quantization
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
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