JupiteX Get the app
Science & Technology30 Nov 2026 · about 7 min

Variational Autoencoders Explained: From Latent Representations to Probabilistic Generation

The brief

A Variational Autoencoder (VAE) is a generative model that learns a probabilistic map between observations and latent variables. It combines representation learning, probabilistic modeling, and variational inference. Its aim is not only to compress and reconstruct examples, but also to define a way to generate observations from sampled latent variables. A conventional autoencoder turns an input into one internal representation and decodes that representation back into an output. A VAE instead encodes an input as a probability distribution over possible latent codes. Its decoder models how observations can be produced from latent variables, rather than simply returning one fixed reconstruction. That difference matters when creating new examples. A standard autoencoder has no inherent rule for choosing useful random codes, so decoding one may yield an unrecognizable result. A VAE’s probabilistic model supplies a prior for sampling codes and a learned conditional process for producing observations. This provides a route from reconstructing existing data to generating new data.

01

What is a Variational Autoencoder, and how does it differ from a conventional autoencoder?

A Variational Autoencoder (VAE) is a generative model that learns a probabilistic map between observations and latent variables. It combines representation learning, probabilistic modeling, and variational inference. Its aim is not only to compress and reconstruct examples, but also to define a way to generate observations from sampled latent variables.

A conventional autoencoder turns an input into one internal representation and decodes that representation back into an output. A VAE instead encodes an input as a probability distribution over possible latent codes. Its decoder models how observations can be produced from latent variables, rather than simply returning one fixed reconstruction.

That difference matters when creating new examples. A standard autoencoder has no inherent rule for choosing useful random codes, so decoding one may yield an unrecognizable result. A VAE’s probabilistic model supplies a prior for sampling codes and a learned conditional process for producing observations. This provides a route from reconstructing existing data to generating new data.

02

Why does a VAE encode an input as a probability distribution over latent codes instead of one fixed code?

A VAE encodes an input as a probability distribution over possible latent codes instead of choosing one fixed code. This is part of its shift from reconstruction alone to probabilistic generation. The model defines how latent variables are selected and how observations can be produced from them.

For example, a handwritten digit’s thickness or slant can affect many pixels at once. A latent code can represent an underlying factor like one of these, while a distribution represents possible codes that could explain the observed image. The encoder is meant to approximate the posterior: which latent variables could have produced that observation.

This approach gives the model a probabilistic framework for both explaining inputs and generating observations. The article emphasizes that an ordinary autoencoder has no guarantee that a randomly selected code will produce a meaningful digit. A VAE instead learns a prior and a conditional generation process. That makes sampling latent codes a defined part of the model, rather than an unsupported use of its decoder.

03

Why might an ordinary autoencoder reconstruct an image well but fail to generate a meaningful image from a random latent vector?

An ordinary autoencoder is trained to reconstruct its inputs. Its objective rewards preserving enough information in the latent representation to reproduce each example. But it does not inherently define a distribution for choosing latent codes when generating new data. Low reconstruction error alone therefore does not ensure that arbitrary codes will decode into meaningful images.

Imagine encoding handwritten digits and then giving the decoder a randomly selected latent vector. The vector may not correspond to a region or representation associated with any real digit. The source notes that a sufficiently flexible autoencoder might even learn to copy its input, rather than discovering useful features. Either way, reconstruction success does not guarantee sensible random generations.

A generative model needs both a distribution from which latent variables can be sampled and a model describing how they produce observations. VAEs build this probabilistic structure into the task. The practical distinction is central: reconstruction tests whether inputs can be reproduced, while generation requires a meaningful process for selecting latent codes and decoding them into new data.

04

How many possible latent explanations can an observation have, and why does considering them all become difficult in a high-dimensional space?

An observation can have multiple latent explanations. The article gives no fixed count: it says different latent variables can produce similar observations. In the usual continuous-latent setting, possible codes form a continuum, while discrete latent variables can instead be counted by summation. This distinction is reflected in the article’s description of marginalization as an integral, or a sum for discrete variables.

To evaluate how well a model explains an image, it must account for all latent variables that could have produced it. For a handwritten digit, more than one combination of underlying factors may lead to similar visible pixels. The model therefore combines the probabilities of those explanations rather than choosing only one.

This calculation becomes difficult when the latent space is high-dimensional and the conditional distribution uses a complex neural network. The article says exact marginal likelihood can then be intractable. Variational inference and the ELBO provide a way to train without directly evaluating the full integral. The challenge is not just the size of the space, but computing the combined probability over it.

05

What is the posterior distribution, and why does a VAE encoder approximate it instead of calculating it exactly?

The posterior distribution gives the probability of latent variables after an observation is known. In a generative model, the prior describes how latent variables are selected, and the conditional distribution describes how observations arise from them. Bayes’ theorem combines these pieces to define the posterior for a particular input.

For a handwritten image, the posterior represents which latent codes could plausibly explain its pixels. Calculating it exactly requires the marginal likelihood in the denominator. That likelihood accounts for all possible latent explanations, and the article notes that computing it can become intractable with a high-dimensional latent space and a complex neural network.

A VAE therefore uses variational inference: it introduces a manageable approximate posterior, represented by the encoder. The article also notes that sampling from the prior can be inefficient when explanatory latent values occupy only a narrow region of the space. Approximation makes learning computationally manageable while aiming to represent the latent explanations relevant to each observed input.

06

How does the ELBO let a VAE train without directly calculating the exact marginal likelihood, and what role does KL divergence play?

The exact marginal likelihood requires considering all latent explanations for an observation. The article says this calculation can become intractable with high-dimensional latent spaces and complex neural networks. The ELBO, or evidence lower bound, lets a VAE train using a variational objective without directly evaluating that full integral.

In the standard VAE formulation, the ELBO balances how well the decoder explains the observed input against how closely the approximate posterior matches the prior. The first part rewards reconstruction or data fit. The second part is a KL-divergence penalty between the encoder’s approximate posterior and the prior. This formula is standard VAE background; the supplied article introduces the ELBO and KL divergence but its displayed objective is absent from the text provided.

KL divergence measures discrepancy between distributions. The article states that it is non-negative, reaches zero when distributions match, and is generally asymmetric. In the VAE objective, it helps constrain the approximate latent distributions. This makes training possible without calculating exact marginal likelihood, while linking inference about inputs to the model’s generative prior.

07

How can shared latent variables make image features vary together, even when those features are modeled as conditionally independent given the latent variables?

A shared latent variable can influence multiple parts of an observation at once. The article explains that changing a handwritten digit’s thickness or slant affects multiple pixels simultaneously. A latent variable can represent an underlying factor with this kind of broad effect.

The generative process first selects latent variables from a prior, then generates observations conditioned on them. Pixels may be modeled as conditionally independent once the latent variables are fixed. But across different latent values, a shared factor can change many pixels together. For example, changing the thickness factor can affect several parts of a digit in a coordinated way.

This structure lets dependencies among observed components emerge through shared latent variables, even when the model treats those components as conditionally independent given the latent code. It matters because image features do not always vary one pixel at a time. The article presents shared latent variables as a way to describe how underlying factors influence observed data and support probabilistic generation.

This brief was written by AI from the original reporting and checked by other models. Names, figures and quotes come from the source; read it for full context.

Read more in the JupiteX app

Pulse is free. New stories every 4 hours, each one broken into the questions that explain it.

Or read more news on the web