Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to interpret the discriminator's loss and the generator's loss in Generative Adversarial Nets?

Tags:

I am reading people's implementation of DCGAN, especially this one in tensorflow.

In that implementation, the author draws the losses of the discriminator and of the generator, which is shown below (images come from https://github.com/carpedm20/DCGAN-tensorflow):

enter image description here

enter image description here

Both the losses of the discriminator and of the generator don't seem to follow any pattern. Unlike general neural networks, whose loss decreases along with the increase of training iteration. How to interpret the loss when training GANs?

like image 829
shapeare Avatar asked Mar 09 '17 08:03

shapeare


People also ask

What is the loss of generator in GAN?

A GAN can have two loss functions: one for generator training and one for discriminator training.

What is adversarial loss in GAN?

The adversarial loss is defined by a continuously trained discriminator network. It is a binary classifier that differentiates between ground truth data and generated data predicted by the generative network (Fig. 2). Source publication. DARN: a Deep Adversial Residual Network for Intrinsic Image Decomposition.

Which is the most common loss function used in training of GANs?

Many loss functions have been developed and evaluated in an effort to improve the stability of training GAN models. The most common is the non-saturating loss, generally, and the Least Squares and Wasserstein loss in larger and more recent GAN models.

How do you know which mode is collapse in GAN?

Mode collapse is when the GAN produces a small variety of images with many duplicates (modes). This happens when the generator is unable to learn a rich feature representation because it learns to associate similar outputs to multiple different inputs. To check for mode collapse, inspect the generated images.


Video Answer


1 Answers

Unfortunately, like you've said for GANs the losses are very non-intuitive. Mostly it happens down to the fact that generator and discriminator are competing against each other, hence improvement on the one means the higher loss on the other, until this other learns better on the received loss, which screws up its competitor, etc.

Now one thing that should happen often enough (depending on your data and initialisation) is that both discriminator and generator losses are converging to some permanent numbers, like this: (it's ok for loss to bounce around a bit - it's just the evidence of the model trying to improve itself)

This loss convergence would normally signify that the GAN model found some optimum, where it can't improve more, which also should mean that it has learned well enough. (Also note, that the numbers themselves usually aren't very informative.)

Here are a few side notes, that I hope would be of help:

  • if loss haven't converged very well, it doesn't necessarily mean that the model hasn't learned anything - check the generated examples, sometimes they come out good enough. Alternatively, can try changing learning rate and other parameters.
  • if the model converged well, still check the generated examples - sometimes the generator finds one/few examples that discriminator can't distinguish from the genuine data. The trouble is it always gives out these few, not creating anything new, this is called mode collapse. Usually introducing some diversity to your data helps.
  • as vanilla GANs are rather unstable, I'd suggest to use some version of the DCGAN models, as they contain some features like convolutional layers and batch normalisation, that are supposed to help with the stability of the convergence. (the picture above is a result of the DCGAN rather than vanilla GAN)
  • This is some common sense but still: like with most neural net structures tweaking the model, i.e. changing its parameters or/and architecture to fit your certain needs/data can improve the model or screw it.
like image 108
Massyanya Avatar answered Oct 04 '22 20:10

Massyanya