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:
- Import the relevant packages and define the device:
!pip install -q torch_snippets
from torch_snippets import *
device...