From 89645bbc4af714325e16acdd686b15e42a270c5d Mon Sep 17 00:00:00 2001 From: Jihye Sofia Seo <9078892+jihyeseo@users.noreply.github.com> Date: Tue, 11 Mar 2025 21:05:13 +0100 Subject: [PATCH 1/2] model.predict() takes tf.tensor, not np.array --- docs/tutorials/text_classification_rnn.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tutorials/text_classification_rnn.ipynb b/docs/tutorials/text_classification_rnn.ipynb index 61538bf5e..b68764372 100644 --- a/docs/tutorials/text_classification_rnn.ipynb +++ b/docs/tutorials/text_classification_rnn.ipynb @@ -449,7 +449,7 @@ "\n", "sample_text = ('The movie was cool. The animation and the graphics '\n", " 'were out of this world. I would recommend this movie.')\n", - "predictions = model.predict(np.array([sample_text]))\n", + "predictions = model.predict(tf.constant([sample_text]))\n", "print(predictions[0])" ] }, @@ -473,7 +473,7 @@ "# predict on a sample text with padding\n", "\n", "padding = \"the \" * 2000\n", - "predictions = model.predict(np.array([sample_text, padding]))\n", + "predictions = model.predict(tf.constant([sample_text, padding]))\n", "print(predictions[0])" ] }, From e7146fa0ceaf37d9359a74e6450ac1eb8d5c4b7a Mon Sep 17 00:00:00 2001 From: Jihye Sofia Seo <9078892+jihyeseo@users.noreply.github.com> Date: Tue, 11 Mar 2025 21:23:16 +0100 Subject: [PATCH 2/2] model.predict needs tf.constant --- docs/tutorials/text_classification_rnn.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tutorials/text_classification_rnn.ipynb b/docs/tutorials/text_classification_rnn.ipynb index b68764372..f2ee7c458 100644 --- a/docs/tutorials/text_classification_rnn.ipynb +++ b/docs/tutorials/text_classification_rnn.ipynb @@ -573,7 +573,7 @@ "source": [ "sample_text = ('The movie was cool. The animation and the graphics '\n", " 'were out of this world. I would recommend this movie.')\n", - "predictions = model.predict(np.array([sample_text]))" + "predictions = model.predict(tf.constant([sample_text]))" ] }, { @@ -675,7 +675,7 @@ "\n", "sample_text = ('The movie was not good. The animation and the graphics '\n", " 'were terrible. I would not recommend this movie.')\n", - "predictions = model.predict(np.array([sample_text]))\n", + "predictions = model.predict(tf.constant([sample_text]))\n", "print(predictions)" ] },