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

前端 未结 6 2113
星月不相逢
星月不相逢 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:47

    Your can use your tokenizer and pad sequencing for a new piece of text. This is followed by model prediction. This will return the prediction as a numpy array plus the label itself.

    For example:

    new_complaint = ['Your service is not good']
    seq = tokenizer.texts_to_sequences(new_complaint)
    padded = pad_sequences(seq, maxlen=maxlen)
    pred = model.predict(padded)
    print(pred, labels[np.argmax(pred)])
    

提交回复
热议问题