Intuition The ONE core idea
A GAN is two neural networks locked in a game: one paints fakes , the other judges if a picture is real or fake, and each one's improvement forces the other to get better. Everything on the parent page is just the precise bookkeeping of that game — who is trying to make which number go up, and who is trying to make it go down.
Before you can read a single line of the parent note, you must be able to look at every symbol it uses and immediately know what it means and why it is there. This page builds them one at a time, in an order where each new symbol only uses symbols already defined. Nothing is assumed.
Everything starts with two machines. Let us draw them before we name them.
G
G is a machine that takes random noise as input and produces a fake sample as output (a fake image, say). Picture a factory: junk goes in the left, a picture comes out the right.
We write its output as G ( z ) — read aloud as "G of z ", meaning "the picture the generator makes from the noise z ".
Definition The Discriminator
D
D is a machine that takes a picture as input and outputs a single number between 0 and 1 : its guess of "how likely is this picture real?". Picture a detective holding a photo and saying a confidence percentage.
D ( x ) = 1 means "I am certain this is real".
D ( x ) = 0 means "I am certain this is fake".
D ( x ) = 0.5 means "I genuinely cannot tell".
Why two machines and not one? Because we have no direct rule for "what makes a face look real". So we let one machine learn that rule (the detective D ) and use it as the teacher for the painter G . That is the whole trick.
We keep saying "noise" and "picture". Let us pin down the exact symbols.
z — the noise vector
z is a list of random numbers (say 100 of them), usually drawn from a bell curve. It is the raw randomness the generator turns into variety. Picture a handful of dice: shake them and you get a different z , which makes a different fake.
x — a data sample
x is one real example — one genuine image from your dataset. Picture pulling one photo out of a shoebox of real photos.
∼ (tilde) and p (a distribution)
The wavy arrow ∼ reads "is drawn from ". A distribution p ( ⋅ ) is a rule that says how likely each possible value is — picture a landscape where tall hills are common values and flat valleys are rare ones.
x ∼ p d a t a ( x ) means "x is a real sample, drawn from the true data landscape".
z ∼ p z ( z ) means "z is noise, drawn from the noise landscape (the dice)".
p g — the generator's distribution
As G chews through every possible noise z , it produces a whole cloud of fake pictures. The landscape describing how likely each fake is is called p g . Picture a second hill sitting next to the real-data hill. The entire goal of training is to slide the p g hill until it sits exactly on top of the p d a t a hill.
Why do we need distributions at all? Because G is never judged on one fake — it is judged on the whole population of fakes it can make. Distributions are the language for "the whole population at once".
The parent note is full of E . It looks scary; it is just an average.
E — expected value (a weighted average)
E x ∼ p d a t a [ f ( x ) ] reads "the average value of f ( x ) , if you keep drawing x from the real-data landscape". Picture: draw a million real photos, compute f on each, add them up, divide by a million.
E x ∼ p [ f ( x )] = ∫ x f ( x ) p ( x ) d x
Intuition Why the little subscript matters
The subscript tells you which landscape you are averaging over . E x ∼ p d a t a averages over real pictures; E z ∼ p z averages over noise (and hence over fakes). Same averaging machine, different bag you draw from.
Why average instead of one sample? Because a single lucky (or unlucky) picture tells you nothing about whether G is generally good. The game is decided on averages, so the objective is written with averages.
The parent note wraps every probability in log . Here is the honest reason.
log — the logarithm
log ( y ) answers "what power do I raise the base to, to get y ?". For our purposes you only need its shape : it is a curve that is huge-negative near 0 and gently rising toward 0 as y → 1 .
log and not just the probability?
Look at the red curve. If the detective is correct with probability near 1 , log is near 0 — small penalty. If the detective is catastrophically wrong (probability near 0 ), log plunges to − ∞ — a savage penalty. So log punishes confident mistakes far harder than mild ones , which is exactly what we want from a training signal. It also turns "multiply many probabilities" into "add many logs", which is numerically stable and easier to differentiate. This is the same object that powers binary cross-entropy .
Two building blocks you will now recognise on sight:
log D ( x ) — big (near 0) when D correctly calls a real picture real.
log ( 1 − D ( G ( z )) ) — big (near 0) when D correctly calls a fake picture fake. Here 1 − D ( ⋅ ) flips "probability real" into "probability fake".
Now every piece of the headline formula is a symbol you have already met.
How does a machine "tune itself"? Two more symbols.
θ — the parameters (the knobs)
θ d is the full set of numbers inside D (its weights); θ g is the set inside G . Picture a mixing desk covered in knobs — training means turning knobs.
∇ — the gradient (which way is uphill)
∇ θ f reads "the direction, in knob-space, that increases f fastest". Picture standing on a hillside blindfolded and feeling which way is steepest uphill.
D ascends its gradient (walk uphill on the scoreboard) — it wants V bigger.
G descends its gradient (walk downhill) — it wants V smaller.
Why gradients and not a formula for the best knobs? Because D and G are giant tangled networks with no closed-form best setting. Feeling your way uphill/downhill one small step at a time is the only tractable option — this is the machinery of the GAN training algorithm .
Discriminator D outputs 0 to 1
log wraps each probability
expectation E averages the batch
min G max D the tug of war
parameters theta d and theta g
Nash equilibrium D equals half
Every arrow says "you need the tail before you can understand the head." Read the parent note only once every box here feels obvious.
Once the tug-of-war stalls perfectly you reach D ∗ ( x ) = 2 1 everywhere — but the path there can break in two famous ways: mode collapse (the painter cheats with one trick) and vanishing gradients, which motivates the Wasserstein GAN . This page only equips you to read the dynamics; those pages explain when they go wrong.
Cover the right side. If you can answer each, you are ready for the parent note .
What does G ( z ) mean in plain words? The fake picture the generator builds from a noise vector z .
What number does D ( x ) output, and what do 0 , 1 , and 0.5 mean? A probability in [ 0 , 1 ] : 1 = certainly real, 0 = certainly fake, 0.5 = can't tell.
Read the symbol x ∼ p d a t a ( x ) aloud and say what it means. "x is drawn from the real-data distribution" — x is one genuine sample.
What is p g and what is the training goal about it? The distribution of the generator's fakes; the goal is to make p g equal p d a t a .
What does E z ∼ p z [ f ] compute? The average of f over many noise draws z from the noise distribution.
Why is log wrapped around every probability? It punishes confident mistakes far harder (goes to − ∞ near 0) and turns products into stable sums.
What does log ( 1 − D ( G ( z ))) measure? How correctly D labels a fake as fake; near 0 when D is right about the fake.
In min G max D V , who pushes the scoreboard up and who pushes it down? D pushes V up (wants to be right); G pushes V down (wants to fool D ).
What are θ d and θ g ? The internal weights (knobs) of the discriminator and generator respectively.
What does ∇ θ point toward, and who ascends vs descends it? The steepest-increase direction in knob-space; D ascends, G descends.