# 归一化流

归一化流是一种生成模型，它通过一系列可逆变换将简单的概率分布（通常是标准正态分布）转换为复杂的概率分布，从而使模型既能采样又能计算精确的似然。归一化流被用于图像、音频及其他高维数据的生成建模、近似推断以及监督学习。<sup>[1](https://jmlr.csail.mit.edu/papers/v22/19-1028.html)</sup> 由于变换是双射的，模型的密度具有闭式表达式，这使归一化流区别于变分自编码器。<sup>[2](https://phuijse.github.io/BLNNbook/chapters/variational/nf.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 归一化流产生什么 | 由简单基分布加一系列双射变换定义的分布，支持采样和精确密度评估<sup>[1](https://jmlr.csail.mit.edu/papers/v22/19-1028.html)</sup> |
| 核心公式 | 带雅可比行列式的变量替换；通过将数据映射回基分布来评估密度<sup>[3](https://ar5iv.labs.arxiv.org/html/1908.09257)</sup> |
| 可处理性要求 | 输入输出维度相等、可逆性，以及高效可微的雅可比行列式计算<sup>[4](https://deepgenerativemodels.github.io/notes/flow/)</sup> |
| 术语提出者 | Tabak 和 Turner，综述文献将其定年为 2013 年，他们将流定义为 K 个简单映射的复合<sup>[1](https://jmlr.csail.mit.edu/papers/v22/19-1028.html)</sup><sup> • </sup><sup>[5](https://doi.org/10.1002/cpa.21423)</sup> |
| 基准（CIFAR-10） | Glow 3.35 比特/维度，RealNVP 3.49；Residual Flow 3.28；Monotone Flow 3.215<sup>[6](https://papers.nips.cc/paper/2018/file/d139db6a236200b21cc7f752979132d0-Paper.pdf)</sup><sup> • </sup><sup>[7](https://proceedings.nips.cc/paper_files/paper/2022/file/6afae862e1abc2ea396c5e842be54a52-Paper-Conference.pdf)</sup> |
| 采样速度 | Glow 在 NVIDIA 1080 Ti GPU 上生成一个 256 × 256 样本约需 130 毫秒<sup>[8](https://openai.com/index/glow/)</sup> |
| 主要应用 | 图像建模、文本转语音、无监督语言归纳、数据压缩和分子结构建模<sup>[9](https://pyro.ai/examples/normalizing%5Fflows%5Fi.html)</sup> |

## 工作原理

流模型指定一个密度为 \( p_{Z} \) 的基分布（通常为标准正态分布）和一个将基样本映射到数据空间的可逆可微变换 \( g \)。若 \( f \) 为 \( g \) 的逆，则数据点 \( y \) 的密度为

\[ p_{Y}(y) = p_{Z}\bigl(f(y)\bigr)\,\bigl|\det D g\bigl(f(y)\bigr)\bigr|^{-1}. \]

可逆性是似然精确的原因：任何样本都可以被推回基空间，在那里其概率是已知的，而雅可比行列式则校正了变换所引起的体积变化。<sup>[3](https://ar5iv.labs.arxiv.org/html/1908.09257)</sup>

三个条件使这一方法切实可行：输入和输出维度必须相等，变换必须可逆，且雅可比行列式的计算必须高效且可微。<sup>[4](https://deepgenerativemodels.github.io/notes/flow/)</sup> 这些性质在复合下封闭：若变换 \( f_{1} \) 和 \( f_{2} \) 易于求逆且行列式易于计算，则 \( f_{1} \circ f_{2} \) 亦然，总体积变化为各层行列式的乘积。<sup>[10](https://papers.nips.cc/paper/2017/file/6c1da886822c67822bcf3679d04369fa-Paper.pdf)</sup><sup> • </sup><sup>[3](https://ar5iv.labs.arxiv.org/html/1908.09257)</sup>

## 实现方法

训练时选择基分布、可逆层架构，并最大化精确对数似然，即基对数密度加上各层对数行列式之和。与变分自编码器不同——其边际似然 \( p(x) \) 不可处理，必须通过 ELBO 优化——归一化流的边际似然是可处理的，最大对数似然有直接表达式。<sup>[2](https://phuijse.github.io/BLNNbook/chapters/variational/nf.html)</sup>

训练好的流提供两种代价不同的操作。采样在单次网络前向传播中对基噪声运行正向变换 \( T \)，因为变换是确定性的；密度评估则运行逆变换 \( T^{-1} \) 并计算雅可比行列式。<sup>[1](https://jmlr.csail.mit.edu/papers/v22/19-1028.html)</sup> 架构选择由行列式计算代价驱动：对于隐藏维度 \( D \) 和 \( L \) 个隐藏层，通用可逆网络计算行列式的复杂度为 \( O(L \cdot D^{3}) \)，因此可扩展的流需要具有高效行列式计算机制的可逆变换。<sup>[11](https://proceedings.mlr.press/v37/rezende15.html)</sup>

## 起源

机器学习中最清晰的思想前身是白化，即将数据变换为白噪声；Chen 和 Gopinath（2000）也许是最早将白化用于密度估计的人，称该方法为高斯化。<sup>[1](https://jmlr.csail.mit.edu/papers/v22/19-1028.html)</sup> 将流用于密度估计最早由 Esteban G. Tabak 和 Eric Vanden-Eijnden 在《通过对数似然对偶上升进行密度估计》（Communications in Mathematical Sciences，2010）中提出，该文通过扩散过程和刘维尔方程来处理这一问题。<sup>[12](https://doi.org/10.4310/cms.2010.v8.n1.a11)</sup><sup> • </sup><sup>[1](https://jmlr.csail.mit.edu/papers/v22/19-1028.html)</sup> “归一化流”一词及作为 K 个简单映射复合的现代定义出现在《一类非参数密度估计算法》（Communications on Pure and Applied Mathematics）中，综述文献将其定年为 2013 年。<sup>[1](https://jmlr.csail.mit.edu/papers/v22/19-1028.html)</sup><sup> • </sup><sup>[5](https://doi.org/10.1002/cpa.21423)</sup> 用深度神经网络参数化流可以产生通用且表达力强的分布类。<sup>[1](https://jmlr.csail.mit.edu/papers/v22/19-1028.html)</sup>

该框架随后从两个方向进入主流机器学习。Danilo Jimenez Rezende 和 Shakir Mohamed 在《带归一化流的变分推断》（2015）中用流构建灵活的近似后验，并引入了平面流和径向流；他们的论文明确将流原理归功于 Tabak 和 Turner 以及 Tabak 和 Vanden-Eijnden。<sup>[11](https://proceedings.mlr.press/v37/rezende15.html)</sup> 在密度估计方面，耦合方法由 Laurent Dinh、David Krueger 和 [Yoshua Bengio](https://www.edgepedia.org/zh/yoshua-bengio) 在《NICE：非线性独立成分估计》（2014）中引入，Dinh、Sohl-Dickstein 和 Bengio 的《使用 Real NVP 进行密度估计》（2016）以仿射耦合对其进行了扩展。<sup>[13](https://doi.org/10.48550/arxiv.1605.08803)</sup><sup> • </sup><sup>[3](https://ar5iv.labs.arxiv.org/html/1908.09257)</sup><sup> • </sup><sup>[11](https://proceedings.mlr.press/v37/rezende15.html)</sup>

## 变体

**耦合层流**将每个输入分成两部分；一部分原样通过，另一部分由以第一部分为条件的函数进行变换。在 NICE 中，耦合层雅可比为下三角矩阵且对角元素为 1，因此模型是保体积的；RealNVP 将加性耦合层与重缩放层复合，增加了缩放因子。<sup>[4](https://deepgenerativemodels.github.io/notes/flow/)</sup> 耦合流，包括 NICE、RealNVP、Glow、WaveGlow、FloWaveNet 和 Flow++，因其密度评估和采样都很快而广受欢迎。<sup>[1](https://jmlr.csail.mit.edu/papers/v22/19-1028.html)</sup> Glow 由 Diederik P. Kingma 和 Prafulla Dhariwal 提出（《Glow：带可逆 1x1 卷积的生成流》，2018），建立在 NICE 和 RealNVP 之上，使每一步由 actnorm、可逆 1 × 1 卷积和耦合层组成。<sup>[6](https://papers.nips.cc/paper/2018/file/d139db6a236200b21cc7f752979132d0-Paper.pdf)</sup>

**自回归流**将每个输出维度以前面的各维度为条件。掩码自回归流（MAF）由 George Papamakarios、Theo Pavlakou 和 Iain Murray（2017）提出，使用 MADE 作为构建模块，使密度评估避免顺序自回归循环，从而使 MAF 在 GPU 上评估和训练都很快；它在通用密度估计上优于 RealNVP。<sup>[10](https://papers.nips.cc/paper/2017/file/6c1da886822c67822bcf3679d04369fa-Paper.pdf)</sup> 代价是 MAF 的前向映射是自回归的，因此采样是顺序的且慢，在样本维度上复杂度为 \( O(D) \)；逆自回归流（IAF）反转生成过程使采样并行化，但新数据点的似然计算很慢。<sup>[4](https://deepgenerativemodels.github.io/notes/flow/)</sup> 神经自回归流（NAF）由 Chin-Wei Huang、David Krueger、Alexandre Lacoste 和 Aaron Courville（2018）提出，用深度神经网络建模耦合函数以获得更强的表达力。<sup>[14](https://doi.org/10.48550/arxiv.1804.00779)</sup><sup> • </sup><sup>[3](https://ar5iv.labs.arxiv.org/html/1908.09257)</sup> MAF 和 IAF 都对应于 RealNVP 的推广。<sup>[10](https://papers.nips.cc/paper/2017/file/6c1da886822c67822bcf3679d04369fa-Paper.pdf)</sup>

**平面流和径向流**由 Rezende 和 Mohamed 引入，相对简单但其逆不易计算，因此支持基于采样的用途（如变分推断）而非精确密度评估。<sup>[11](https://proceedings.mlr.press/v37/rezende15.html)</sup> **连续归一化流**用神经常微分方程替代离散层；FFJORD 由 Will Grathwohl、Ricky T. Q. Chen、Jesse Bettencourt、Ilya Sutskever 和 David Duvenaud（2018）提出，实现了具有自由形式连续动力学的可扩展可逆生成模型。<sup>[15](https://doi.org/10.48550/arxiv.1810.01367)</sup> **残差流和单调流**放宽了严格的层约束：Byeongkeun Ahn、Chiyoon Kim、Youngjoon Hong 和 Hyunwoo J. Kim（2022）的《用于归一化流的可逆单调算子》从可逆单调算子构建流。<sup>[16](https://doi.org/10.48550/arxiv.2210.08176)</sup> Qinsheng Zhang 和 Yongxin Chen（2021）的《扩散归一化流》通过两个神经随机微分方程结合了流和扩散。<sup>[17](https://doi.org/10.48550/arxiv.2110.07579)</sup>

**流匹配和整流流**是无模拟地训练连续归一化流的方法。流匹配由 Yaron Lipman、Ricky T. Q. Chen、Heli Ben-Hamu、Maximilian Nickel 和 Matt Le（2022）提出，对固定条件概率路径的向量场进行回归，使用最优传输路径时轨迹为直线，从而训练更快、采样更快、泛化更好。<sup>[18](https://arxiv.org/abs/2210.02747)</sup> 整流流由 Xingchao Liu、Chengyue Gong 和 Qiang Liu（2022）提出，将前向过程定义为数据分布与标准正态之间的直线路径 \( z_{t} = (1-t)\,x_{0} + t\,\varepsilon \)，而随机插值由 Michael S. Albergo 和 Eric Vanden-Eijnden（2022）提出，将框架推广到连接任意两个分布，而不仅限于数据和高斯噪声。<sup>[19](https://doi.org/10.48550/arxiv.2209.03003)</sup><sup> • </sup><sup>[20](https://doi.org/10.48550/arxiv.2209.15571)</sup>

## 应用

归一化流将简单的独立同分布标准正态噪声转换为复杂的、可学习的高维分布，已被应用于图像建模、文本转语音、无监督语言归纳、数据压缩和分子结构建模。<sup>[9](https://pyro.ai/examples/normalizing%5Fflows%5Fi.html)</sup> 在变分推断中，它们作为灵活的近似后验，通过一系列可逆变换对简单初始密度进行变换而构建。<sup>[11](https://proceedings.mlr.press/v37/rezende15.html)</sup> 在音频方面，Sungwon Kim、Sang-gil Lee、Jongyoon Song、Jaehyeon Kim 和 Sungroh Yoon（2018）的《FloWaveNet：原始音频的生成流》生成原始波形，而 Parallel WaveNet 结合了 IAF 和 MAF：IAF 学生模型生成样本，而通过最大似然训练的 MAF 教师模型提供似然，学生模型通过最小化与教师的 KL 散度来训练。<sup>[21](https://doi.org/10.48550/arxiv.1811.02155)</sup><sup> • </sup><sup>[4](https://deepgenerativemodels.github.io/notes/flow/)</sup>

以比特/维度计（越低越好），Glow 在 CIFAR-10 上达到 3.35，而 RealNVP 为 3.49；均匀去量化基准表给出 Residual Flow 在 CIFAR-10 上为 3.28，Monotone Flow 为 3.215，在 ImageNet 32 × 32 上 RealNVP 达到 4.28 而 Monotone Flow 达到 3.961。<sup>[6](https://papers.nips.cc/paper/2018/file/d139db6a236200b21cc7f752979132d0-Paper.pdf)</sup><sup> • </sup><sup>[7](https://proceedings.nips.cc/paper_files/paper/2022/file/6afae862e1abc2ea396c5e842be54a52-Paper-Conference.pdf)</sup> 采样是单次前向传播：Glow 的模型在 NVIDIA 1080 Ti GPU 上生成一个 256 × 256 样本约需 130 毫秒。<sup>[8](https://openai.com/index/glow/)</sup> 这些方法现在支撑着大型文本到图像系统：《用于高分辨率图像合成的整流流 Transformer 扩展》（Esser 及同事，2024），即 [Stable Diffusion 3](https://www.edgepedia.org/zh/stable-diffusion-3) 论文，通过对数几率正态分布时间步采样重新加权噪声尺度来改进整流流训练，并引入了 MM-DiT，一种对文本和图像词元使用单独权重并在注意力中连接的 Transformer。<sup>[22](https://arxiv.org/html/2403.03206v1)</sup>

## 局限与替代方案

**拓扑不匹配**。由于流是微分同胚（光滑、可逆且逆也光滑的变换），输入、输出及所有中间空间必须具有相同维度，这限制了流表示复杂拓扑目标的能力；当先验和目标不同胚时，流会将概率质量泄漏到目标支撑集之外。<sup>[23](https://ar5iv.labs.arxiv.org/html/2309.04433)</sup> 一个可见的症状是：用单峰高斯基分布表示双峰或多峰目标时会出现涂抹效应——尖锐边界无法表达，密度泄漏到真实支撑集之外；在流形假设下，基和目标拓扑很可能不匹配。<sup>[23](https://ar5iv.labs.arxiv.org/html/2309.04433)</sup> Cornish 等（2019）表明，对于具有不同支撑拓扑的基和目标以及连续变换，任意精确的近似要求变换的双 Lipschitz 常数（衡量函数“可逆性”的指标）趋于无穷。<sup>[23](https://ar5iv.labs.arxiv.org/html/2309.04433)</sup>

与替代方案比较：自回归模型和 VAE 在对数似然上优于基于流的模型，但分别存在采样效率低和推断不精确的缺点。<sup>[8](https://openai.com/index/glow/)</sup> 普通流在单次网络前向传播中生成样本，因此采样效率高；DiffFlow 在采样时需要 MCMC，而随机归一化流更慢，因为它们使用 Metropolis-Hastings 算法。<sup>[23](https://ar5iv.labs.arxiv.org/html/2309.04433)</sup> 已发表的比较没有量化流与 GAN 和扩散模型在样本质量上的对比，也没有量化保体积约束的内存代价。

## References

1. [Normalizing Flows for Probabilistic Modeling and Inference (Papamakarios, Nalisnick, Rezende, Mohamed, Lakshminarayanan; JMLR)](https://jmlr.csail.mit.edu/papers/v22/19-1028.html)
2. [An introduction to Normalizing Flow models, Bayesian Learning and Neural Networks](https://phuijse.github.io/BLNNbook/chapters/variational/nf.html)
3. [Normalizing Flows: An Introduction and Review of Current Methods (Kobyzev, Prince, Brubaker)](https://ar5iv.labs.arxiv.org/html/1908.09257)
4. [Normalizing Flow Models (course notes)](https://deepgenerativemodels.github.io/notes/flow/)
5. [E. G. Tabak, Cristina V. Turner (2012). A Family of Nonparametric Density Estimation Algorithms. Communications on Pure and Applied Mathematics.](https://doi.org/10.1002/cpa.21423)
6. [Glow: Generative Flow with Invertible 1x1 Convolutions (Kingma & Dhariwal, NeurIPS 2018)](https://papers.nips.cc/paper/2018/file/d139db6a236200b21cc7f752979132d0-Paper.pdf)
7. [Invertible Monotone Operators for Normalizing Flows (NeurIPS 2022)](https://proceedings.nips.cc/paper_files/paper/2022/file/6afae862e1abc2ea396c5e842be54a52-Paper-Conference.pdf)
8. [Glow: Better reversible generative models](https://openai.com/index/glow/)
9. [Normalizing Flows - Introduction (Part 1), Pyro Tutorials](https://pyro.ai/examples/normalizing%5Fflows%5Fi.html)
10. [Masked Autoregressive Flow for Density Estimation (Papamakarios, Pavlakou, Murray, NeurIPS 2017)](https://papers.nips.cc/paper/2017/file/6c1da886822c67822bcf3679d04369fa-Paper.pdf)
11. [Variational Inference with Normalizing Flows (Rezende & Mohamed, ICML 2015)](https://proceedings.mlr.press/v37/rezende15.html)
12. [Esteban G. Tabak, Eric Vanden-Eijnden (2010). Density estimation by dual ascent of the log-likelihood. Communications in Mathematical Sciences.](https://doi.org/10.4310/cms.2010.v8.n1.a11)
13. [Dinh, Laurent, Sohl-Dickstein, Jascha, Bengio, Samy (2016). Density Estimation Using Real NVP. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1605.08803)
14. [Huang, Chin-Wei and colleagues (2018). Neural Autoregressive Flows. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1804.00779)
15. [Grathwohl, Will and colleagues (2018). FFJORD: Free-form Continuous Dynamics for Scalable Reversible Generative Models. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1810.01367)
16. [Ahn, Byeongkeun and colleagues (2022). Invertible Monotone Operators for Normalizing Flows. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2210.08176)
17. [Zhang, Qinsheng, Chen, Yongxin (2021). Diffusion Normalizing Flow. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2110.07579)
18. [Flow Matching for Generative Modeling (Lipman et al.)](https://arxiv.org/abs/2210.02747)
19. [Liu, Xingchao, Gong, Chengyue, Liu, Qiang (2022). Flow Straight and Fast: Learning to Generate and Transfer Data with Rectified Flow. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2209.03003)
20. [Albergo, Michael S., Vanden-Eijnden, Eric (2022). Building Normalizing Flows with Stochastic Interpolants. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2209.15571)
21. [Kim, Sungwon and colleagues (2018). FloWaveNet : A Generative Flow for Raw Audio. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1811.02155)
22. [Scaling Rectified Flow Transformers for High-Resolution Image Synthesis (Stable Diffusion 3)](https://arxiv.org/html/2403.03206v1)
23. [Variations and Relaxations of Normalizing Flows](https://ar5iv.labs.arxiv.org/html/2309.04433)

---
*Initially written Sep 29, 2026 · Reviewed: Sep 30, 2026 · Edited: Oct 15, 2026; Oct 21, 2026 · Last review: Sep 30, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Machine learning methods

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/normalizing-flow

English original: https://www.edgepedia.org/normalizing-flow
