Training the discriminator network

The steps given in this section show how to train the discriminator network. This is a continuation of the last series of steps:

  1. Generate fake high-resolution images using the generator network:
generated_high_resolution_images = 
generator.predict(low_resolution_images)
  1. Create a batch of real labels and fake labels:
    real_labels = np.ones((batch_size, 16, 16, 1))
fake_labels = np.zeros((batch_size, 16, 16, 1))
  1. Train the discriminator network on real images and real labels:
d_loss_real = discriminator.train_on_batch(high_resolution_images, 
real_labels)
  1. Train the discriminator on generated images and fake labels:
d_loss_fake = discriminator.train_on_batch(generated_high_resolution_images, fake_labels)
  1. Finally, calculate the total discriminator loss:
    d_loss = 0.5 * np.add(d_loss_real, d_loss_fake)

We have now added the code to train the discriminator network. Next, add the code to train the adversarial model, which trains the generator network.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.31.163