Output Size Launch Problem TensorFlow graph Android

I output my tenorflow graph in Android and I am trying to run it. I am inputting some data from CSV and it seems to be working fine, but the output of the final node is batch time x feature_dims, and the only output functions that I see are single arrays.

Received error:

08-28 10:01:44.162 10602-10602/com.example.rob.android_kds E/TensorFlowInferenceInterface: Failed to run TensorFlow inference with inputs:[the_input], outputs:[output_node0]
08-28 10:01:44.162 10602-10602/com.example.rob.android_kds E/TensorFlowInferenceInterface: Inference exception: java.lang.IllegalArgumentException: Input shape axis 0 must equal 3, got shape [1]
                                                                                               [[Node: fc1/unstack = Unpack[T=DT_INT32, axis=0, num=3, _device="/job:localhost/replica:0/task:0/cpu:0"](fc1/Shape)]]
08-28 10:01:44.162 10602-10602/com.example.rob.android_kds I/System.out: readOutput
08-28 10:01:44.172 10602-10602/com.example.rob.android_kds E/AndroidRuntime: FATAL EXCEPTION: main
                                                                            Process: com.example.rob.android_kds, PID: 10602
                                                                            java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
                                                                                at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
                                                                                at java.util.ArrayList.get(ArrayList.java:308)
                                                                                at org.tensorflow.contrib.android.TensorFlowInferenceInterface.getTensor(TensorFlowInferenceInterface.java:486)
                                                                                at org.tensorflow.contrib.android.TensorFlowInferenceInterface.readNodeIntoFloatBuffer(TensorFlowInferenceInterface.java:332)
                                                                                at org.tensorflow.contrib.android.TensorFlowInferenceInterface.readNodeFloat(TensorFlowInferenceInterface.java:287)
                                                                                at com.example.rob.android_kds.MainActivity$1.onClick(MainActivity.java:171)
                                                                                at android.view.View.performClick(View.java:5697)
                                                                                at android.view.View$PerformClick.run(View.java:22526)
                                                                                at android.os.Handler.handleCallback(Handler.java:739)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                at android.os.Looper.loop(Looper.java:158)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:7225)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

This is my code segment:

               // Copy the input data into TensorFlow.
               System.out.println("inputNode");
               Trace.beginSection("fillNodeFloat");
               //input is 3x234x26 and array is a unravelled arr = 18252
               tensorflow.fillNodeFloat(
                       "the_input", new int[]{3 * 234 * 26}, arr);
               Trace.endSection();

               // Run the inference call.
               System.out.println("runInference");
               Trace.beginSection("runInference");
               String outputNode = "output_node0";
               String[] outputNodes = {outputNode};
               tensorflow.runInference(outputNodes);
               Trace.endSection();

               // Copy the output Tensor back into the output array.
               System.out.println("readOutput");
               Trace.beginSection("readNodeFloat");
               //output should be batchxtimex29 (3 x 234 x 29) = 20358 flattened array
               float[] output=new float[20358];

               tensorflow.readNodeFloat(outputNode, output); // ERROR HERE
               Trace.endSection();

Any help appreciated (full code here https://github.com/mlrobsmt/kds2Droid ), thanks

+4
source share
2 answers

, Input shape axis 0 must equal 3, got shape [1] , float[] arr=new float[18252];, , , . , , 3D- .

0

, . Android 1D. , 1D-.

0

Source: https://habr.com/ru/post/1684597/


All Articles