Skip to content

Commit 31925f7

Browse files
Lint the Transfer learning with TensorFlow Hub tutorial, change Keras preprocessing APIs to stable
PiperOrigin-RevId: 402839323
1 parent 5299b70 commit 31925f7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

site/en/tutorials/images/transfer_learning_with_hub.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@
6868
"\n",
6969
"This tutorial demonstrates how to:\n",
7070
"\n",
71-
"1. Use models from TensorFlow Hub with `tf.keras`\n",
72-
"1. Use an image classification model from TensorFlow Hub\n",
73-
"1. Do simple transfer learning to fine-tune a model for your own image classes"
71+
"1. Use models from TensorFlow Hub with `tf.keras`.\n",
72+
"1. Use an image classification model from TensorFlow Hub.\n",
73+
"1. Do simple transfer learning to fine-tune a model for your own image classes."
7474
]
7575
},
7676
{
@@ -333,7 +333,7 @@
333333
"id": "jFHdp18ccah7"
334334
},
335335
"source": [
336-
"First, load this data into the model using the image data off disk with `tf.keras.preprocessing.image_dataset_from_directory`, which will generate a `tf.data.Dataset`:"
336+
"First, load this data into the model using the image data off disk with `tf.keras.utils.image_dataset_from_directory`, which will generate a `tf.data.Dataset`:"
337337
]
338338
},
339339
{
@@ -348,7 +348,7 @@
348348
"img_height = 224\n",
349349
"img_width = 224\n",
350350
"\n",
351-
"train_ds = tf.keras.preprocessing.image_dataset_from_directory(\n",
351+
"train_ds = tf.keras.utils.image_dataset_from_directory(\n",
352352
" str(data_root),\n",
353353
" validation_split=0.2,\n",
354354
" subset=\"training\",\n",
@@ -394,7 +394,7 @@
394394
"id": "L0Btd0V3C8h4"
395395
},
396396
"source": [
397-
"Second, because TensorFlow Hub's convention for image models is to expect float inputs in the `[0, 1]` range, use the `tf.keras.layers.experimental.preprocessing.Rescaling` layer to achieve this."
397+
"Second, because TensorFlow Hub's convention for image models is to expect float inputs in the `[0, 1]` range, use the `tf.keras.layers.Rescaling` preprocessing layer to achieve this."
398398
]
399399
},
400400
{
@@ -403,7 +403,7 @@
403403
"id": "Rs6gfO-ApTQW"
404404
},
405405
"source": [
406-
"Note: You could also include the `tf.keras.layers.experimental.preprocessing.Rescaling` layer inside the model. Refer to the [Working with preprocessing layers](https://www.tensorflow.org/guide/keras/preprocessing_layers) guide for a discussion of the tradeoffs."
406+
"Note: You could also include the `tf.keras.layers.Rescaling` layer inside the model. Refer to the [Working with preprocessing layers](https://www.tensorflow.org/guide/keras/preprocessing_layers) guide for a discussion of the tradeoffs."
407407
]
408408
},
409409
{
@@ -414,7 +414,7 @@
414414
},
415415
"outputs": [],
416416
"source": [
417-
"normalization_layer = tf.keras.layers.experimental.preprocessing.Rescaling(1./255)\n",
417+
"normalization_layer = tf.keras.layers.Rescaling(1./255)\n",
418418
"train_ds = train_ds.map(lambda x, y: (normalization_layer(x), y)) # Where x—images, y—labels.\n",
419419
"val_ds = val_ds.map(lambda x, y: (normalization_layer(x), y)) # Where x—images, y—labels."
420420
]

0 commit comments

Comments
 (0)