【问题标题】:Tensorflow Lite model outputs greater values than Tensorflow modelTensorflow Lite 模型输出比 Tensorflow 模型更大的值
【发布时间】:2021-06-09 09:04:39
【问题描述】:

我在 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)

【问题讨论】:

    标签: android tensorflow tensorflow-lite


    【解决方案1】:

    您应该展示有关如何转换模型的更多详细信息,可能是您的预处理和后期处理。错误的输出可能来自他们。

    【讨论】:

    • 请尝试不量化的转换。并非所有模型都能很好地进行量化。
    【解决方案2】:

    我找到了解决方案。在我的 Tensorflow 模型中,我有一些操作无法转换为 Tensorflow Lite 模型。这是关于操作转换的指南https://www.tensorflow.org/lite/guide/ops_compatibility。我改变了它们,现在一切都正确了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-14
      • 2019-03-17
      • 1970-01-01
      • 2019-02-03
      相关资源
      最近更新 更多