In this section, we will implement different parts of training a GAN architecture, based on the DCGAN paper I mentioned in the preceding information box. Some of the important parts of training a DCGAN include:
- A generator network, which maps a latent vector (list of numbers) of some fixed dimension to images of some shape. In our implementation, the shape is (3, 64, 64).
- A discriminator network, which takes as input an image generated by the generator or from the actual dataset, and maps to that a score estimating if the input image is real or fake.
- Defining loss functions for generator and discriminator.
- Defining an optimizer.
- Training a GAN.
Let's explore each of these sections in detail. The implementation is based on the code, which is available in the PyTorch examples at: