Deep Learning with Python, Second Edition by François Chollet

Deep Learning with Python, Second Edition by François Chollet

Author:François Chollet [Chollet, François]
Language: eng
Format: epub, mobi
Publisher: Manning Publications Co.
Published: 2021-10-21T22:00:00+00:00


Figure 9.5 Displaying training and validation loss curves

You can see that we start overfitting midway, around epoch 25. Let’s reload our best performing model according to the validation loss, and demonstrate how to use it to predict a segmentation mask (see figure 9.6):

from tensorflow.keras.utils import array_to_img model = keras.models.load_model("oxford_segmentation.keras") i = 4 test_image = val_input_imgs[i] plt.axis("off") plt.imshow(array_to_img(test_image)) mask = model.predict(np.expand_dims(test_image, 0))[0] def display_mask(pred): ❶ mask = np.argmax(pred, axis=-1) mask *= 127 plt.axis("off") plt.imshow(mask) display_mask(mask)

❶ Utility to display a model’s prediction



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.