输出维度问题运行TensorFlow图表Android

输出维度问题运行TensorFlow图表Android,第1张

概述我已将张量流图输出到 Android中,我正在尝试运行它.我从CSV输入了一些数据,它似乎工作正常,但最终节点的输出是批量x时间x feature_dims,我能看到的唯一输出函数是单个数组. 我收到的错误是: 08-28 10:01:44.162 10602-10602/com.example.rob.android_kds E/TensorFlowInferenceInterface: Fai 我已将张量流图输出到 Android中,我正在尝试运行它.我从CSV输入了一些数据,它似乎工作正常,但最终节点的输出是批量x时间x feature_dims,我能看到的唯一输出函数是单个数组.

我收到的错误是:

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: readOutput08-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.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)

这是我的代码段:

// 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();

任何帮助赞赏(完整代码在这里https://github.com/mlrobsmt/kds2Droid),谢谢

解决方法 不确定,但根据你的错误信息说输入形状轴0必须等于3,得到形状[1]和代码的这一行定义你的输入数组float [] arr = new float [18252];我希望您的例外原因是您的输入没有合适的形状.事实上,我认为您的输入应该是3D数组而不是矢量. 总结

以上是内存溢出为你收集整理的输出维度问题运行TensorFlow图表Android全部内容,希望文章能够帮你解决输出维度问题运行TensorFlow图表Android所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1124035.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存