python - 更改输入大小后 tflite.allocate_tensors() 失败

标签 python tensorflow tensorflow-lite

我正在尝试使用 tflite 模型对批处理进行推理。我使用以下代码:

interpreter = tf.lite.Interpreter(model_path=model_path)
input_details = interpreter.get_input_details()
interpreter.resize_tensor_input(input_details[0]["index"], [batch_size, 513, 513, 3])
interpreter.allocate_tensors()

代码崩溃并给出以下错误:

RuntimeError: tensorflow/lite/kernels/reshape.cc:58 num_input_elements != num_output_elements (1579014 != 789507)Node number 0 (RESHAPE) failed to prepare.

查看输出详细信息时,它的形状仍然是 [1, 513, 513, output_channels] 而不是 [batch_size, 513, 513, output_channels]我希望如此。

有什么想法吗?

最佳答案

这是一个已知错误 https://github.com/tensorflow/tensorflow/issues/16216 但目前没有补丁

关于python - 更改输入大小后 tflite.allocate_tensors() 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58217497/

相关文章:

python - 在 Azure 中使用 Python 调整 Excel 文件工作表列的大小

python - django-tenant-schema 为所有租户启用管理模块

python - 神经网络将所有内容分类为一类,在不平衡数据集上召回率=1

python - tensorflow static_rnn 错误 : input must be a sequence

python - 访问内部张量并向 tflite 模型添加新节点?

c++ - 如何将 TensorFlow Lite 构建为静态库并从单独的 (CMake) 项目链接到它?

python - 使用 Python 使用 Counter 重命名

Python:如何保存二叉树?

python - 在卡住图上使用 optimize_for_inference.py 后使用模型时出错

android - 在手机硬件上运行机器学习模型的可行性?