4.5.9 · D1Generative Models

Foundations — DCGAN, WGAN, StyleGAN

2,809 words13 min readBack to topic

This page assumes you know nothing beyond basic arithmetic and what a picture is. Every symbol used by the parent note is built here, one at a time, each resting on the previous.


1. What is an "image" to a computer?

Look at the figure: on the left is a tiny 4×4 picture; on the right are its three number-grids peeled apart.

Figure — DCGAN, WGAN, StyleGAN
  • (a phrase you saw in the parent) means: 3 channels, each a 64-row by 64-column grid. That's numbers.
  • Why the topic needs this: a generator's whole job is to output such a grid of numbers. When the parent writes " RGB image", it is naming the shape of that output.

2. Vectors, , the norm , and the latent vector

The bold signals this is a vector, not one number. The symbol means "is an element of / belongs to".

Figure — DCGAN, WGAN, StyleGAN

Why the topic needs it: every GAN starts from . Different → different generated image. StyleGAN's whole innovation is about how enters the network.


3. Functions and the two players: and / critic

Symbol Plain meaning Input → Output
Generator latent vector → fake image
Discriminator (classic GAN) image → number in = "probability real"
Critic (WGAN) image → any real number = "realness score"

4. Parameters , , the loss , and "training"

Figure — DCGAN, WGAN, StyleGAN

5. The activation functions: ReLU, LeakyReLU, tanh

Figure — DCGAN, WGAN, StyleGAN
  • ReLU : negatives become , positives pass through. Used in the DCGAN generator.
  • LeakyReLU: like ReLU but negatives get a small slope instead of a hard , so a gradient still flows for negative inputs. Used in the DCGAN discriminator to avoid "dying" neurons (dials that get stuck because their gradient is always ).
  • tanh: an S-curve squashing any input into . Used at the generator output so images land exactly in the normalized range from §1.
Recall Why tanh and not ReLU at the output?

Because pixels must span including negatives; ReLU kills all negatives, so it could never produce the dark end of the range. ::: tanh gives the full span.


6. Probability distributions: , , ,

Figure — DCGAN, WGAN, StyleGAN
  • : the symbol means "is drawn from". Read " is a sample drawn from the real-image cloud."
  • : is expectation = the average value of if you keep drawing from the cloud. Not a sum over a fixed list — an average weighted by how likely each value is.

7. The classic GAN objectives ,

Now that , , and are built, we can write the actual game the parent starts from.


8. Measuring distance between two clouds


Prerequisite map

Image as number grid

Normalized range minus1 to plus1

Vector z and norm

z drawn from p of z

Functions G and D and critic f

Weights theta and w

Loss L a scalar score

Gradient and learning rate

Training loop

Activations ReLU tanh

Distributions Pr and Pg

Expectation E

GAN losses LD and LG

Divergence JS vs Wasserstein

Manifold thin sheet

Lipschitz critic

DCGAN WGAN StyleGAN

Every arrow points toward the parent topic the main note: you need each box before that note's symbols make sense.


Equipment checklist

Cover the right side and answer aloud.

What does describe?
3 colour channels, each a 64×64 grid of pixels — one RGB image.
What does mean in words?
is a list of 100 real numbers (the latent seed vector).
Where do the numbers in come from?
They are drawn from a fixed prior, usually , which the parent also writes .
What is the symbol ?
"is an element of / belongs to."
What does the norm compute, and which norm is it?
The Euclidean (straight-line) distance between points and : .
Difference between and ?
outputs a probability in (yes/no realness); the WGAN critic outputs any real number (how-much realness).
What is the loss ?
A function mapping the network's outputs to one scalar "how-bad" number that training pushes down.
What do and stand for?
The bags of tunable weights for the generator and the critic respectively.
What does tell you?
For each weight in , how much the loss changes if you wiggle it — the uphill direction; we subtract it to go downhill.
Why subtract and not add?
To move down the loss landscape; (learning rate) sets step size.
Write the vanilla discriminator objective.
, maximized.
What does tanh guarantee about its output?
It always lies strictly between and , matching normalized pixels.
Why LeakyReLU in the discriminator?
It keeps a small gradient for negative inputs, preventing "dead" neurons.
What does mean?
is a sample drawn from the real-image distribution.
What is ?
The average of over images drawn from the real cloud.
Why do real images live on a "manifold"?
They fill only a thin sheet of the huge pixel space; random grids are static, not photos — so real/fake sheets rarely overlap.
Why does JS divergence give no gradient on disjoint clouds?
It saturates at the constant ; a constant has zero slope, so the compass points nowhere.
How is defined, and what does its select?
; the picks the cheapest transport plan (least shovelling cost).
What is and what does mean?
The largest slope ratio ; means the graph is never steeper than 45°.