16.03.2021 Views

Advanced Deep Learning with Keras

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 8

Implementing CVAE requires a few modifications in the code of the VAE. For the

CVAE, the VAE CNN implementation is used. Listing 8.2.1 highlights the changes

made to the original code of VAE for MNIST digits. The encoder input is now a

concatenation of original input image and its one-hot label. The decoder input is

now a combination of the latent space sampling and the one-hot label of the image it

should generate. The total number of parameters is 174, 437. The codes related to β

-VAE will be discussed in the next section of this chapter.

There are no changes in the loss function. However, the one-hot labels are supplied

during training, testing, and plotting of results. Figures 8.2.1 to 8.2.3 show us the

encoder, decoder, and CVAE models. The role of the conditioning label in the form

of a one-hot vector is indicated.

Figure 8.2.4: The latent vector mean values for the test dataset (CVAE CNN). The colorbar shows the

corresponding MNIST digit as a function of z. Color images can be found on the book GitHub repository:

https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras/tree/master/chapter8-vae.

[ 261 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!