Tensorflow TFLiteConverter是否自动量化Keras模型?
我使用tf.lite.TFLiteConverter将经过训练的Keras模型转换为tflite_模型。转换后的tflite_模型是量子化的吗?下面是进行转换的代码段Tensorflow TFLiteConverter是否自动量化Keras模型?,tensorflow,quantization,Tensorflow,Quantization,我使用tf.lite.TFLiteConverter将经过训练的Keras模型转换为tflite_模型。转换后的tflite_模型是量子化的吗?下面是进行转换的代码段 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 = conver
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)
基本上,在使用converter.convert like进行转换之前,我们需要converter.post_training_quantize=True标志
要启用模型量化,我们需要添加以下标志~>converter.post_training_quantize=true在哪里插入代码?是在tflite\u model=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)