【发布时间】: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