Let's go through this process step by step.
- Start by adding TensorBoard to store losses:
tensorboard = TensorBoard(log_dir="logs/".format(time.time()))tensorboard.set_model(stage2_gen)tensorboard.set_model(stage2_dis)
- Then, create two tensors with the labels real and fake. These will be required during the training of the generator and the discriminator. Use label smoothing, which is covered in Chapter 1, Introduction to Generative Adversarial Networks:
real_labels = np.ones((batch_size, 1), dtype=float) * 0.9fake_labels = np.zeros((batch_size, 1), dtype=float) * 0.1
- Next, create a for loop, which should run for the number of times specified by the number of epochs, as follows:
for epoch in range(epochs): print(