0
私はTensorflowを学習しており、チュートリアルの後でAndroid搭載アプリケーションで実行するカスタムモデルを作成できましたが、問題があります。AndroidのTensorflowエラー
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));
}
アプリはinferenceInterface.run(new String[]{"output"})
メソッドを実行しようとすると、私はエラーを得た:私は次のコードを持って、私ができたので、
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)]]
私は私が作成したモデルを信じないの問題がありますそれを肯定的な結果を持つPythonコードで使用する。
はい、問題はモデルが配列ではないと予想していたことでした。私はモデルをop 'tf.reshape'に変更しました。そうすれば、配列の入力を設定することができ、モデルは後でそれを行列に変更します –