大家好,我尝试使用以下代码将我的模型从 .h5(keras) 转换为 .tflite
import tensorflow as tf
keras_model = tf.keras.models.load_model("model06.h5")
converter = tf.lite.TFLiteConverter.from_keras_model(keras_model)
tflite_model = converter.convert()
with open('model06.tflite', 'wb') as f:
f.write(tflite_model)
但是在转换为 .tflite 之后,我的预测在精度上有一些损失,是否有更好的方法来转换模型而不损失模型的精度
答案 0 :(得分:0)
精度损失是正常的;事实上,这是预期的现象,这是速度和准确性之间的权衡。
您唯一能做的就是在转换时使用 float16
而不是 int8
以减轻精度损失。