Sunrise Machine

What if two numbers could paint a sunrise?

Time of Day → Time of Year →
What is latent space? ▸

A map where similar sunrises live near each other. Move a little to the right and the sunrise shifts later in the day; move up and the season warms.

Technical: formal definition ▸

The latent space is a low-dimensional manifold learned by the VAE. Each point represents a compressed description of an image. The decoder maps this back: .

Deep dive: comparison to PCA, t-SNE, UMAP ▸

Unlike PCA (linear), the VAE learns a nonlinear mapping with a probabilistic prior. Unlike t-SNE and UMAP (which only embed, don't decode), the VAE can generate new images from any point in latent space. The trade-off: VAE embeddings may be less visually separated than t-SNE but support generation and interpolation.

The Encoder

Original

Reconstruction

What is an encoder? ▸

A compressor that finds the two most important numbers to describe any sunrise.

Technical: amortized inference ▸

The encoder is a neural network that maps an input image to a distribution in latent space. It outputs two vectors: a mean and a log-variance .

Deep dive: why amortized? ▸

Instead of optimizing a separate latent code for each image (as in classical variational inference), the encoder amortizes the cost by learning a single function that maps any image to its approximate posterior. This is what makes VAEs fast at test time — one forward pass instead of an optimization loop.

The Decoder

Somewhere inside a neural network lives a tiny world of sunrises. Every point in this two-dimensional space maps to a unique image — a gradient of color, light, and atmosphere.

The horizontal axis captures something like time of day: deep pre-dawn blues on the left, bright midday light on the right.

The vertical axis captures time of year: cool winter tones below, warm summer golds above.

Hover over the canvas to decode sunrises in real time. Click to pin two favorites and interpolate between them.

What is a decoder? ▸

A painter that only needs two instructions. Give it two numbers and it produces a full sunrise image.

Technical: the generative model ▸

The decoder is , a neural network that maps a latent vector to an image . The final layer uses a Sigmoid activation to keep pixel values in [0, 1].

Deep dive: architecture ▸

The decoder uses transposed convolutions (sometimes called "deconvolutions") to progressively upsample from a small spatial representation. Starting from the 2D latent code, a linear layer maps to a 128-channel 4×4 feature map, then three ConvTranspose2d layers upsample to 32×32. Each layer has a receptive field that grows with depth, allowing the network to capture both local texture and global structure.

z = (0.00, 0.00)
Leaving the learned distribution...
0.50

Why "Variational"?

Sampling Temperature

T = 1.0

The Balance: Reconstruction vs. Regularization

Sharp images ← → Smooth space

Latent distribution

Reconstruction quality

Why sample from a distribution? ▸

Allowing a little randomness makes the generator more creative. Instead of mapping each image to a single point, the encoder maps it to a small cloud — and we sample from that cloud.

Technical: the reparameterization trick ▸

We sample using:

This lets gradients flow through the sampling step, since the randomness is isolated in .

Deep dive: why is this needed for backprop? ▸

Backpropagation requires differentiable operations. Sampling from a distribution is inherently stochastic and non-differentiable. The reparameterization trick rewrites the sample as a deterministic function of the parameters plus external noise, making the loss differentiable with respect to and .

What is KL divergence? ▸

A measure of how far the encoder's guesses are from a simple baseline (a standard normal distribution). The smaller the KL, the more "regular" the latent space.

Technical: the ELBO ▸

The VAE optimizes the Evidence Lower Bound:

The reconstruction term wants accurate decoding. The KL term wants the encoder to stay close to the prior.

Deep dive: bits-back coding ▸

Information-theoretically, the ELBO can be interpreted via bits-back coding: encoding an image costs log p(x|z) bits, but we "get back" KL(q||p) bits because the decoder expects samples from the prior. The gap between the ELBO and the true log-likelihood is the KL divergence between the approximate and true posterior.

Your Turn

Can you find this sunrise in latent space?

Score: -- Guesses: 0/3
Round: 0/5 | Total: 0 | Best: --

Your sunrise:

z = (0.00, 0.00)

Loading model...
Lite mode