In the previous section, we defined the architecture of both generator and discriminator networks of the CGAN. Now, let's write the code for model training. In order to make it easy for you to reproduce the results, we will use MNIST as the training set to see how the CGAN performs in image generation. What we want to accomplish here is that, after the model is trained, it can generate the correct digit image we tell it to, with extensive variety.
Generating images from labels with the CGAN
One-stop model training API
First, let's create a new Model class that serves as a wrapper for different models and provides the one-stop training API. Create a new file named build_gan.py and import the necessary modules:
import...