I have a CNN model for text classification which uses a pre-trained embedding of the glove. I have frozen that graph optimized for inference and using it on the android studio. The problem is when I try to pass the weights into the model for inference. I have a JSON file with the key-value pairs between the words and the embedding which I use to create an input of embeddings from the text that the user types in. I can already get the embeddings from the JSON file but when I try to feed it into the graph for inference, it gives me the following error:
java.lang.IllegalArgumentException: indices[0,3891] = -2 is not in [0,
7459)
[[Node: EmbeddingLayer/embedding_lookup = Gather[Tindices=DT_INT32,
Tparams=DT_FLOAT, _class=["loc:@EmbeddingLayer/W"],
validate_indices=false,
_device="/job:localhost/replica:0/task:0/device:CPU:0"]
(EmbeddingLayer/W/read, EmbeddingLayer/Cast)]]
The Android code is in my GitHub https://github.com/sushiboo/testNN1
The main code that gives me problem is the Classify method:
private void classify(float[] input){
TFInference = new TensorFlowInferenceInterface(getAssets(), MODEL_FILE);
TFInference.feed(INPUT_NODE, input, 1, input.length);
TFInference.run(OUTPUT_NODES);
float[] resu = new float[2];
TFInference.fetch(OUTPUT_NODE, resu);
tvResult.setText("Programmer: " + Float.toString(resu[0]) + "\n Construction" + Float.toString(resu[1]));
Log.e("Result: ", Float.toString(resu[0]));
}
The problem is in the
TFInference.run(OUTPUT_NODES);
On the Error message, the number '7459' represents the input dimension of the embedding layer.
I am really confused as to what is happening here but I know that the indices[0,3891] = -2 plays some part in this.
The problem was with the model guys. I have fixed this one and now I am stuck on another error.