Decoder model

To specify the decoder model architecture, we will use the following code:

# Decoder
decoder <- encoder %>%
layer_conv_2d(filters = 4,
kernel_size = c(3,3),
activation = 'relu',
padding = 'same') %>%
layer_upsampling_2d(c(2,2)) %>%
layer_conv_2d(filters = 8,
kernel_size = c(3,3),
activation = 'relu',
padding = 'same') %>%
layer_upsampling_2d(c(2,2)) %>%
layer_conv_2d(filters = 1,
kernel_size = c(3,3),
activation = 'sigmoid',
padding = 'same') summary(decoder)
Output
Tensor("conv2d_25/Sigmoid:0", shape=(?, 28, 28, 1), dtype=float32)

Here, the encoder model has become the input for the decoder model. For the decoder network, we use a similar structure, with the first convolutional layer having 4 filters and the second convolutional layer having 8 filters. In addition, instead of pooling layers, we now use up-sampling layers. The first upsampling layer changes the height and width to 14 x 14 and the second upsampling layer restores it to the original height and width of 28 x 28. In the last layer, we make use of the sigmoid activation function, which ensures that the output values remain between 0 and 1.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset