How it works...

In step 1, we generated a random Gaussian noise with a mean of 0.5 and a standard deviation of 0.5. The shape of the noise data has to be similar to the shape of the data to which we add it. 

We want our pixel values to be in the range of 0 and 1, but after introducing noise in the input data, the pixel values might change and no longer be in the required range. To avoid this, in step 2, we clipped the values in the corrupted input data within a range of 0 and 1. Clipping converted all of the negative values into 0 and values greater than one into 1, while the rest of the values remain as is. In step 3, we created the encoder part of the autoencoder model. In our example, the encoder model was a stack of two convolutional ...

Get Deep Learning with R Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.