Training the cGAN

This is the first step of the training process. In this step, we train the generator and the discriminator networks. Perform the following steps:

  1. Start by specifying the parameters required for the training:
# Define hyperparametersdata_dir = "/path/to/dataset/directory/"wiki_dir = os.path.join(data_dir, "wiki_crop")epochs = 500batch_size = 128image_shape = (64, 64, 3)z_shape = 100TRAIN_GAN = TrueTRAIN_ENCODER = FalseTRAIN_GAN_WITH_FR = Falsefr_image_shape = (192, 192, 3)
  1. Next, define the optimizers for the training. We will use the Adam optimizer, which is available in Keras. Initialize the optimizers, as shown in the following code:
# Define optimizers# Optimizer for the discriminator networkdis_optimizer = Adam(

Get Generative Adversarial Networks Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.