Introduces the term normalizing flow and the change-of-variables density update for a sequence of invertible maps, used there to enrich variational posteriors (ICML 2015).
Normalizing Flows: Tractable Density via Invertible Transforms
Invertible maps that turn a simple density into a richer one: exact log-likelihood from the change-of-variables formula, and layer designs that keep the Jacobian determinant cheap.
Intuition
The idea in plain words, before the symbols.
A normalizing flow is an invertible, differentiable map that warps a simple distribution into a richer one (Rezende and Mohamed, 2015).
Start from a simple base distribution, such as a standard Gaussian. Then apply an invertible transformation that bends and stretches space into a richer model distribution.
Because the transform is invertible, you get:
- Exact sampling: sample from the base, push forward to .
- Tractable log-likelihood under the flow model: map back to and account for how volumes change.
The price is architectural: you must design so it is invertible and the needed map direction plus Jacobian determinant are cheap to compute.
The two terms of the log-likelihood can pull in opposite directions. A map that squeezes space raises density through its volume term, but it may have to start from a base point far in the tail to reach the point being scored. The practice after the demo compares two such maps.
Study prompts for this section: Intuition
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Demo
Change an input, predict the result, and see which quantities respond.
Explore Normalizing Flows: Tractable Density via Invertible Transforms
Observation guide
Optional and ungraded. Opening a guide saves nothing.
Choose what to inspect in Normalizing Flows: Tractable Density via Invertible Transforms, then open its guide.
The demo below asks you to predict the density effect before revealing the Jacobian correction. The exact log-likelihood always has two terms: the base log-density at the inverse point and the log-volume correction from the inverse Jacobian.
Study prompts for this section: Demo
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Practice
Two affine flows of a standard normal score the same point. Predict which gives the higher density, check both log terms, then change the point and the maps.
Mathematics
Definitions, assumptions and the derivation.
Change of variables
Let where is invertible and . Then:
so:
The determinant term is the volume correction. Relative to the base density at the corresponding latent point, an inverse map that squeezes a small data-space volume into a smaller latent-space volume multiplies density by a factor below one; an inverse map that expands that volume multiplies it by a factor above one.
Equivalently, expansion by the forward map spreads probability over more data-space volume and lowers density. For example, in one dimension x = 2z gives p_x(x) = p_z(x / 2) / 2. When comparing different points or transforms, the base-density term can also change, so the determinant alone does not determine which total density is larger.
This is the tractable-density advantage of flows, but also the constraint: a flexible transform is useful for likelihood work only when the needed map direction and log-determinant stay tractable.
The volume term does not rank densities by itself
For a one-dimensional affine map with and a standard normal base, the change of variables reads
Compare map A, , with map B, , at the point . B's volume term is larger, against . But B must start from , two standard deviations out, while A starts from :
The same happens with , , and , , at : D's volume term is larger by , yet . The Jacobian determinant matters only together with the base density at the preimage.
The absolute value ignores orientation. The map has the same volume term as , and at the same density, because its preimage has the same standard normal density as . With a base distribution that is not symmetric, the two densities can differ.
Maps that are not one-to-one
The formula needs exactly one preimage. For , both and reach a point , and each contributes its base density divided by :
One branch alone integrates to . At the derivative vanishes, and below there is no preimage. Normalizing flows avoid these cases by building from invertible layers whose Jacobian determinants are never zero.
Composition of flows
If maps latent variables forward, with and , then the inverse-Jacobian log-determinants add as a negative sum of forward log-determinants:
This follows from the determinant of a product of Jacobians. A general determinant costs operations, so practical flows are built from layers with cheap Jacobians. The coupling layers of Real NVP (Dinh et al., 2017), for example, have triangular Jacobians, whose log-determinant is just the sum of the logs of the diagonal entries. Papamakarios et al. (2021) review the main designs.
A one-dimensional check of the sum: following by gives the single map , and the forward log-determinants equal that map's.
Study prompts for this section: Mathematics
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Code
The same calculation as runnable code, in the notation of the derivation.
import numpy as np
# A tiny 2D linear flow: x = A z + b, with z ~ N(0, I)
A = np.array([[1.2, 0.3], [0.1, 0.9]])
b = np.array([0.5, -0.2])
Ainv = np.linalg.inv(A)
def log_pz(z):
d = z.shape[0]
return -0.5 * float(z @ z) - 0.5 * d * np.log(2 * np.pi)
x = np.array([1.0, 0.0])
z = Ainv @ (x - b)
log_px = log_pz(z) + np.log(abs(np.linalg.det(Ainv)))
print("det(A):", round(float(np.linalg.det(A)), 3))
print("z:", np.round(z, 3))
print("log p_x(x):", round(float(log_px), 3))
The second block computes the comparisons from the Mathematics section and checks that the two-branch density for integrates to one.
import numpy as np
def log_density(x, a, b):
# x = a z + b with z ~ N(0, 1): the base density at the preimage, then the volume term
z = (x - b) / a
return -0.5 * np.log(2 * np.pi) - 0.5 * z**2 - np.log(abs(a))
A, B = log_density(1, 2, 0), log_density(1, 0.5, 0)
C, D = log_density(2, 3, 1), log_density(2, 1 / 3, 1)
print("log p_A(1) - log p_B(1):", round(A - B, 6), "vs 15/8 - 2 ln 2 =", round(15 / 8 - 2 * np.log(2), 6))
print("log p_C(2) - log p_D(2):", round(C - D, 6), "vs 40/9 - 2 ln 3 =", round(40 / 9 - 2 * np.log(3), 6))
print("x = -2z and x = 2z agree at x = 1:", bool(np.isclose(log_density(1, -2, 0), A)))
# x = z^2 is two-to-one: sum both preimages, each divided by |dx/dz| = 2 sqrt(x)
phi = lambda z: np.exp(-z**2 / 2) / np.sqrt(2 * np.pi)
def square_density(x):
r = np.sqrt(x)
return (phi(r) + phi(-r)) / (2 * r)
u = np.linspace(1e-9, 12, 1_200_001) # substitute x = u^2, dx = 2u du, to pass the 1/sqrt(x) peak
print("both branches integrate to", round(float(np.trapezoid(square_density(u**2) * 2 * u, u)), 6),
"; one branch to", round(float(np.trapezoid(phi(u) / (2 * u) * 2 * u, u)), 6))
Study prompts for this section: Code
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Concept: Normalizing Flows: Tractable Density via Invertible Transforms
What is the smallest example of Normalizing Flows you can work through by hand, and what does it show?
DetailsGenerative Models
Reference id
concept:generative-models/normalizing-flowsAfter the first pass
Go deeper
Optional material for a second reading. Sources are always shown; the other panels open from their headings or from these links, and closing one keeps what you wrote or revealed.What to look for in each sectionChoose a section and what you expect to see in it, then read short advice.
Section by section
Choose what to look for in each section
Invertible maps that turn a simple density into a richer one: exact log-likelihood from the change-of-variables formula, and layer designs that keep the Jacobian determinant cheap.

