TFLiteConverter是否自动量化Keras模型?

时间:2019-08-22 12:26:06

标签: tensorflow quantization

我使用tf.lite.TFLiteConverter将训练好的Keras模型转换为tflite_model。转换后的tflite_model是量化的吗?这是进行转换的代码段。

import tensorflow as tf

keras_model = "./Trained_Models/h_vs_o_a_V1.h5"

converter = tf.lite.TFLiteConverter.from_keras_model_file(keras_model)
tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)

1 个答案:

答案 0 :(得分:1)

基本上,在使用converter.post_training_quantize = True之类的转换之前,我们需要converter.convert()标志

import tensorflow as tf

keras_model = "./Trained_Models/h_vs_o_a_V1.h5"

converter = tf.lite.TFLiteConverter.from_keras_model_file(keras_model)
converter.post_training_quantize = True
tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)