Tensorflow Lite 模型输出比 Tensorflow 模型更大的值

迈克尔·杜斯

我在 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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

ValueError:模型的输出张量必须是TensorFlow`Layer`的输出

将ONNX模型转换为TensorFlow Lite

为量化的Tensorflow Lite模型创建位图ByteBuffer

TensorFlow:如何在Tensorflow训练模型中找到输出节点?

如何知道Tensorflow Lite模型的输入/输出功能信息?

Tensorflow Lite模型输出错误

Tensorflow-ValueError:模型的输出张量必须是TensorFlow`Layer`的输出

如何将TensorFlow Lite模型量化为16位

将模型转换为Tensorflow-lite时出错

在Hexagon DSP上运行Tensorflow Lite演示模型

如何在tensorflow中为Java使用tensorflow-lite模型

我可以在Tensorflow Lite模型上获取指标吗?

Android分类应用程序因Tensorflow Lite模型崩溃

如何验证从Keras转换的Tensorflow-Lite模型

如何从Tensorflow.js(.json)模型转换为Tensorflow(SavedModel)或Tensorflow Lite(.tflite)模型?

无论输入如何,Tensorflow lite模型输出始终提供相同的输出

将已保存的Tensorflow模型转换为Tensorflow Lite的正确方法是什么

Tensorflow分类模型返回错误的输出形状

无法在TensorFlow中完全分离模型的输出

运行交叉验证时,Tensorflow保存的模型变得更大

在 TensorFlow Lite 中运行 Keras 模型时的不同预测

使用 Keras Functional API 为 Tensorflow LITE 构建模型

如何在 tensorflow lite 模型文件 (v 1.x) 中嵌入模型版本或描述

如何创建可轻松转换为 TensorFlow Lite 的模型?

将tensorflow lite模型直接导入tensorflow/keras

在 python 中加载 Tensorflow Lite 模型

从源 tflite 模型构建的 tensorflow-lite-select-tf-ops 和 tensorflow-lite AAR 找不到 org.tensorflow.lite.Interpreter

如何将python中的KNN Scikit-learn模型转换为tensorflow lite模型?

如何基于模型 Tensorflow lite 进行预测?