As you learned in the first section of this chapter, denoising autoencoders can be used to train the models such that they are able to remove the noise from the images input to the trained model:
- For the purpose of this example, we write the following helper function to help us add noise to the images:
def add_noise(X):
return X + 0.5 * np.random.randn(X.shape[0],X.shape[1])
- Then we add noise to test images and store it in a separate list:
test_images_noisy = add_noise(test_images)
We will use these test images to test the output from our denoising model examples.
- We build and train the denoising autoencoder as in the preceding example, with one difference: While training, we input the noisy images to the input layer and we check the reconstruction and denoising error with the non-noisy images, as the following code shows:
X_batch,...