Training a model takes several steps:
- 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
- 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 = []
- After that, calculate a ...