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

前端 未结 6 2111
星月不相逢
星月不相逢 2020-12-02 08:19

I\'m playing with the reuters-example dataset and it runs fine (my model is trained). I read about how to save a model, so I could load it later to use again. But how do I

6条回答
  •  悲&欢浪女
    2020-12-02 08:44

    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)
    

提交回复
热议问题