I am learning Tensorflow and following a tutorial I was able to make a custom model to run it in an Android App but I am having problems with it. I have the following code:
public void testModel(Context ctx) {
String model_file = "file:///android_asset/model_graph.pb";
int[] result = new int[2];
float[] input = new float[]{0.0F, 1.0F, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 1.0F, 0.0F, 1.0F, 0.0F, 1.0F, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0F, 1.0F, 0.0F, 1.0F, 0.0F, 1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F, 1.0F, 0.0F, 1.0F, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 1.0F, 0.0F, 1.0F, 1.0F, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 1.0F, 0.0F, 1.0F, 0.0F, 1.0F, 0.0F};
TensorFlowInferenceInterface inferenceInterface;
inferenceInterface = new TensorFlowInferenceInterface(ctx.getAssets(), model_file);
inferenceInterface.feed("input", input, 68);
inferenceInterface.run(new String[]{"output"});
inferenceInterface.fetch("output", result);
Log.v(TAG, Arrays.toString(result));
}
I got an error when the app try to run the inferenceInterface.run(new String[]{"output"}) method:
java.lang.IllegalArgumentException: In[0] is not a matrix
[[Node: MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_input_0_0, W1)]]
I don't believe the model I created is the problem because I was able to use it in a Python code with positive result.