java-如何向Tensorflow Android构建中添加 *** 作

java-如何向Tensorflow Android构建中添加 *** 作,第1张

概述我试图在Android上运行Tensorflow模型,因此我正在使用nightlynativebuildinhere,继Androiddemo之后,我已经成功运行了TensorflowAndroidlib,并使用以下代码加载了该模型.inferenceInterface=newTensorFlowInferenceInterface(getAssets(),MODEL_FILE);日志显示结果

我试图在Android上运行Tensorflow模型,因此我正在使用nightly native build in here,继@L_502_2@之后,我已经成功运行了Tensorflow AndroID lib,并使用以下代码加载了该模型.

inferenceInterface = new TensorFlowInferenceInterface(getAssets(), MODEL_file);

日志显示结果很好.

I/TensorFlowInferenceInterface: Successfully loaded TensorFlow native methods (RunStats error may be ignored)I/TensorFlowInferenceInterface: Model load took 1007ms, TensorFlow version: 1.2.0-rc0I/TensorFlowInferenceInterface: Successfully loaded model from 'file:///androID_asset/model.pb'

但是,当我完成所有输入节点的输入时

inferenceInterface.@R_502_6146@("input1", new int[]{1, 2, 3}, 1, 3);inferenceInterface.@R_502_6146@("input2", new int[]{3}, 1);inferenceInterface.@R_502_6146@("input3", new int[]{4}, 1);

然后调用run方法

inferenceInterface.run(new String[]{"output"});

Tensorflow被打破,说某些内核未注册

E/TensorFlowInferenceInterface: Failed to run TensorFlow inference with inputs:[input1, input2, input3], outputs:[output]D/AndroIDRuntime: Shutting down VME/AndroIDRuntime: FATAL EXCEPTION: mainProcess: ...jnitest, PID: 16357java.lang.RuntimeException: Unable to start activity ComponentInfo{...MainActivity}: java.lang.IllegalArgumentException: No OpKernel was registered to support Op 'LessEqual' with these attrs.  Registered devices: [cpu], Registered kernels:<no registered kernels>[[Node: .../LessEqual = LessEqual[T=DT_INT32](.../maximum_iterations, .../LessEqual/y)]]at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2665)at androID.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)at androID.app.ActivityThread.-wrap12(ActivityThread.java)at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)at androID.os.Handler.dispatchMessage(Handler.java:102)at androID.os.Looper.loop(Looper.java:154)at androID.app.ActivityThread.main(ActivityThread.java:6119)at java.lang.reflect.Method.invoke(Native Method)at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:776)Caused by: java.lang.IllegalArgumentException: No OpKernel was registered to support Op 'LessEqual' with these attrs.  Registered devices: [cpu], Registered kernels:<no registered kernels>[[Node: dynamic_seq2seq/decoder/decoder_1/LessEqual = LessEqual[T=DT_INT32](.../maximum_iterations, .../LessEqual/y)]]at org.tensorflow.Session.run(Native Method)at org.tensorflow.Session.access0(Session.java:48)at org.tensorflow.Session$Runner.runHelper(Session.java:295)at org.tensorflow.Session$Runner.run(Session.java:245)at org.tensorflow.contrib.androID.TensorFlowInferenceInterface.run(TensorFlowInferenceInterface.java:142)at org.tensorflow.contrib.androID.TensorFlowInferenceInterface.run(TensorFlowInferenceInterface.java:111)at ...jnitest.MainActivity.onCreate(MainActivity.java:52)at androID.app.Activity.performCreate(Activity.java:6679)at androID.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2618).. 9 more

我认为int32的“ LessEqual”应在Tensorflow中定义,但不能与Tensorflow AndroID lib一起构建.

因此,我的问题是如何在AndroID lib构建中包含更多内核或以其他任何方式解决此问题,我们将不胜感激.

解决方法:

我建议您阅读此免费电子书:Building Mobile Applications with TensorFlow

它包含有关移动设备上提供哪些 *** 作的部分. (第33页),其中说明了如何为那些默认情况下不用于移动版本的op内核将实现添加到版本中.

仅供参考,这本电子书由Pete Warden(GitHub,blog)撰写,他在Google工作,是TensorFlow的维护者之一.

总结

以上是内存溢出为你收集整理的java-如何向Tensorflow Android构建中添加 *** 作全部内容,希望文章能够帮你解决java-如何向Tensorflow Android构建中添加 *** 作所遇到的程序开发问题。

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

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

原文地址: http://outofmemory.cn/web/1091629.html

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

发表评论

登录后才能评论

评论列表(0条)

保存