我在為 Android Java 的 TFLITE 解釋器準(zhǔn)備輸出時(shí)遇到錯(cuò)誤。該模型有 1 個(gè)輸入和 4 個(gè)輸出。interpreter.runForMultipleInputsOutputs(input, map_of_indices_to_outputs);E/Run multiple: Internal error: Unexpected failure when preparing tensor allocations: tensorflow/lite/kernels/tile.cc:53 num_dimensions != num_multipliers (1 != 2)Node number 4 (TILE) failed to prepare.輸出要求是 4 個(gè)浮點(diǎn)數(shù)組的列表:[ [1x1],[1x2], [1x2], [1x2] ]python 中預(yù)測(cè)的輸出是:In [56] output = model.predict(new_observation_scaled)Out[56]: [array([[0.]], dtype=float32), array([[137.66626, 335.7148 ]], dtype=float32), array([[0.16666616, 0.40643442]], dtype=float32), array([[9.9915421e-01, 8.4577635e-04]], dtype=float32)]所以我用JAVA準(zhǔn)備了一個(gè)對(duì)象列表:float [][] output0 = new float [1][1];float [][] output1 = new float [1][2];float [][] output2 = new float [1][2];float [][] output3 = new float [1][2];Object[] outputs = {output0,output1,output2,output3};Map<Integer, Object> map_of_indices_to_outputs = new HashMap<>();map_of_indices_to_outputs.put(0, output0);map_of_indices_to_outputs.put(1, output1);map_of_indices_to_outputs.put(2, output2);map_of_indices_to_outputs.put(3, output3);你能幫我找出錯(cuò)誤嗎?
1 回答

繁星淼淼
TA貢獻(xiàn)1775條經(jīng)驗(yàn) 獲得超11個(gè)贊
我得到了問題的解決方案:
以同樣的方式,輸出需要一個(gè)列表,輸入也需要一個(gè)列表:
Object[] outputs = {output0,output1,output2,output3};
Object[] inputs = {input};
interpreter.runForMultipleInputsOutputs(inputs, map_of_indices_to_outputs);
添加回答
舉報(bào)
0/150
提交
取消