tensorflow - 将 .h5 转换为 .tflite 会降低我的模型预测精度
问题描述
大家好,我尝试使用以下代码将我的模型从 .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 后,我的预测在精度上有一些损失,有没有更好的方法来转换模型而不会损失模型的精度
解决方案
精度下降是正常的;实际上这是预期会发生的现象,它是速度和准确性之间的权衡。
您唯一可以做的就是使用float16
而不是int8
在转换时使用,以减轻精度损失。
推荐阅读
- serial-port - RS422 Pan & Tilt 总是重复命令而不是应答
- flutter - 颤振设置状态;它如何选择应该重建的 UI 的哪一部分?
- c# - 打印单元测试内函数的输出
- python - 皮查姆。'进程以退出代码 0 结束' 。运行代码后没有输出
- javascript - 在使用 React useState hook 更改类而不是 CSS className:hover 时如何获得淡入过渡?
- reactjs - React propTypes 将 isRquired 添加到指定形状的对象
- pycharm - PVlib 安装为可在 PyCharm 中使用的可编辑库
- android - 为 Android 构建 valgrind 失败并出现错误“ld:错误:无法找到库 -lgcc”
- r - 用扫帚拟合模型后如何保留原始列:增强
- next.js - 在选择反应中单击其他时如何显示输入字段