9
$\begingroup$

The goal of the discriminator in a GAN is to distinguish between real inputs and inputs synthesized by the generator.

Suppose I train a GAN until the generator is good enough to fool the discriminator much of the time. Could I then use the discriminator as a classifier that tests whether an input belongs to a single class?

For instance, if I train StyleGAN to be able to synthesize photorealistic cats, could I use the trained discriminator to detect whether an image is a cat or not?

My thinking is that perhaps the discriminator would be more accurate than other classifier models because it has effectively trained on many, many more inputs thanks to the generator.

On the other hand, perhaps the discriminator is somehow worse because it has been trained overwhelmingly on cat-like images (assuming the generator has gotten pretty good), and hasn't seen a wide variety of negative examples. It is concerned less with "is this a cat?" than "what are the tell-tale signs of this being synthetic?"

$\endgroup$

1 Answer 1

3
$\begingroup$

Yes, we can use the Discriminator of the GAN to classify images. But we should make sure that the images produced by the Generator are real looking.

  • If you have trained your GAN on a large number of images and it is performing pretty well on the dataset then I insist you to treat the Discriminator model as a pretrained model ( like we do in transfer learning ) and again train this model on images which were not used to train the GAN earlier. Thus the model is fine tuned on the dataset on the GAN wasn't trained before.

  • Another similar way could be to only use the weights of the CNN layers and load them in our new model.

Suppose I train a GAN until the generator is good enough to fool the discriminator much of the time. Could I then use the discriminator as a classifier that tests whether an input belongs to a single class?

You should definitely try reusing a Discriminator from a GAN and share your results too :-).

$\endgroup$
2
  • $\begingroup$ I really would like to know if your answer was tested by @rgov and the results on that, as I am facing something similar. $\endgroup$ Commented Jul 29, 2021 at 9:34
  • 1
    $\begingroup$ I don't recall having tried using a Discriminator for classification, but I would follow the advice of training the model further on negative examples. $\endgroup$
    – rgov
    Commented Jul 30, 2021 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.