Free AI Logo
Back to Blog
Tech Explained9 min read2024-04-20

Understanding GANs (Generative Adversarial Networks)

Tech Explained

The Forger and the Detective

Before Diffusion models took over, GANs were the kings of AI generation. Invented by Ian Goodfellow in 2014, a GAN consists of two neural networks pitted against each other in a game.

The Generator (The Forger)

The Generator's job is to create fake data (e.g., an image of a face) that looks real. It starts by outputting random noise and slowly learns to shape it into a face.

The Discriminator (The Detective)

The Discriminator is fed both real images (from a dataset) and fake images (from the Generator). Its job is to classify them: "Real" or "Fake."

The Training Loop

1. The Generator creates a fake image.
2. The Discriminator looks at it and guesses.
3. If the Generator fools the Discriminator, the Generator gets a reward (points), and the Discriminator is penalized (learns it was wrong).
4. If the Discriminator catches the fake, it gets a reward, and the Generator learns it needs to do better.

Evolution

Over millions of rounds, the Forger becomes an expert artist, and the Detective becomes an expert critic. Eventually, the Generator creates images so realistic that the Discriminator can't tell the difference (50% guess rate). This is when the GAN is "converged."

Legacy of GANs

While Diffusion models are now preferred for text-to-image because they are more stable (GANs are notoriously hard to train), GANs are still used for real-time applications like video upscaling (Super Resolution) and style transfer because they are much faster at inference time.