From 16b0b0efc2967aa795dd6ac504e41e937ba35524 Mon Sep 17 00:00:00 2001 From: Guido Iaquinti Date: Sun, 10 Nov 2024 11:17:47 +0100 Subject: [PATCH] Update tf2_image_retraining.ipynb --- site/en/hub/tutorials/tf2_image_retraining.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/site/en/hub/tutorials/tf2_image_retraining.ipynb b/site/en/hub/tutorials/tf2_image_retraining.ipynb index 0266f4683c1..5d16389644a 100644 --- a/site/en/hub/tutorials/tf2_image_retraining.ipynb +++ b/site/en/hub/tutorials/tf2_image_retraining.ipynb @@ -221,7 +221,7 @@ " \"efficientnetv2-b0-21k-ft1k\": 224,\n", " \"efficientnetv2-b1-21k-ft1k\": 240,\n", " \"efficientnetv2-b2-21k-ft1k\": 260,\n", - " \"efficientnetv2-b3-21k-ft1k\": 300, \n", + " \"efficientnetv2-b3-21k-ft1k\": 300,\n", " \"efficientnet_b0\": 224,\n", " \"efficientnet_b1\": 240,\n", " \"efficientnet_b2\": 260,\n", @@ -363,8 +363,8 @@ "model = tf.keras.Sequential([\n", " # Explicitly define the input shape so the model can be properly\n", " # loaded by the TFLiteConverter\n", - " tf.keras.layers.InputLayer(input_shape=IMAGE_SIZE + (3,)),\n", - " hub.KerasLayer(model_handle, trainable=do_fine_tuning),\n", + " tf.keras.layers.InputLayer(shape=IMAGE_SIZE + (3,)),\n", + " tf.keras.layers.Lambda(lambda x: hub.KerasLayer(model_handle, trainable=do_fine_tuning)(x)),\n", " tf.keras.layers.Dropout(rate=0.2),\n", " tf.keras.layers.Dense(len(class_names),\n", " kernel_regularizer=tf.keras.regularizers.l2(0.0001))\n", @@ -391,7 +391,7 @@ "outputs": [], "source": [ "model.compile(\n", - " optimizer=tf.keras.optimizers.SGD(learning_rate=0.005, momentum=0.9), \n", + " optimizer=tf.keras.optimizers.SGD(learning_rate=0.005, momentum=0.9),\n", " loss=tf.keras.losses.CategoricalCrossentropy(from_logits=True, label_smoothing=0.1),\n", " metrics=['accuracy'])" ]