Description of TF Lite's Toco converter args for quantization aware training
You should never need to manually set the quantization stats.
Have you tried the post-training-quantization tutorials?
https://www.tensorflow.org/lite/performance/post_training_integer_quant
Basically they set the quantization options:
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]converter.inference_input_type = tf.uint8converter.inference_output_type = tf.uint8
Then they pass a "representative dataset" to the converter, so that the converter can run the model a few batches to gather the necessary statistics:
def representative_data_gen(): for input_value in mnist_ds.take(100): yield [input_value]converter.representative_dataset = representative_data_gen
While there are options for quantized training, it's always easier to to do post-training quantization.