Conditional GANs
Feeding a label to both the generator and discriminator turns an ordinary GAN, which produces an unpredictable sample from the whole data distribution, into one that generates exactly the category you ask for.
Prerequisites: The GAN Minimax Objective
An ordinary GAN's generator takes random noise and produces some sample from the data distribution — you don't get to choose which category it lands on. Train one on a mix of cats and dogs and each call to might give either, with no control. A conditional GAN (cGAN) fixes this the same way a conditional VAE does: hand a label to both networks, so the generator learns to produce samples of that label and the discriminator learns to check both realism and whether the sample actually matches the label it was told to be.
The analogy: a custom order versus a grab bag
An ordinary GAN is a grab bag: reach in, get a random item from whatever mix was in there. A conditional GAN is a custom order: you specify "dog" and the vendor (generator) produces a dog, while a quality inspector (discriminator) checks not only "is this a real-looking animal" but also "did they actually deliver a dog, not a cat wearing a dog costume." Both checks matter — a perfectly realistic cat delivered against a dog order should still fail inspection.
The objective, with threaded through
The cGAN objective is the ordinary minimax objective with conditioning every term:
In words: the discriminator now scores "is both real and consistent with label ," and the generator, given and , tries to produce something that clears that bar. Practically, is concatenated into the generator's input noise and into whatever layer of the discriminator sees the sample, so both networks have access to the same label at every step.
Worked example 1: a discriminator that checks both things
Suppose the discriminator's score decomposes (illustratively) as , both in . A real, correctly-labeled dog photo: , , giving — high, as it should be. A realistic dog photo mislabeled as "cat": (still looks real) but (clearly not a cat), giving — correctly rejected, even though the image itself is perfectly photorealistic. An unconditional GAN's discriminator has no term at all and would have accepted this sample.
Worked example 2: sampling multiple classes from one model
Train a cGAN on ten digit classes with one-hot. To generate five 6's and five 9's from a single trained generator: draw ten noise vectors , pair the first five with one-hot(6) and the rest with one-hot(9), and decode each pair through the same . Contrast with training ten separate unconditional GANs, one per digit — a cGAN gets all ten classes' worth of shared structure (stroke style, thickness) baked into one model, so a "6" and a "9" sampled with the same underlying tend to share the same handwriting style, something ten independent models could never guarantee.
Change the strategy above and notice each preset is really the same payoff machinery conditioned on a different choice — the same relationship a cGAN has to its label: one shared network, steered by which condition you hand it.
A conditional GAN threads a label through both generator and discriminator, so the discriminator rejects samples that are realistic but mismatched to their label, and the generator learns to produce a chosen category on demand — turning an uncontrollable grab-bag sampler into a steerable one.
What this means in practice
Conditional GANs underlie most controllable image generation and are the natural template for finance use cases like generating synthetic order flow conditioned on a venue, or synthetic return paths conditioned on a volatility regime — the same generator can be asked for "calm regime" or "stressed regime" samples rather than needing a separate model per regime.
The common mistake is conditioning only the generator and leaving the discriminator unconditional — it still learns to reject unrealistic samples, but has no way to penalize a realistic sample delivered under the wrong label, so the generator is never actually pushed to respect and can quietly ignore it, the GAN analogue of posterior collapse.
Related concepts
Practice in interviews
Further reading
- Mirza & Osindero, Conditional Generative Adversarial Nets (2014)