Learn Before
Autoencoder Decoder Code
__The decoder is a mirror image of the encoder, except instead of convolutional layers, we use convolutional transpose layers, as shown in the code. __
(Actually we don't have to write decoder as a mirror image of the encoder. But it is inevitable for the decoder to have exactly same size for the output image as we the input size of the encoder)
#<1> define the input to the decoder (the point in the latent space). decoder_input = Input(shape=(self.z_dim,), name='decoder_input') x = Dense(np.prod(shape_before_flattening))(decoder_input) x = Reshape(shape_before_flattening)(x) for i in range(self.n_layers_decoder): conv_t_layer = Conv2DTranspose( filters = self.decoder_conv_t_filters[i] , kernel_size = self.decoder_conv_t_kernel_size[i] , strides = self.decoder_conv_t_strides[i] , padding = 'same' , name = 'decoder_conv_t_' + str(i) ) #<2>Stack convolutional transpose layers on top of each other. x = conv_t_layer(x) if i < self.n_layers_decoder - 1: x = LeakyReLU()(x) if self.use_batch_norm: x = BatchNormalization()(x) if self.use_dropout: x = Dropout(rate = 0.25)(x) else: x = Activation('sigmoid')(x) decoder_output = x #<3>The Keras model that defines the decoder—a model that takes a point in t #the latent space and decodes it into the original image domain. self.decoder = Model(decoder_input, decoder_output)```
0
1
Tags
Data Science
Related
What does the Autoencoder try to do ?
Putting it all together - AutoEncoder Code
Problems With Autoencoders
Reference to the AutoEncoder Code
Autoencoder Decoder Code
Autoencoder Encoder Sample Code
Denoising Autoencoders
Sparse Autoencoders
Undercomplete Autoencoders
Overcomplete Autoencoders
Regularizing Autoencoder
Autoencoder Depth
Learning Manifolds Using Autoencoder
Drawing Samples From Autoencoders
Autoencoder Decoder Code
Autoencoder Encoder Sample Code