Lensa ML
Lensa ML

How GANs Work

Step 1 of 6

The Forger and the Detective

Two networks locked in a creative duel

Generator"The Forger"Obvious FakeDiscriminator"The Detective"FAKE!
Fake quality0.15
D(real)
0.92
D(fake)
0.10
QUALITY
15%

Obvious fake — discriminator is very confident. A GAN pits a Generator (forger) against a Discriminator (detective). Drag the slider to see how the discriminator's confidence changes as fake quality improves.

Step 1 of 6: The Forger and the Detective

Two networks locked in a creative duel

Generator"The Forger"Obvious FakeDiscriminator"The Detective"FAKE!
Fake quality0.15
D(real)
0.92
D(fake)
0.10
QUALITY
15%

Obvious fake — discriminator is very confident. A GAN pits a Generator (forger) against a Discriminator (detective). Drag the slider to see how the discriminator's confidence changes as fake quality improves.

Step 2 of 6: The Generator

Creating from random noise

NOISEDenseReshapeConvT0%Output (8x8)Garbage!Generator Network
Noise seed42
Training0
NOISE INPUT
42
TRAINING
0%
QUALITY
0.05

The Generator takes a random noise vector and transforms it through layers. Drag the training slider to see how output quality improves as the network learns. Different noise seeds produce different outputs.

Step 3 of 6: The Discriminator

Learning to spot fakes

REAL(from dataset)FAKE(from generator)DiscriminatorD(real)0.92CORRECTD(fake)0.15CORRECTthreshold = 0.50
Threshold0.50
D(REAL)
0.92
D(FAKE)
0.15
ACCURACY
100%

The Discriminator outputs a probability for each input. The decision threshold determines its classification boundary. Drag the slider to see how the threshold affects accuracy. Too high or too low, and the discriminator makes mistakes.

Step 4 of 6: The Adversarial Game

Each network improves to beat the other

2D Distribution MatchingReal (Gaussian)Fake (Generated)LOSS CURVES3.00Epochln(2)G LossD Loss
Epoch0
EPOCH
0
G LOSS
3.00
D LOSS
0.30

Training alternates: the Discriminator learns to detect fakes, then the Generator learns to fool it. The fake distribution (purple dots) gradually converges to match the real distribution (green dots). Use the controls to step through training.

Step 5 of 6: Reaching Equilibrium

When the generator fools the discriminator 50% of the time

GAN BalanceD50%G50%EquilibriumD confidence on fakes0.50 target0.50
Balance0.50
D CONF
0.50
G LOSS
0.70
D LOSS
0.69
REGIME
Equilibrium

Near Nash equilibrium: the Discriminator outputs ~0.50 for all inputs. Both networks push each other to improve. Losses converge near ln(2) ≈ 0.693.

Step 6 of 6: What GANs Can Create

Images, music, text, and beyond

Latent Space Explorationz1 dimensionz2 dimensionGenerated OutputStyleGANPix2PixSRGANCycleGAN
z1 (style)0.50
z2 (content)0.50
Z1
0.50
Z2
0.50
OUTPUT SEED
100

GANs learn a smooth latent space where nearby points produce similar outputs. Drag both sliders to navigate the 2D latent space and see how generated images interpolate smoothly between corners. This enables face generation, style transfer, and super-resolution.