9 Generative adversarial networks

 

This chapter covers

  • Working with generative models for fully connected and convolutional networks
  • Encoding concepts using latent vectors
  • Training two networks that cooperate
  • Manipulating generation using a conditional model
  • Manipulating generation with vector arithmetic

Most of what we have learned thus far has been a one-to-one mapping. Every input has one correct class/output. The dog can only be a “dog”; the sentence is only “positive” or “negative.” But we can also encounter one-to-many problems where there is more than one possible answer. For example, we may have the concept of “seven” as input and need to create several different kinds of pictures of the digit 7. Or, to colorize an old black-and-white photograph, we could produce multiple possible color images that were all equally valid. For one-to-many problems, we can use a generative adversarial network (GAN). Like other unsupervised models such as the autoencoder, we can use the representation a GAN learns as the input to other AI/ML algorithms and tasks. But the representation a GAN learns is often more meaningful, allowing us to manipulate our data in new ways. For example, we could take a picture of a frowning person and have the algorithm alter the image so the person is smiling.

9.1 Understanding generative adversarial networks

9.1.1  The loss computations

9.1.2  The GAN games

9.1.3  Implementing our first GAN

9.2 Mode collapse

9.3 Wasserstein GAN: Mitigating mode collapse

9.3.1  WGAN discriminator loss

9.3.2  WGAN generator loss

9.3.3  Implementing WGAN

9.4 Convolutional GAN

9.4.1  Designing a convolutional generator

9.4.2  Designing a convolutional discriminator

9.5 Conditional GAN

9.5.1  Implementing a conditional GAN

9.5.2  Training a conditional GAN

9.5.3  Controlling the generation with conditional GANs

9.6 Walking the latent space of GANs

9.6.1  Getting models from the Hub

9.6.2  Interpolating GAN output

9.6.3  Labeling latent dimensions

9.7 Ethics in deep learning