Keras, how do I predict after I trained a model? Keras, how do I predict after I trained a model? python python

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)


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))