Stochastic Variational Inference

Chapter 16 Mathematics for AI

Chapter 16: Variational Inference and Latent Variables — Stochastic Variational Inference

From the book

Chapter 16: Variational Inference and Latent Variables. In the chapter mind map this icon labels Stochastic VI(SVI). The discussion below is excerpted and lightly edited from § Stochastic Variational Inference in Mathematics for AI and Machine Learning.

Variational Inference (VI)[^variational-note] approximates the intractable posterior $p_{\boldsymbol\theta}(\mathbf z | \mathbf x)$ with a simpler variational distribution $q_{\boldsymbol\phi}(\mathbf z)$ parameterized by variational parameters $\boldsymbol\phi$, chosen from a restricted family of distributions $\mathcal{Q}$.

[^variational-note]: The term "variational" comes from the calculus of variations, a branch of mathematics that deals with optimizing over functions rather than just parameters. In variational inference, we optimize over a family of distributions (functions) to find the best approximation to the true posterior, searching through a variational family $\mathcal{Q}$ of tractable distributions.

The variational family $\mathcal{Q}$ is a constrained set of distributions (not all possible distributions) chosen for computational tractability. The choice of $\mathcal{Q}$ balances expressiveness (approximation quality) and computational efficiency (optimization and expectation computation). Common choices include Gaussian distributions, mean field distributions (factorized into independent components: $q(\mathbf z) = \prod_{i=0}^{k-1} q_i(z_i)$), or distributions parameterized by neural networks.

The variational parameters $\boldsymbol\phi$ define the specific distribution within this family. For example, if $q$ is Gaussian, then $\boldsymbol\phi = \{\boldsymbol\mu, \boldsymbol\Sigma\}$; if $q$ is parameterized by a neural network (as in VAEs), then $\boldsymbol\phi$ represents the encoder network's weights and biases.

The goal is to find $q^_{\boldsymbol\phi^}(\mathbf z) \in \mathcal{Q}$ that minimizes the KL divergence from $q$ to the true posterior:

Here, $q^$ denotes the optimal variational distribution (the best approximation within the family $\mathcal{Q}$), and $\boldsymbol\phi^$ denotes the optimal variational parameters that achieve this minimum. The asterisk ($^*$) notation is standard mathematical notation for optimal values.

What this drawing shows

What you see. Green mini-batch and purple ELBO curve fixed; red stochastic gradient arrows grow sequentially from batch samples toward the objective.

In the mind map. Chapter 16 — Stochastic VI(SVI). See From the book above for definitions, figures, and worked examples.

Where to read next

Open Chapter 16 companion →

Read the full definitions, figures, and worked examples in Chapter 16: Variational Inference and Latent Variables — see the mind-map node Stochastic VI(SVI).

PNG Icons

Textless (256×256 px)
PNG 256×256 px Copy PNG URL
Textless (64×64 px)
PNG 64×64 px Copy PNG URL
Textless (32×32 px)
PNG 32×32 px Copy PNG URL

Animated GIFs

Animated GIF (256×256 px)
GIF 256×256 px Copy GIF URL
Animated GIF (128×128 px)
GIF 128×128 px Copy GIF URL
Animated GIF (64×64 px)
GIF 64×64 px Copy GIF URL