Deploying a Tensorflow model, getting an error

断了今生、忘了曾经 提交于 2019-12-24 17:17:22

问题


I am importing my trained Tensorflow model to android. I saved my input and output tensors, namely "input" and "y_", respectively.

This is my code in Android Studio:

 private static ActivityInference activityInferenceInstance;
    private TensorFlowInferenceInterface inferenceInterface;
    private static final String MODEL_FILE = "file:///android_asset/optimized_har.pb";
    private static final String INPUT_NODE = "input";
    private static final String[] OUTPUT_NODES = {"y_"};
    private static final String OUTPUT_NODE =  "y_";
    private static final long[] INPUT_SIZE = {1,1800};
    private static final int OUTPUT_SIZE = 6;
    private static AssetManager assetManager;

Then this function to return the probabilities at the output:

public float[] getActivityProb(float[] input_signal)
    {
        float[] result = new float[OUTPUT_SIZE];
        inferenceInterface.feed(INPUT_NODE,input_signal,INPUT_SIZE);
        inferenceInterface.run(OUTPUT_NODES);
        inferenceInterface.fetch(OUTPUT_NODE,result);
        return result;
    }

But my app crashes. I am sure the input and output dimensions are correct (or maybe not). But I checked that they are the same (both declared sized in Android Studio and the actual sizes in Python).

What is the possible of this error? Is there a better way to debug in Android Studio?

Also, I found the line which causes the error:

inferenceInterface.run(OUTPUT_NODES);

来源:https://stackoverflow.com/questions/48166439/deploying-a-tensorflow-model-getting-an-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!