Generative Adversarial Network (GAN)
A GAN trains two networks in competition: a generator that fabricates fake samples and a discriminator that judges real versus fake. Their adversarial game pushes the generator toward realistic outputs, enabling image synthesis and data generation without…
Why it exists
Many tasks need a model that can generate new realistic data, faces, textures, audio, rather than just classify existing data. Earlier generative models required specifying and optimizing an explicit probability density, which is hard for complex high-dimensional data like images. GANs sidestep that by learning to generate through competition instead of likelihood maximization.
The mental model
Think of a counterfeiter and a detective. The generator is the counterfeiter producing fake currency; the discriminator is the detective trying to spot fakes. As the detective gets sharper, the counterfeiter must produce better fakes, and vice versa. This arms race continues until the counterfeits are good enough that the detective can do no better than guessing.
How it works
The generator maps a random noise vector to a synthetic sample. The discriminator receives a mix of real samples and generated ones and outputs the probability that each is real. Training is a minimax game: the discriminator maximizes its accuracy at telling real from fake, while the generator minimizes the discriminator's ability to detect its fakes. Gradients from the discriminator flow back to teach the generator. At the theoretical optimum the generator's distribution matches the real data distribution and the discriminator outputs one half everywhere.
When it matters
GANs shine for high-fidelity image synthesis, style transfer, super-resolution, and augmenting scarce datasets. They matter less where you need exact likelihoods or stable, easily trained generation, where diffusion models or variational autoencoders may be preferable. Key failure modes to know are training instability and mode collapse, where the generator produces a narrow set of outputs that fool the discriminator without covering the full data variety.
A concrete example
To generate realistic human faces, you feed the generator random noise vectors and it outputs face images; the discriminator is shown both real photographs and these generated faces and learns to flag fakes. Early on the faces are blurry blobs the discriminator easily rejects. Over many rounds the generator learns texture, symmetry, and lighting to evade detection, eventually producing convincing faces of people who do not exist, the result popularized by sites that display GAN-generated portraits.
Interview question
In a GAN, what objective does the generator pursue during training?
- a.Classify inputs as real or fake more accurately than the discriminator
- b.Produce samples that fool the discriminator into judging them realCorrect
- c.Compress real data into a low-dimensional latent code
- d.Maximize the likelihood it assigns to the real training data
Why? this is the answer
The generator's goal is to create fakes the discriminator cannot distinguish from real data. Option D describes likelihood-based models, and option A describes the discriminator's job, not the generator's.
Just read this? Test yourself on what you have been reading.
Read the original → en.wikipedia.org
- #machine-learning
- #deep-learning
- #generative-models
- #neural-networks
- #gan
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on machine-learning — each one lists the topics its interview covers.
See open roles