Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

machine learning

What is a Conditional GAN (cGAN)?

Nouman Abbasi

Conditional generative adversarial network, or cGAN for short, is a type of GAN that involves the conditional generation of images by a generator model.

A generative adversarial network (GAN) is a Machine Learning framework used to train generative models. Read more about GANs here.

GANs rely on a generator that learns to generate new images, and a discriminator that learns to distinguish synthetic images from real images.

In cGANs, a conditional setting is applied, meaning that both the generator and discriminator are conditioned on some sort of auxiliary information (such as class labels or data) from other modalities. As a result, the ideal model can learn multi-modal mapping from inputs to outputs by being fed with different contextual information.


By providing additional information, we get two benefits:

  1. Convergence will be faster. Even the random distribution that the fake images follow will have some pattern.
  2. You can control the output of the generator at test time by giving the label for the image you want to generate.


If that was confusing, consider this example:

Suppose you train a GAN on hand-written digits (MNIST imagesA large database of handwritten digits commonly used for training various image processing systems.). You normally cannot control what specific images the generator will produce. In other words, there is no way you can request a particular digit image from the generator.

This is where the cGANs come in as we can add an additional input layer of one-hot-encoded image labels. This additional layer guides the generator in terms of which image to produce.

The input to the additional layer can be a feature vector derived either an image that encodes the class or a set of specific characteristics we expect from the image.

cGANs are not strictly unsupervised learning algorithms because they require labeled data as input to the additional layer.

Conditional GAN


  • Image-to-image translation
  • Text-to-image synthesis
  • Video generation
  • Convolutional face generation


machine learning


Nouman Abbasi
Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring