|
68 | 68 | "\n",
|
69 | 69 | "This tutorial demonstrates how to:\n",
|
70 | 70 | "\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." |
74 | 74 | ]
|
75 | 75 | },
|
76 | 76 | {
|
|
333 | 333 | "id": "jFHdp18ccah7"
|
334 | 334 | },
|
335 | 335 | "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`:" |
337 | 337 | ]
|
338 | 338 | },
|
339 | 339 | {
|
|
348 | 348 | "img_height = 224\n",
|
349 | 349 | "img_width = 224\n",
|
350 | 350 | "\n",
|
351 |
| - "train_ds = tf.keras.preprocessing.image_dataset_from_directory(\n", |
| 351 | + "train_ds = tf.keras.utils.image_dataset_from_directory(\n", |
352 | 352 | " str(data_root),\n",
|
353 | 353 | " validation_split=0.2,\n",
|
354 | 354 | " subset=\"training\",\n",
|
|
394 | 394 | "id": "L0Btd0V3C8h4"
|
395 | 395 | },
|
396 | 396 | "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." |
398 | 398 | ]
|
399 | 399 | },
|
400 | 400 | {
|
|
403 | 403 | "id": "Rs6gfO-ApTQW"
|
404 | 404 | },
|
405 | 405 | "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." |
407 | 407 | ]
|
408 | 408 | },
|
409 | 409 | {
|
|
414 | 414 | },
|
415 | 415 | "outputs": [],
|
416 | 416 | "source": [
|
417 |
| - "normalization_layer = tf.keras.layers.experimental.preprocessing.Rescaling(1./255)\n", |
| 417 | + "normalization_layer = tf.keras.layers.Rescaling(1./255)\n", |
418 | 418 | "train_ds = train_ds.map(lambda x, y: (normalization_layer(x), y)) # Where x—images, y—labels.\n",
|
419 | 419 | "val_ds = val_ds.map(lambda x, y: (normalization_layer(x), y)) # Where x—images, y—labels."
|
420 | 420 | ]
|
|
0 commit comments