4.5.2 · D1Generative Models

Foundations — Autoencoders fundamentals

2,040 words9 min readBack to topic

This page is the toolbox. The parent note throws a lot of symbols at you at once — , , , , , , . Here we build each one from nothing, in an order where every symbol is earned before the next uses it. A smart 12-year-old should be able to read from line one.


1. A number vs. a list of numbers: the vector

The picture. A vector with two components is an arrow in a flat plane: tells you how far right, how far up. A vector with three components is an arrow in 3D space. Look at figure s01: the same list of numbers is both "a point" and "an arrow from the origin to that point."

Figure — Autoencoders fundamentals

Why the topic needs it. A grayscale image is 28 pixels wide and 28 tall = little brightness numbers. Line them all up and you get one giant vector . So an image is a vector, and an autoencoder is a machine that eats and spits out vectors.


2. The space a vector lives in:

  • = every point in a flat plane (2 numbers each).
  • = every point in ordinary space (3 numbers each).
  • = every possible -number list, i.e. every possible image.

The picture. Think of as a room where each vector is one specific spot. is the number of directions you can move in. We can only draw up to 3 directions, but the idea works for 784.

Why the topic needs it. When the parent writes , the symbol just means "is a member of / lives inside." So reads: " is one image, sitting somewhere in the room of all possible images." The whole point of an autoencoder is to move this vector into a much smaller room.

Recall What does

mean in plain words? is a list of 32 numbers — a point inside the "room of all 32-number lists." ::: It is the compressed version of the image.


3. A function that moves between rooms:

The picture (figure s02). Draw a big box labelled (all images) and a small box labelled (all codes). The encoder is an arrow carrying a point from the big box to the small box. The decoder is an arrow carrying it back. That round trip — big → small → big — is the autoencoder.

Figure — Autoencoders fundamentals

Why the tiny letters and ? These Greek letters (say "fy" and "thay-ta") are the knobs of the function — its adjustable settings, called parameters. means "the encoder function, currently set to knob-values ." Training = twisting those knobs until the round trip works. We meet the actual knobs (weights) in section 6.


4. Measuring "how far apart": distance and

The whole reason we train is to make the rebuilt vector close to the original . So we need to measure closeness.

The picture (figure s03). Two arrows, (blue) and (orange). The red arrow between their tips is the error vector; its length is the single number "how far off were we?"

Figure — Autoencoders fundamentals

Why squared and not the plain length? Two reasons, and both matter:

  1. Squaring kills the square root, giving a smooth sum that is easy to differentiate (section 6 needs derivatives).
  2. Squaring punishes big mistakes far more than small ones — a pixel off by costs , off by costs . This pushes the network to fix its worst errors first.

The symbol (capital Greek sigma) just means "add up, letting the counter run from to ." So = "add the squared error of every component."

Recall Why do we square the error instead of taking absolute value?

Squaring is smooth (differentiable everywhere) and penalizes large errors much harder. ::: Absolute value has a sharp corner at zero that makes gradient-based training awkward.


5. The bending rule: the activation

The picture (figure s04). ReLU is a flat line then a ramp; sigmoid is a smooth S-curve pinned between 0 and 1.

Figure — Autoencoders fundamentals

Why the topic needs bending. Stacking only straight-line (linear) steps still gives a straight line — a linear autoencoder can only ever do PCA (the parent's Worked Example 1). Real images live on curved shapes, so we need a curved rule to bend the mapping. That is exactly what adds.

Why sigmoid at the decoder's output? Pixel brightness lives in . Sigmoid guarantees the rebuilt pixels land in — which is also what the BCE loss (next section) demands.


6. Knobs, slopes, and the chain: weights, , derivatives

Three last tools the parent leans on.

Why the topic needs derivatives. Training = "twist each knob in the direction that lowers the loss." The derivative points in that direction. The chain rule is what lets the signal travel backward from the output all the way through the bottleneck to the first encoder knob — the parent's "gradient flows through the bottleneck."

Recall What does the symbol

tell you? How much the loss changes when you slightly nudge the knob — the slope. ::: We twist opposite to this slope to reduce the loss.


Prerequisite map

Scalar and Vector

Space R to the n

Function f from X to Z

Norm and distance

Squared reconstruction loss

Encoder and Decoder

Activation sigma

Weights W and bias b

Training objective

Logarithm

Derivative and chain rule

Autoencoders fundamentals

This map feeds directly into the Encoder-Decoder Architectures and Latent Space Representations topics, and underpins the whole family: Variational Autoencoders (VAE), Sparse Autoencoders, Dimensionality Reduction Techniques, and the broader idea of Unsupervised Learning.


Equipment checklist

Read each question, answer in your head, then reveal.

A vector is...
an ordered list of numbers, drawable as an arrow/point.
means...
the room of all possible lists of 784 real numbers, i.e. all images.
means...
a function (with knobs ) carrying an image from the big input room to the small latent room.
means...
the network's reconstruction (guess) of the original .
measures...
the squared straight-line distance between original and reconstruction — the reconstruction error.
We square the error because...
it is smooth to differentiate and punishes big mistakes harder.
inside a layer does...
bends the mapping (ReLU or sigmoid) so the network is more than a straight line.
means...
add up terms as the counter runs from 1 to .
is used because...
it turns products of probabilities into sums and is easy to differentiate, while preserving where the maximum sits.
is...
the slope of the loss with respect to knob — the direction to twist it during training.
The chain rule lets us...
multiply per-step slopes to send the gradient backward through every layer, including the bottleneck.