Keras, how do I predict after I trained a model?
model.predict()
expects the first parameter to be a numpy array. You supply a list, which does not have the shape
attribute a numpy array has.
Otherwise your code looks fine, except that you are doing nothing with the prediction. Make sure you store it in a variable, for example like this:
prediction = model.predict(np.array(tk.texts_to_sequences(text)))print(prediction)
model.predict_classes(<numpy_array>)
Sample https://gist.github.com/alexcpn/0683bb940cae510cf84d5976c1652abd
You must use the same Tokenizer you used to build your model!
Else this will give different vector to each word.
Then, I am using:
phrase = "not good"tokens = myTokenizer.texts_to_matrix([phrase])model.predict(np.array(tokens))