Sorry, I feel a little bit stupid, but I can't help me other ways.
I'm playing with the reuters-example and it run fine. So I do have now a trained model. Thats where all examples end as far as I can see.
I read about to save the model. So I could load it later to use again.
But, how do I use these models to predict a new text? Do I use models.predict() ?
Do I have to prepare this text in a special way? I tried it with
import keras.preprocessing.text
text = np.array(['this is just some random, stupid text'])
print(text.shape)
tk = keras.preprocessing.text.Tokenizer(nb_words=2000, filters=keras.preprocessing.text.base_filter(), lower=True, split=" ")
tk.fit_on_texts(text)
pred = tk.texts_to_sequences(text)
print(pred)
model.predict(pred)
But I always get
(1L,)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-80-dbddb6dc0010> in <module>()
5 tk.fit_on_texts(text)
6 pred = tk.texts_to_sequences(text)
----> 7 print(pred.shape)
8 print(pred)
9
AttributeError: 'list' object has no attribute 'shape'
Have you any reccomondations, how to start or follow up?
Thank you.
Kind regards Ben
Aucun commentaire:
Enregistrer un commentaire