How to do it...

We will now move on to build our deep autoencoder. A deep autoencoder has multiple layers in its encoder and decoder network:

  1. Let's build an autoencoder:
encoded_dim = 32# input layerinput_img <- layer_input(shape = c(784),name = "input")# encoderencoded = input_img %>%    layer_dense(128, activation='relu',name = "encoder_1") %>%    layer_dense(64, activation='relu',name = "encoder_2") %>%    layer_dense(encoded_dim, activation='relu',name = "encoder_3")# decoderdecoded = encoded %>%    layer_dense(64, activation='relu',name = "decoder_1")%>%    layer_dense(128, activation='relu',name = "decoder_2")%>%    layer_dense(784,activation = 'sigmoid',name = "decoder_3")# autoencoderautoencoder = keras_model(input_img, decoded)summary(autoencoder) ...

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.