运行tensorflow lite示例时出错

问题描述 投票:0回答:1

我尝试构建并运行tensorflow lite示例(最小)。

构建没问题,但运行此程序时出现错误。

为什么会出现这个错误?

使用的模型是在tensorflow上训练的自定义模型,并使用toco转换tensorflow lite。

root@90f212114f89:/tensorflow# bazel-bin/tensorflow/contrib/lite/examples/minimal/minimal /root/DNNSE/model/tflite_model.lite
tensorflow/contrib/lite/kernels/reduce.cc:107 current >= 0 && current < input_num_dims was not true.
tensorflow/contrib/lite/kernels/reduce.cc:107 current >= 0 && current < input_num_dims was not true.
tensorflow/contrib/lite/kernels/reduce.cc:107 current >= 0 && current < input_num_dims was not true.
tensorflow/contrib/lite/kernels/reduce.cc:107 current >= 0 && current < input_num_dims was not true.
Node 8 failed to prepare.

Error at tensorflow/contrib/lite/examples/minimal/minimal.cc:59

节点 8 准备失败。 <- this error throw in interpreter PrepareOpsStartingAt() function.

我认为模型转换.tflite时出现一些错误

如何调试这个问题?

我在下面使用了构建选项。

 bazel build ... --compilation_mode=dbg -s

还有其他有用的构建选项吗?

tensorflow tensorflow-lite
1个回答
0
投票

您遇到的错误消息表明在 TensorFlow Lite 中准备节点时出现问题。具体来说,它似乎与reduce操作有关。您可以采取以下一些步骤来排除故障并可能解决问题:

检查 TensorFlow Lite 模型:确保您尝试加载的 TensorFlow Lite 模型 (tflite_model.lite) 有效且已正确生成。您可以通过在 Python 中加载模型并使用 TensorFlow Lite 解释器执行推理来验证这一点。

检查有问题的节点:确定 TensorFlow Lite 模型中的哪个节点导致错误。您可以使用 TensorFlow Lite 的 Python API 检查模型并打印有关每个节点的信息,包括其类型和属性。

检查输入数据:如果错误与输入尺寸 (input_num_dims) 有关,请仔细检查您向模型提供的输入数据。确保它具有模型预期的正确形状和格式。

更新 TensorFlow Lite:确保您使用的是最新版本的 TensorFlow Lite。新版本中可能存在错误修复或改进,可以解决您遇到的问题。

查找类似问题:搜索在线论坛、GitHub 问题或 TensorFlow Lite 文档以查找其他用户报告的类似问题。他们可能找到了可以帮助您解决问题的变通方法或解决方案。

调试模型执行:尝试调试模型执行以了解特定节点准备失败的原因。您可以添加打印语句或使用调试工具来检查中间结果并识别任何异常。

查阅 TensorFlow Lite 文档:请参阅官方 TensorFlow Lite 文档,了解故障排除提示、最佳实践和常见陷阱。该文档可能会提供有关解决您所面临的错误的见解。

© www.soinside.com 2019 - 2024. All rights reserved.