16.03.2021 Views

Advanced Deep Learning with Keras

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Autoencoders

Figure 3.3.1 shows actual validation data with both the corrupted and denoised test

MNIST digits. We're even able to see that humans will find it difficult to read the

corrupted MNIST digits. Figure 3.3.3 shows a certain level of robustness of DAE as

the level of noise is increased from σ = 0.5 to σ = 0.75 and . At σ = 0.75

, DAE is still able to recover the original images. However, at σ = 1.0 , a few digits

such as 4 and 5 in the second and third sets can no longer be recovered correctly.

Figure 3.3.3: Performance of denoising autoencoder as the noise level is increased

As seen in Listing 3.3.1, denoising-autoencoder-mnist-3.3.1.py shows

us a Denoising autoencoder:

from keras.layers import Dense, Input

from keras.layers import Conv2D, Flatten

from keras.layers import Reshape, Conv2DTranspose

from keras.models import Model

from keras import backend as K

from keras.datasets import mnist

import numpy as np

import matplotlib.pyplot as plt

from PIL import Image

np.random.seed(1337)

# load MNIST dataset

(x_train, _), (x_test, _) = mnist.load_data()

# reshape to (28, 28, 1) and normalize input images

[ 86 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!