我使用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)
答案 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)