⚡ A GAN (Generative Adversarial Network) is two neural networks in competition — a generator that creates fake data and a discriminator that tries to spot fakes. Their competition drives both to improve until the generator produces outputs indistinguishable from real data. GANs powered the first wave of AI-generated faces, deepfakes, and synthetic images before diffusion models largely took over.
Category: Generative AI · Difficulty: Intermediate · Last updated: 15 May 2026 · 5 min read
GAN — How Two Competing Neural Networks Learned to Create Photorealistic Fake Data
What is Generative Adversarial Network?
Ian Goodfellow invented GANs in 2014, reportedly sketching the idea on a napkin in a bar after an argument with colleagues. The idea was deceptively simple: instead of training one neural network to generate realistic data, train two networks in adversarial competition.
The generator is a counterfeiter. Its job is to produce fake images convincing enough to fool the detective. The discriminator is the detective. Its job is to distinguish real images from the counterfeiter’s fakes. Each time the detective catches a fake, the counterfeiter learns what gave it away and improves. Each time the counterfeiter fools the detective, the detective sharpens its skills. The competition is zero-sum — one’s gain is the other’s loss.
In theory, this competition continues until the generator produces perfect fakes and the discriminator can do no better than random guessing. In practice, GAN training is notoriously unstable — but when it works, the results are stunning. By 2018, GANs could generate photorealistic human faces of people who have never existed.
How GAN works ?
- The generator takes a random noise vector as input and passes it through layers to produce a synthetic image.
- The discriminator receives both real images from the training dataset and fake images from the generator, and predicts which is which.
- The discriminator’s loss measures how often it is fooled. It backpropagates and improves its detection.
- The generator’s loss measures how often its fakes are caught. It backpropagates and improves its generation — specifically learning to fool the current discriminator.
- Both networks update simultaneously, locked in an adversarial loop.
- Training converges (ideally) when the generator produces images the discriminator cannot reliably classify.
Real-world examples
Not theory — what real teams actually shipped using this technique.
- StyleGAN2 (NVIDIA, 2020) — generated photorealistic human faces of nonexistent people at 1024×1024 resolution. The website thispersondoesnotexist.com shows a new GAN face every refresh. Every face is fake. None are distinguishable from real photographs.
- Pix2Pix and CycleGAN — translate images between domains without paired training data. Horse → Zebra. Summer → Winter. Sketch → Photograph. These image-to-image translation GANs demonstrated that style and content can be disentangled.
- Drug discovery — Insilico Medicine used a GAN to generate novel molecular structures with desired pharmacological properties, producing a drug candidate in 46 days — a process that typically takes years.
Common pitfalls
- Mode collapse — the generator learns to produce a small variety of convincing fakes instead of diverse outputs. It finds a few examples that fool the discriminator and exploits them, ignoring the full diversity of the target distribution.
- Training instability — GAN training is notoriously difficult. The generator and discriminator must improve at roughly the same rate. If one gets too far ahead, training collapses. Techniques like Wasserstein loss, spectral normalisation, and gradient penalties help but do not fully solve the problem.
- Evaluation difficulty — measuring how good GAN outputs are is genuinely hard. FID (Fréchet Inception Distance) is the standard metric but is not perfectly correlated with human judgments of quality.
- Diffusion models outperform on image quality — for most image generation tasks, diffusion models now produce higher quality and more diverse outputs with more stable training. GANs have ceded this territory.
Frequently asked questions
QUESTION 1 What is a GAN in simple terms?
ANSWER 1 Two neural networks competing — a counterfeiter (generator) creating fakes and a detective (discriminator) spotting them. Their competition drives both to improve until fakes become indistinguishable from real data.
QUESTION 2 How does a GAN generate a realistic image?
ANSWER 2 The generator transforms random noise into an image. The discriminator judges it real or fake. The generator learns from being caught. Repeated millions of times, it learns to consistently fool the discriminator.
QUESTION 3 What are GANs used for?
ANSWER 3 Image generation, image-to-image translation, super-resolution, data augmentation, deepfakes, drug discovery molecular generation, and video generation.
QUESTION 4 Have GANs been replaced by diffusion models?
ANSWER 4 Largely for image generation — diffusion models produce higher quality with more stable training. GANs remain used for real-time applications, video, medical imaging augmentation, and drug discovery.
📬 Get one concept + one use case every Tuesday. Join the newsletter →