问题
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