我在 Tensorflow 中训练了一个模型,因此可以产生的最大输出值为 1.0。然后我将其转换为 Tensorflow Lite 以安装在 android 上,现在 Tensorflow Lite 模型产生的值远大于 1.0。我能做些什么来解决这个问题?
我正在使用 Tensorflow 2.5
tf 模型 -> tflite 模型脚本
converter = tf.lite.TFLiteConverter.from_saved_model("/content/drive/MyDrive/savedmodel")
converter.optimizations = [tf.lite.Optimize.DEFAULT]
tflite_quant_model = converter.convert()
ite_models_dir = pathlib.Path("/content/drive/MyDrive/tflite_models/")
tflite_models_dir.mkdir(exist_ok=True, parents=True)
tflite_model_quant_file = tflite_models_dir/"model_temp_quant.tflite"
tflite_model_quant_file.write_bytes(tflite_quant_model)
我找到了解决方案。在我的 Tensorflow 模型中,我有一些无法转换为 Tensorflow Lite 模型的操作。这是有关操作转换的指南https://www.tensorflow.org/lite/guide/ops_compatibility。我改变了它们,现在一切都正确了。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句