【问题标题】:I am getting an resize_tensor_input failed to reshape error while using tflite使用 tflite 时出现 resize_tensor_input failed to reshape 错误
【发布时间】:2021-06-01 21:33:15
【问题描述】:

所以当我将 1 个输入传递给 tflite 模型时,我的模型和一切都正常工作。但对于批量推理,我需要为此传递 1000 个值,我正在调整张量输入大小,但出现以下错误:

tensorflow/lite/kernels/reshape.cc:69 num_input_elements != num_output_elements (100000 != 100)Node number 6 (RESHAPE) failed to invoke.

我使用的代码是:

interpreter.resize_tensor_input(input_details[0]['index'], [1, 1000, 100])
interpreter.allocate_tensors()
interpreter.set_tensor(input_details[0]['index'], input_data10)
interpreter.invoke()

在最后一行它给了我这个错误。

【问题讨论】:

  • 请确保您的 TFLite 模型可以处理任意批量大小。如果不是,请考虑使用输入批量大小的动态维度的 TF 模型再次进行 TFLite 转换。

标签: python tensorflow nlp tensorflow-lite bert-language-model


【解决方案1】:

我能够通过更改 np.expands 行来解决上述问题。

最初我使用的是:

input_data10 = np.expand_dims(input_text[1:1001], axis=0)

我改成了 input_data10 = np.expand_dims(input_text[1:1001], axis=1)

所以通过改变轴,它对我有用。

【讨论】:

    猜你喜欢
    • 2019-08-28
    • 1970-01-01
    • 2016-11-15
    • 1970-01-01
    • 2018-04-28
    • 2012-05-27
    • 1970-01-01
    • 1970-01-01
    • 2017-09-24
    相关资源
    最近更新 更多