Generative Adversarial Networks (GANs) are a revolutionary approach to generative modeling where two neural networks compete against each other in a game. The Generator creates fake data trying to fool the Discriminator, while the Discriminator tries to distinguish real data from fake. Through this adversarial training, GANs can generate incredibly realistic images, videos, and even music. They're behind deepfakes, art generation, and photo enhancement.
Watch the Generator and Discriminator compete!
Generator improves over time, creating increasingly realistic samples
GANs use an ingenious adversarial training approach inspired by game theory. Think of it like a counterfeiter (Generator) trying to make fake money and a detective (Discriminator) trying to spot fakes. As the detective gets better at spotting fakes, the counterfeiter must improve their technique. Eventually, the counterfeiter becomes so good that even the expert detective can't tell real from fake. This competitive process drives both networks to improve, resulting in highly realistic generated content.
Training a GAN to generate realistic human faces:
Initial: Generator produces random noise that looks nothing like faces
Iteration 100: Vague face-like blobs appear, Discriminator easily spots fakes (95% accuracy)
Iteration 1000: Recognizable faces with odd features, Discriminator accuracy drops to 80%
Iteration 10000: Realistic faces with minor artifacts, Discriminator at 60% accuracy
Iteration 50000: Photorealistic faces, Discriminator can barely tell real from fake (52% accuracy)
Result: Generator creates faces indistinguishable from real photos!
Generator's Objective: Maximize log(D(G(z))) - fool the discriminator
Discriminator's Objective: Maximize log(D(x)) + log(1 - D(G(z))) - correctly classify real and fake
This is a minimax game where one player's gain is another's loss. The networks reach a Nash
equilibrium when the Generator produces perfect fakes and the Discriminator can only guess randomly
(50% accuracy). At this point, the Generator has learned the true data distribution!
1. Initialize: Create both Generator and Discriminator networks with random weights
2. Train Discriminator: Show it real data (label 1) and generated fake data (label 0)
3. Train Generator: Generate fakes and get Discriminator's feedback (try to get label 1)
4. Alternate: Train D for k steps, then G for 1 step (typically k=1)
5. Monitor: Watch Discriminator accuracy approach 50% (random guessing)
6. Converge: Stop when generated samples look realistic and D can't distinguish them
Deep Convolutional GAN: Uses CNNs for both networks, stable training, produces high-quality images. Foundation for many modern GANs.
Style-Based Generator: Controls different aspects of generated images at different levels. Creates photorealistic faces with adjustable features.
Unpaired Image Translation: Converts images between domains (horses↔zebras, summer↔winter) without paired training data.
Paired Image Translation: Converts images with paired training data (sketches→photos, day→night, maps→satellite images).