Variational Autoencoder
An autoencoder that remembers things as a range, not a point
- A Variational Autoencoder, or VAE, remembers a piece of data as a range, not a single point. It writes down a center along with how spread out that range is.
- When rebuilding, it draws one value from within that range and uses it. The same input gives a slightly different result every time.
- There are two penalties. It weighs how far the rebuild strayed from the original together with how oddly placed the range itself is.
- The ranges overlap and pack the space tightly, so values between two pieces of data also produce a plausible result.
- In exchange, results tend to come out soft rather than sharp.
Contents
1The analogy
To remake a soap you made at a workshop, you need to write down the recipe. Write it as one fixed point — this many grams of base, this many drops of scent — and that exact soap comes back perfectly, but any soap you never wrote down is a mystery.
So the writing method changes. Write down a range instead — scent somewhere between this much and that much, setting time around here — recording a width alongside the center. Every batch pours a slightly different amount from within that range, so every soap comes out subtly different, but every one of them is a usable soap.
Once the written ranges start overlapping each other, the empty gaps between recipe cards disappear. Reach for anything roughly halfway between two soaps' recipes, and you still get a soap that doesn't feel out of place.
2In detail
Writing down a range instead of a point
A plain autoencoder shrinks one image down to a single short bundle of numbers — every piece of data gets exactly one spot. The problem is that there's nothing between those spots. Reach for a point between two spots and the result comes out unrecognizable.
A VAE has its shrinking half produce two sets of values instead: one is a center, the other is how spread out it is. One image ends up recorded not as a single point but as a round region.
Recording things as regions means neighboring data's regions start to overlap. Wherever they overlap, you get a result blending the properties of this image and that one. Filling in the gaps between spots is the whole point of this approach.
Drawing one value from the range each time
The rebuilding half doesn't just take the center value as-is. It draws a random point from within the recorded range and builds the result from that value. Feed in the same image, and a different point gets drawn each time, so the result comes out a little different every time too.
This random draw makes training tricky. Once randomness gets mixed in, there's no way to trace back what needs adjusting and by how much. So the way of drawing gets rewritten: generate a random value first, off to the side, and set the actual point by multiplying the width by that random value and adding it to the center. With the randomness pushed outside, the center and the width can be adjusted normally.
Two penalties
Training measures two things. First, how far the rebuilt result strays from the original. Second, how far the recorded range strays from a fixed, standard shape. That second rule is what keeps every recipe card from scattering off to some far-flung corner of its own.
The two penalties pull in opposite directions. Chase reconstruction alone, and the width gets squeezed as narrow as possible until it's basically a single point again — and the gaps go empty again. Chase matching the standard shape alone, and every recipe card crowds into the center, so almost any image produces a similar result.
How much weight gets put on each penalty decides this model's character. Attempts to tune that weight so each dimension takes on a clearer, more distinct property grew out of exactly this trade-off.
Walking between two points still works
Once the overlapping ranges pack the space tightly, something interesting becomes possible. Fix the spots of two images, walk between them at even steps, and generate a result at each step, and you get a sequence that gradually morphs from one into the other. No unrecognizable garbage shows up in between.
Making a brand-new result gets simpler too: draw a value from the standard range with no original image at all, and feed it into the rebuilding half. Even at a spot that never showed up in training, the result comes out blending the properties of whatever data sits nearby.
Why results come out soft
Images built this way tend to be stable in overall shape, but they're prone to soft edges and blurred-out detail. That's because the structure allows several results to come from the same spot, and drawing something near the middle of all those possibilities happens to minimize the penalty better for the rebuilding half.
So wherever sharp images are needed, this gets paired with another approach. This structure only handles shrinking data down into a small summary, and the job of sharpening the result inside that summary gets handed off to a noise-clearing approach instead. In fields like audio or molecular structure, where the space between points needs to stay smooth, this approach on its own is still widely used today.
3More precisely
A VAE is a generative model in which the encoder outputs a probability distribution over the latent variable, and the decoder reconstructs the original from a sample drawn from that distribution. The training objective jointly minimizes the reconstruction error and how far the encoder's distribution strays from a predetermined reference distribution. The technique that rewrites the random sample as a calculation on the center and the width, so that training stays possible despite the randomness, is called the reparameterization trick.
The analogy breaks down in places. A soap recipe is written with two or three numbers, but a real latent variable runs from dozens to hundreds of dimensions, and no single dimension is responsible for a human-recognizable property like scent or firmness. And a person sets the width on a recipe card, while here the width itself gets learned and varies from one piece of data to the next.
The penalty for matching the reference distribution blurs out detail as the price of packing the space tightly. The two don't improve together, so deciding how much of one to give up for the other is a decision that always comes attached.
4Try it yourself
5Common misconceptions
It's easy to think a VAE is just an autoencoder with a little randomness sprinkled in, but actually the point is remembering data as a distribution instead of a point, so the whole space gets packed tightly.
It's easy to think remembering things as a range makes the results erratic, but actually the penalty that keeps the range in check is exactly what makes results at in-between points come out stable.
It's easy to think blurry results mean the training wasn't finished, but actually the blur comes from a structure where drawing near the middle of several possibilities happens to be the best move.
7One-line summary
In shortA Variational Autoencoder remembers data as a range instead of a point, filling in the gaps between spots — and that's exactly what lets it generate a plausible new result even at a point in between.
Spotted an error or have a better analogy? Suggest an edit · Last updated2026-09-02