From the course: AI Workshop: Hands-on with GANs with Deep Convolutional Networks

Unlock this course with a free trial

Join today to access over 23,300 courses taught by industry experts.

Training a discriminator on bad fakes

Training a discriminator on bad fakes

We have the discriminator set up, now it's time to train it. The loss function that we'll use is the BCELoss or the Binary Cross Entropy loss. The BCELoss is a loss function that measures the difference between two probability distributions. In the context of binary classification, the two probability distributions are the predicted probabilities of the positive class and the negative class, as compared with the actual labels in the data. Next, we use the Adam optimizer to train the discriminator. The Adam optimizer has an adaptive learning rate that has been shown to work well for a GAN. We're only training the discriminator, but we are using the same optimizer and the same parameters like we would for the discriminator when it's part of a GAN. Next, let's set up a training loop to train our classification model. Now we'll train just for two epochs. You can see the for loop for epochs on line 1. We only train for two epochs because that's more than sufficient for the discriminator to…

Contents