How it works...

In step 1, we initialized a variable, encoded_dim, to set the dimensionality of the encoded representation of the input. Since we implemented an under-complete autoencoder, which compresses input feature space to a lower dimension, encoded_dim is less than the input dimension. Next, we defined the input layer of the autoencoder, which took an array of a size of 784 as input.

In the next step, we built an autoencoder model. We first defined an encoder and a decoder network and then combined them to create an autoencoder. Note that the number of units in the encoder layer is equal to encoded_dim because we wanted to compress the input feature space of 784 dimensions to 32 dimensions. The number of units in the decoder layer ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.