Using GANs to generate handwritten digits
To generate images of handwritten digits, we will leverage the same network as we learned about in the previous section. The strategy we will adopt is as follows:
- Import MNIST data.
- Initialize random noise.
- Define the generator model.
- Define the discriminator model.
- Train the two models alternately.
- Let the model train until the generator and discriminator losses are largely the same.
Let’s execute each of the preceding steps in the following code:
The following code is available as Handwritten_digit_generation_using_GAN.ipynb
in the Chapter12
folder in this book’s GitHub repository: https://bit.ly/mcvp-2e. The code is moderately lengthy. We strongly recommend you execute the notebook in GitHub to reproduce the results while you understand the steps to perform and the explanation of various code components from the text.
- Import the relevant packages...