A generative adversarial network, or GAN, is a machine learning system that learns to create new examples that look like a training dataset. It can generate images, sounds, text patterns, or other data by studying many real examples. GANs matter because they show how computers can learn creativity-like patterns from data instead of following fixed drawing or writing rules.
They are used in art tools, image improvement, game design, data simulation, and scientific modeling.
Key Facts
- A GAN has two neural networks: a Generator G and a Discriminator D.
- The Generator maps random input noise z into a fake sample: fake data = G(z).
- The Discriminator estimates whether an input is real or fake: D(x) = probability that x is real.
- Training is adversarial because G tries to fool D while D tries to detect fakes.
- A common GAN objective is min_G max_D V(D, G) = E[log D(x)] + E[log(1 - D(G(z)))].
- If training succeeds, fake samples become hard to distinguish from real samples because the generated data distribution becomes closer to the real data distribution.
Vocabulary
- Generator
- The neural network in a GAN that creates fake samples from random input noise.
- Discriminator
- The neural network in a GAN that predicts whether a sample is real from the dataset or fake from the Generator.
- Training data
- The collection of real examples that a machine learning model studies to learn patterns.
- Loss function
- A mathematical score that tells a model how wrong its predictions or outputs are during training.
- Latent space
- The hidden input space of random numbers that the Generator transforms into new samples.
Common Mistakes to Avoid
- Thinking the Generator copies real images exactly is wrong because it learns statistical patterns and produces new samples that resemble the dataset.
- Training only the Generator is wrong because a GAN needs feedback from the Discriminator to improve its fake samples.
- Assuming a lower Discriminator score always means better training is wrong because GAN training is a balance between two changing networks.
- Using too little or biased training data is wrong because the GAN can only learn patterns that are represented in the examples it sees.
Practice Questions
- 1 A Discriminator checks 200 samples and labels 150 correctly as real or fake. What is its accuracy as a percent?
- 2 A Generator creates 64 fake images in each training batch. If training runs for 500 batches, how many fake images are produced during training?
- 3 Explain why a GAN can improve when the Discriminator gets better, but can also fail if the Discriminator becomes too strong too early.