From d0be1b2ee88ad842c6a77aebd8d4be4485302d9f Mon Sep 17 00:00:00 2001 From: Nicolas Oliver Date: Wed, 4 Sep 2024 21:40:36 +0000 Subject: [PATCH] Fix Text classification with TensorFlow Hub * install tf_keras * use tf_keras model and layers --- .../tutorials/keras/text_classification_with_hub.ipynb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/site/en/tutorials/keras/text_classification_with_hub.ipynb b/site/en/tutorials/keras/text_classification_with_hub.ipynb index b43e59e35fc..454495c0ac0 100644 --- a/site/en/tutorials/keras/text_classification_with_hub.ipynb +++ b/site/en/tutorials/keras/text_classification_with_hub.ipynb @@ -121,7 +121,8 @@ "outputs": [], "source": [ "!pip install tensorflow-hub\n", - "!pip install tensorflow-datasets" + "!pip install tensorflow-datasets\n", + "!pip install tf_keras" ] }, { @@ -138,6 +139,7 @@ "import tensorflow as tf\n", "import tensorflow_hub as hub\n", "import tensorflow_datasets as tfds\n", + "import tf_keras\n", "\n", "print(\"Version: \", tf.__version__)\n", "print(\"Eager mode: \", tf.executing_eagerly())\n", @@ -290,10 +292,10 @@ }, "outputs": [], "source": [ - "model = tf.keras.Sequential()\n", + "model = tf_keras.Sequential()\n", "model.add(hub_layer)\n", - "model.add(tf.keras.layers.Dense(16, activation='relu'))\n", - "model.add(tf.keras.layers.Dense(1))\n", + "model.add(tf_keras.layers.Dense(16, activation='relu'))\n", + "model.add(tf_keras.layers.Dense(1))\n", "\n", "model.summary()" ]