Training the model

Training a model takes several steps:

  1. Create two tensors with the real and fake labels. 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
  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("========================================")    print("Epoch is:", epoch)    print("Number of batches", int(X_train.shape[0] / batch_size))    gen_losses = []    dis_losses = []
  1. After that, calculate a ...

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.