尝试在Android上使用dl4j运行应用

时间:2016-08-15 10:34:40

标签: android android-studio deep-learning nd4j dl4j

我正在尝试使用深度学习库dl4j运行一个简单的应用程序。

我正在使用Android Studio并使用Gradle。

在运行时,我得到以下异常:

08-15 13:23:00.601 4868-4868/com.mi.dl E/AndroidRuntime: FATAL EXCEPTION: main
 Process: com.mi.dl, PID: 4868
 java.lang.IllegalStateException: Could not execute method for android:onClick
     at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
     at android.view.View.performClick(View.java)
     at android.view.View$PerformClick.run(View.java)
     at android.os.Handler.handleCallback(Handler.java)
     at android.os.Handler.dispatchMessage(Handler.java)
     at android.os.Looper.loop(Looper.java)
     at android.app.ActivityThread.main(ActivityThread.java)
     at java.lang.reflect.Method.invoke(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:372)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
  Caused by: java.lang.reflect.InvocationTargetException
     at java.lang.reflect.Method.invoke(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:372)
     at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
     at android.view.View.performClick(View.java) 
     at android.view.View$PerformClick.run(View.java) 
     at android.os.Handler.handleCallback(Handler.java) 
     at android.os.Handler.dispatchMessage(Handler.java) 
     at android.os.Looper.loop(Looper.java) 
     at android.app.ActivityThread.main(ActivityThread.java) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:372) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java) 
  Caused by: java.lang.ExceptionInInitializerError
     at org.deeplearning4j.nn.conf.NeuralNetConfiguration$Builder.seed(NeuralNetConfiguration.java:485)
     at com.mi.dl.MLPClassifierLinear.main(MLPClassifierLinear.java:79)
     at com.mi.dl.MyActivity.sendMessage(MyActivity.java:70)
     at java.lang.reflect.Method.invoke(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:372) 
     at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
     at android.view.View.performClick(View.java) 
     at android.view.View$PerformClick.run(View.java) 
     at android.os.Handler.handleCallback(Handler.java) 
     at android.os.Handler.dispatchMessage(Handler.java) 
     at android.os.Looper.loop(Looper.java) 
     at android.app.ActivityThread.main(ActivityThread.java) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:372) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java) 
  Caused by: java.lang.RuntimeException: org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException: Please ensure that you have an nd4j backend on your classpath. Please see: http://nd4j.org/getstarted.html
     at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:5151)
     at org.nd4j.linalg.factory.Nd4j.<clinit>(Nd4j.java:169)
     at org.deeplearning4j.nn.conf.NeuralNetConfiguration$Builder.seed(NeuralNetConfiguration.java:485) 
     at com.mi.dl.MLPClassifierLinear.main(MLPClassifierLinear.java:79) 
     at com.mi.dl.MyActivity.sendMessage(MyActivity.java:70) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:372) 
     at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
     at android.view.View.performClick(View.java) 
     at android.view.View$PerformClick.run(View.java) 
     at android.os.Handler.handleCallback(Handler.java) 
     at android.os.Handler.dispatchMessage(Handler.java) 
     at android.os.Looper.loop(Looper.java) 
     at android.app.ActivityThread.main(ActivityThread.java) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:372) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java) 
  Caused by: org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException: Please ensure that you have an nd4j backend on your classpath. Please see: http://nd4j.org/getstarted.html
     at org.nd4j.linalg.factory.Nd4jBackend.load(Nd4jBackend.java:178)
     at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:5148)
     at org.nd4j.linalg.factory.Nd4j.<clinit>(Nd4j.java:169) 
     at org.deeplearning4j.nn.conf.NeuralNetConfiguration$Builder.seed(NeuralNetConfiguration.java:485) 
     at com.mi.dl.MLPClassifierLinear.main(MLPClassifierLinear.java:79) 
     at com.mi.dl.MyActivity.sendMessage(MyActivity.java:70) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:372) 
     at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
     at android.view.View.performClick(View.java) 
     at android.view.View$PerformClick.run(View.java) 
     at android.os.Handler.handleCallback(Handler.java) 
     at android.os.Handler.dispatchMessage(Handler.java) 
     at android.os.Looper.loop(Looper.java) 
     at android.app.ActivityThread.main(ActivityThread.java) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:372) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java) 

在build.gradle文件中,我有以下依赖项:

compile 'org.nd4j:nd4j-native-platform:0.5.0'

但我也尝试了不同的后端。 dl4j团队表示还不支持Android,但我仍然想尝试使其工作,所以任何帮助都将受到赞赏。

0 个答案:

没有答案