Start with the picture, metaphor, or geometric mechanism.
Choose what you expect to see in this section of Normalizing Flows: Tractable Density via Invertible Transforms.
Questions to ask of the pictureChoose a part of the picture and what you expect, then read short advice.
Looking at the picture
Questions to ask of the picture
Invertible maps that turn a simple density into a richer one: exact log-likelihood from the change-of-variables formula, and layer designs that keep the Jacobian determinant cheap.
Which part of the picture should you look at first?
Pick the part of the picture you expect to explain Normalizing Flows: Tractable Density via Invertible Transforms.
Sources
References for this page
A reference shows where an idea comes from; it does not vouch for every step on this page.Builds flows from affine coupling layers whose Jacobians are triangular, so the log-determinant is a sum of per-dimension terms (ICLR 2017).
A review of normalizing flows: the change-of-variables formula, composition, and the main layer designs that keep the inverse and the Jacobian determinant cheap (Journal of Machine Learning Research, 2021).
Springer. Chapter 18 is a textbook treatment of normalizing flows.
What each claim rests on1 claim, each with its sources, where it appears on this page, and its caveats.
Claims and sources
Invertible maps that turn a simple density into a richer one: exact log-likelihood from the change-of-variables formula, and layer designs that keep the Jacobian determinant cheap.
The checks were made by this site, not by an independent reviewer.
Rezende and Mohamed define a normalizing flow as transforming a probability density through a sequence of invertible mappings, state that repeated change-of-variables moves an initial density through that se...
Rezende and Mohamed frame flows for variational approximate posteriors and density transformation; they do not by themselves justify broad claims about modern data modeling, sampling quality, stability, or u...
Rezende and Mohamed support normalizing flows as sequences of invertible maps that turn a simple initial density into a richer one. They derive the change-of-variables update for a finite flow using inverse or forward Jacobian determinants, and give the log density of the composition as the base log density minus the summed forward log-determinants. The page's equations, code (an affine flow) and demo look up the preimage and add the inverse-Jacobian log-volume correction.
Explain it without the pageWrite your own explanation before asking for feedback. Your draft and any hints stay while this page is open.
Practice · Normalizing Flows: Tractable Density via Invertible Transforms
Try the idea in your own words
Invertible maps that turn a simple density into a richer one: exact log-likelihood from the change-of-variables formula, and layer designs that keep the Jacobian determinant cheap.
Concept · Selected for practice
Normalizing Flows: Tractable Density via Invertible Transforms
What it rests on: Sources: Variational Inference with Normalizing Flows; Density estimation using Real NVP; Normalizing Flows for Probabilistic Modeling and Inference
Context and links
Generative Models
Explain the mechanism
For Normalizing Flows: Tractable Density via Invertible Transforms: What is the smallest example of Normalizing Flows you can work through by hand, and what does it show? Explain your answer, including what changes, why, and which assumption matters.
A rough first thought is enough. Your draft stays when you change tasks.
Your draft stays on this page and is cleared when you leave or reload.
A little help · Explain
Open one hint at a time. These are suggestions, not your answer or a grade.
0 of 3 hints shown for this question.
Clearing your answer keeps this help record. Outside help is your own report; this page cannot check it.
Where am I stuck? (optional)
Take your draft to a feedback conversation
No AI feedback runs here. You can copy a prompt to use elsewhere; nothing is sent automatically. Review the text before sharing, and leave out private information.
Write an attempt before copying a feedback prompt.
A draft, or an AI reply to it, is not a test of what you have learned. To check that, try a different case later without help.
Ask about this pagePick one item on this page and copy a prompt about it into an AI assistant you already use. Notes you write here stay in this browser.
A = np.array([[1.2, 0.3], [0.1, 0.9]])Your question
Choose what your question is about
Pick the idea, equation, source, code, claim, misconception or demo state you want to ask about. The prompt you copy includes it, so the answer can stay on that item.Open the draft below to save one note and next action in this browser.
Normalizing Flows: Tractable Density via Invertible Transforms
What is the smallest example of Normalizing Flows you can work through by hand, and what does it show?
Fixed prompts generated from this item. They are not comments from people or independent reviews.
The 4 cited sources must support this exact item, not just the surrounding topic.
Connect the definition to one equation, piece of code or demo before widening the discussion.
Change one input, then check that the same relationship holds in the mathematics, the code and the demo.
You can state the mechanism in your own words
Local action draftNo local draft saved yetOpen when you are ready to write one next action
This draft stays in this browser and is attached to this item only.
- What the 4 cited sources say about this exact item
- The definition, its prerequisites, and a contrasting concept
- The equation or code that makes the concept concrete
- One demo state that shows what stays the same as the inputs change
- You can state the mechanism in your own words
- You can name the prerequisite that would clear up the confusion
- You can predict how the result changes when one input changes
Reference id
concept/concept-notebook/generative-models/normalizing-flows
concept:generative-models/normalizing-flows