4.5.6 · D1Generative Models

Foundations — Generative Adversarial Networks (GAN) framework

2,108 words10 min readBack to topic

Before you can read a single line of the parent note, you must be fluent in a small alphabet of symbols. This page introduces each one from absolute zero — plain words first, then the picture it stands for, then why the topic cannot live without it. Read top to bottom: every symbol is built only from symbols already explained above it.


1. The two worlds: data space and noise space

Everything in a GAN lives in one of two "spaces". A space here just means "the set of all possible things of one kind".

  • Data space — the world of things we want to make. If we make images, a point in data space is one whole image.
  • Noise space — a world of pure randomness, our raw material. A point here is just a list of random numbers.
Figure — Generative Adversarial Networks (GAN) framework

Look at the figure: on the left is a blob of noise dots (structureless); on the right is the data blob (curved, structured — real images cluster on a thin curved region, not everywhere). The Generator's whole job is the red arrow: carry a noise point on the left onto the data region on the right.

Why the topic needs two spaces: we cannot ask a network to "imagine from nothing" — a computer needs some input. So we feed it randomness and ask it to transform randomness into data. Two spaces, one bridge.


2. Vectors, and the symbol

Every image is stored as a long list of numbers (each pixel's brightness). A list of numbers is called a vector.

  • (letter x) = a point in data space, i.e. one real sample. Picture: one actual photo from our dataset.
  • (letter z) = a point in noise space, i.e. one random seed. Picture: a short list like of length 100.

Why: the parent note writes and output . Now you know that just means "the input is a list of 100 random numbers, the output is an image-shaped list of 784 numbers".


3. Probability distributions: , ,

Not every point in data space is equally likely to be a real photo. A photo of a face is common; a photo of pure static is not. A probability distribution is a rule that tells you how likely each point is.

Three distributions appear in the parent note — memorise their pictures:

Symbol Plain words Picture
how real data is spread the true data blob (right side of Fig 1)
how the noise seeds are spread a symmetric fuzzy ball around the origin
how the Generator's fakes are spread a second blob in data space — the fakes' cloud
Figure — Generative Adversarial Networks (GAN) framework

In the figure the black curve is (where real things live) and the red curve is (where fakes live). Early in training they sit apart. The entire goal of a GAN, said in one sentence: push the red curve until it lands exactly on top of the black curve. When , the fakes are statistically indistinguishable from real data.

Why the topic needs distributions: "make realistic images" is vague. "Make equal " is a precise, checkable target — and it is what the whole minimax game secretly optimises. See Discriminative vs Generative Models for why generative models care about at all.


4. Sampling and the symbol

Picture: a hand dipping into the blob and picking one dot, favouring crowded spots.

Why: we never have the formula for — only a pile of examples we can sample. GANs are built to work from samples alone, never needing the formula. This is their superpower.


5. The two networks as functions: and

A function is a machine: put something in, get something out. A neural network (see Neural Network Basics) is a function with tunable knobs, so it can learn the right input→output rule.

Figure — Generative Adversarial Networks (GAN) framework

Follow the figure left→right: a seed enters , becomes a fake image ; that fake, or a real image , enters ; out comes one number on the red 0–1 dial.

Why one number in ? Because "is this real?" is a yes/no question, and the honest answer is a probability. means "90% sure real". This is exactly a binary classifier — the tool that scores it is Cross-Entropy Loss.


6. The knobs: and

Picture: a mixing board with thousands of sliders. Training nudges each slider a little. The tool that decides which way to nudge is Gradient Descent Optimization.

That is why the parent writes — the semicolon means " takes input , and its behaviour is controlled by knobs ".


7. Expectation: the symbol

Picture: draw a thousand samples, compute on each, take the mean. In practice we approximate it by a minibatch average — that is literally what the parent's training loops compute.

Why: the GAN objective must judge over all data, not one point. Expectation is the honest "score across the whole distribution".


8. The logarithm: why appears everywhere

Figure — Generative Adversarial Networks (GAN) framework

Look at the red curve in the figure. Two facts make the perfect scoring tool:

  1. It punishes confident mistakes brutally. If should say "real" (, so we want big) but instead says , then — a huge penalty. Near the curve plunges to .
  2. It barely rewards already-good answers. From to the curve is almost flat. So the network stops obsessing over cases it already nails and focuses its effort where it is wrong.

Why and not just itself? Multiplying many probabilities gives tiny numbers a computer rounds to zero; turns products into sums (stable), and it is the natural language of likelihood — the same reasoning behind Kullback-Leibler Divergence and Cross-Entropy Loss.


9. Putting the alphabet together: reading the value function

You can now decode the parent's central line without fear:

Read it as plain English, symbol by symbol you now know:

  • — "on average over real examples, how loudly does correctly shout real?" (, so , the best possible).
  • — "on average over fakes, how loudly does correctly shout fake?" (, so , so , again best).

turns its knobs to make big; turns its knobs to make small. That opposition is the game, and its balance point is a Nash Equilibrium.


10. The minimax notation:

Picture: a saddle — a mountain pass shaped like a Pringle. Walk one direction and you're at a peak (that's climbing); walk the perpendicular direction and you're at a valley (that's descending). The equilibrium is the seat of the saddle where neither can improve alone. This is exactly the Nash Equilibrium idea.


Prerequisite map

Vectors and R to the n

Neural network as a function

Probability distribution p

Sampling with tilde

Expectation E average

Data space and noise space

Generator G

Discriminator D

Value function V

Logarithm log

Parameters theta and gradients

Alternating training

Minimax min max game

GAN framework


Equipment checklist

Test yourself — reveal only after you have answered aloud.

What does a point in data space represent?
One whole real sample, e.g. a single image stored as a vector of pixel values.
What does the noise seed represent, and why do we need it?
A list of random numbers with no meaning; it's the raw randomness transforms into data, because a network needs some input to produce output.
In one sentence, what is the goal of a GAN in terms of distributions?
Push the fake distribution until it equals the real distribution .
What does mean?
Draw one example at random from the real-data distribution, favouring high-density regions.
What does the Discriminator output, and what does mean?
A number in = probability the input is real; means total uncertainty (can't tell real from fake).
What is versus ?
The tunable knobs (parameters) of the Generator and the Discriminator respectively.
What does compute?
The average of over many samples drawn from ; approximated by a minibatch mean.
Give the two reasons is used in the objective.
It punishes confident wrong answers ( near ) and turns products of probabilities into stable sums.
What does say in words?
tunes itself to maximise ; then tunes itself so that best-case-for- value is as small as possible — a saddle-point game.