| 第1行: |
第1行: |
| | #重定向 [[RealNVP]] | | #重定向 [[RealNVP]] |
| − | '''RealNVP'''('''Real-valued Non-Volume Preserving''',实值非体积保持变换)是一类基于标准化流(normalizing flows)的深度生成模型,由 Laurent Dinh、Jascha Sohl-Dickstein 与 Samy Bengio 于 2017 年提出<ref name="Dinh2017">{{cite journal|author1=Dinh L.|author2=Sohl-Dickstein J.|author3=Bengio S.|title=Density Estimation Using Real NVP|journal=International Conference on Learning Representations (ICLR)|year=2017|url=https://arxiv.org/abs/1605.08803}}</ref>。它的核心思想可以概括为:'''用一个完全可逆的神经网络,将复杂的数据分布逐步变换为简单的高斯分布。由于变换可逆,模型既可正向精确计算数据的概率密度,也可反向直接从高斯分布采样生成新数据。'''
| |
| − | [[文件:Realnvp flow anim.gif|缩略图|332x332像素|上图示意 RealNVP 的正向与反向流程:正向通过复合可逆变换将数据分布映射为标准高斯分布;反向则从高斯分布采样并逐层逆变换还原为数据。]]
| |
| − | = 原理概述 =
| |
| − |
| |
| − | RealNVP 是一类标准化流:它将一系列可逆映射 <math>f_1, \dots, f_n</math> 复合为整体变换 <math>f = f_n \circ \cdots \circ f_1</math>,从而将数据 <math>\mathbf{x}</math> 映射到标准正态分布 <math>\mathbf{z} = f(\mathbf{x}) \sim \mathcal{N}(0, \mathbf{I})</math>。由于可逆性,生成样本时只需从正态分布采样 <math>\mathbf{z}</math>,再通过逆映射 <math>\mathbf{x} = f^{-1}(\mathbf{z})</math> 还原为数据。每一层变换的雅可比行列式都能高效解析计算,因此整体对数似然 <math>\log p_X(\mathbf{x})</math> 可直接求出,无需借助变分下界或对抗训练。
| |
| − |
| |
| − | 在因果涌现的研究中,RealNVP 常被用作可逆编码器(INN)的实现载体。以 NIS 和 NIS+ 为例,编码器被分解为两步:先用 RealNVP 的耦合层将微观状态 <math>\mathbf{x}_t</math> 无损地映射到等维潜在空间 <math>\mathbf{x}'_t</math>(信息转换),再通过投影算子 <math>\chi_{p,q}</math> 丢弃 <math>p-q</math> 个维度,得到宏观状态 <math>\mathbf{y}_t</math>(信息丢弃)。因此,RealNVP 的可逆性、参数共享和解析雅可比行列式,是 NIS 系列实现“可控维度、双向编码—解码”的技术基础;需要强调的是,宏观粗粒化本身是有损的,真正无损的仅是 INN 内部的信息转换阶段。更详细的 NIS/NIS+ 应用见后文。
| |
| − |
| |
| − | = 历史渊源 =
| |
| − |
| |
| − | RealNVP 建立在早期标准化流工作之上,其发展有两条主线。
| |
| − |
| |
| − | 第一条主线是可逆变换的"分层堆叠"思想。从 1990 年代的独立成分分析(ICA),到 2000 年 Chen 与 Gopinath 的'''高斯化'''(Gaussianization)<ref name="Chen2000">{{cite conference|author1=Chen S. S.|author2=Gopinath R. A.|title=Gaussianization|conference=Advances in Neural Information Processing Systems (NIPS)|year=2000}}</ref>,研究者一直尝试用可逆变换将复杂数据"归一化"到简单分布。2010 年,Tabak 与 Vanden-Eijnden 正式提出了"标准化流"(normalizing flow)的数学框架——通过一系列可逆映射,让基分布像水流一样"流动"成目标分布<ref name="Tabak2010">{{cite journal|author1=Tabak E. G.|author2=Vanden-Eijnden E.|title=Density Estimation by Dual Ascent of the Log-Likelihood|journal=Communications in Mathematical Sciences|year=2010|volume=8|issue=1|pages=217-233}}</ref>。
| |
| − |
| |
| − | 第二条主线是耦合层的发明与升级。2014 年,Dinh 等人提出了 '''NICE'''(Non-linear Independent Components Estimation),首次使深度可逆网络可训练<ref name="NICE2014">{{cite journal|author1=Dinh L.|author2=Krueger D.|author3=Bengio Y.|title=NICE: Non-linear Independent Components Estimation|journal=ICLR 2015 Workshop|year=2014|url=https://arxiv.org/abs/1410.8516}}</ref>。NICE 的关键创新是'''加性耦合层''':将输入分成两半,其中一半直接保持不变,另一半则加上一个以第一半为条件的神经网络输出。由于该变换的雅可比行列式恒为 1,它'''保持体积'''(volume preserving),但表达能力因此受限。
| |
| − |
| |
| − | 2017 年的 RealNVP 将加性耦合扩展为仿射耦合,即以前一半变量为条件,对后一半变量先进行缩放再进行平移。这一改动使变换不再保持体积(non-volume preserving),增强了模型的表达能力,同时保留了计算上的便利性。后续的理论工作(Draxler et al., 2024)证明:体积保持的流'''不是'''分布的普适逼近器,而仿射耦合流在良好条件下是<ref name="Draxler2024">{{cite journal|author1=Draxler F.|author2=Wahl S.|author3=Schnörr C.|author4=Köthe U.|title=On the Universality of Volume-Preserving and Coupling-Based Normalizing Flows|journal=Proceedings of the 41st International Conference on Machine Learning (ICML)|year=2024|publisher=PMLR 235}}</ref>。这从理论上解释了 RealNVP 相对于 NICE 的优势。
| |
| − |
| |
| − | <!-- 图1:NICE 的加性耦合 vs RealNVP 的仿射耦合(2D 示意图) -->
| |
| − |
| |
| − | = 算法框架 =
| |
| − |
| |
| − | RealNVP 把若干可逆模块按顺序堆叠,形成从数据空间到潜在空间的完整映射。其网络主体由四个功能模块组成:'''仿射耦合层'''(coupling)负责可逆的特征变换,每个耦合层输出后接'''批量归一化'''(batch normalization)以稳定训练;'''压缩'''(squeeze)负责降低空间分辨率并把信息重排到通道;'''变量分解'''(factor out)负责在每个尺度末尾抽取一部分变量作为潜在编码。其中,仿射耦合层通过 空间棋盘(checkerboard)与通道级(channel-wise)两种掩码实现,二者交替使用。
| |
| − |
| |
| − | [[文件:Realnvp multiscale.svg|缩略图|RealNVP 多尺度分层架构示意图。BN 为批量归一化(Batch Normalization)操作的简写。|替代=|753x753像素]]
| |
| − |
| |
| − | 如上图所示,输入图像 <math>\mathbf{x}</math> 首先进入第一层 Scale 1。每个非末尺度内部依次经过 3 个 checkerboard 掩码的耦合层Coupling(每个耦合层输出后接批量归一化BN)、压缩块Squeeze 、再 3 个 channel-wise 掩码的耦合层(同样每个后接批量归一化),最后通过变量分解 Factor Out 把当前特征一分为二;末尺度则只经过 4 个 checkerboard 耦合层(同样每个后接批量归一化)就进行 Factor Out。一半结果作为 <math>\mathbf{z}^{(i)}</math> 抽出,另一半 <math>\mathbf{h}^{(i)}</math> 继续传入下一尺度。不同尺度之间通过折线连接,最终把每个 <math>\mathbf{z}^{(i)}</math> 展平为向量后按顺序拼接成完整潜变量 <math>\mathbf{z}</math>。虽然各 <math>\mathbf{z}^{(i)}</math> 的展平长度不同(依次为 <math>HWC/2, HWC/4, \dots, HWC/2^{L-1}</math>),但它们的总和恰好等于输入维度 <math>HWC</math>,因此整体变换保持维度不变。这种分层设计的意图是:早期尺度保留高分辨率的局部细节,后期尺度处理低分辨率的全局结构,并通过逐步分解减少后续层的计算量。
| |
| − |
| |
| − | 正向流程可概括为:
| |
| − |
| |
| − | <math>
| |
| − | \mathbf{x} = \mathbf{h}^{(0)} \;\xrightarrow{\text{耦合层} \times n}\; \xrightarrow{\text{压缩}}\; \xrightarrow{\text{耦合层} \times n}\; \xrightarrow{\text{分解出一半}}\; \mathbf{z}^{(1)} \;\longrightarrow\; \cdots \;\longrightarrow\; \mathbf{z}
| |
| − | </math>
| |
| − |
| |
| − | 由于每个压缩和分解步骤都要对空间或通道维度进行对半划分,各尺度的空间尺寸与通道数都必须是偶数;实际应用中通常把图像尺寸调整为偶数,或通过填充、裁剪等预处理满足该条件。
| |
| − |
| |
| − | == 仿射耦合层:可逆的"条件变形" ==
| |
| − |
| |
| − | 图中的 '''Coupling''' 块即仿射耦合层,它是 RealNVP 的基本可逆变换单元。
| |
| − |
| |
| − | {{NumBlk|:|
| |
| − | <math>
| |
| − | \begin{cases}
| |
| − | \mathbf{y}_{1:d} = \mathbf{x}_{1:d} \\[6pt]
| |
| − | \mathbf{y}_{d+1:D} = \mathbf{x}_{d+1:D} \odot \exp\!\bigl(\mathbf{s}(\mathbf{x}_{1:d})\bigr) + \mathbf{t}(\mathbf{x}_{1:d})
| |
| − | \end{cases}
| |
| − | </math>
| |
| − | |{{EquationRef|1}}}}
| |
| − | 这里 <math>\mathbf{s}</math>(scale,缩放)和 <math>\mathbf{t}</math>(translation,平移)是两个深度神经网络(通常是 CNN)。<math>\odot</math> 为逐元素乘积。由于 <math>\mathbf{s}</math> 和 <math>\mathbf{t}</math> 的输入只来自不变的那一半,输出只作用在可变的那一半,整个变换的雅可比矩阵是下三角块结构,行列式即为对角线元素的乘积——计算复杂度从 <math>O(D^3)</math> 降到 <math>O(D)</math>。此外,逆变换为:
| |
| − |
| |
| − | {{NumBlk|:|
| |
| − | <math>
| |
| − | \begin{cases}
| |
| − | \mathbf{x}_{1:d} = \mathbf{y}_{1:d} \\[6pt]
| |
| − | \mathbf{x}_{d+1:D} = \bigl(\mathbf{y}_{d+1:D} - \mathbf{t}(\mathbf{y}_{1:d})\bigr) \odot \exp\!\bigl(-\mathbf{s}(\mathbf{y}_{1:d})\bigr)
| |
| − | \end{cases}
| |
| − | </math>
| |
| − | |{{EquationRef|2}}}}
| |
| − |
| |
| − | [[文件:仿射耦合.png|缩略图|仿射耦合层示意图:正向(从左到右)将输入分块并变换,反向(从右到左)逐块还原。|替代=]]
| |
| − |
| |
| − | 无需对 <math>\mathbf{s}</math> 或 <math>\mathbf{t}</math> 求逆,只需按逆变换公式进行减法和除法即可。因此'''编码(求密度)和解码(采样)同样高效'''。
| |
| − |
| |
| − |
| |
| − |
| |
| − | == 掩码卷积的两种分区模式 ==
| |
| − |
| |
| − | 仿射耦合层要先把输入分成两部分。针对图像数据,RealNVP 使用两种掩码来决定划分方式:
| |
| − |
| |
| − | * '''空间棋盘模式'''(checkerboard masking):像国际象棋棋盘一样,按坐标 <math>(i+j)</math> 的奇偶性决定像素是否属于"被动"集合。相邻像素被分到不同集合,能充分利用局部相关性。
| |
| − | * '''通道级掩码'''(channel-wise masking):将前一半通道设为被动,后一半为主动。这通常在"压缩"操作后使用,因为此时空间分辨率已降低,通道间的语义分工更明确。
| |
| − |
| |
| − | 通过交替堆叠不同掩码的耦合层(至少三层),每个维度在不同层中分别作为被动变量和主动变量,信息得以充分混合。
| |
| − |
| |
| − | <!-- 图3:Checkerboard masking 与 Channel-wise masking 的对比示意图 -->
| |
| − |
| |
| − | == 多尺度架构:分层打包潜在变量 ==
| |
| − |
| |
| − | 多尺度架构依赖两个关键操作:压缩(Squeeze)与变量分解(Factor Out)。
| |
| − |
| |
| − | '''压缩'''(squeezing):将空间上每个 <math>2\times2</math> 的小块在通道方向上重排,将 <math>s\times s\times c</math> 重排为 <math>s/2 \times s/2 \times 4c</math>。空间分辨率减半,通道数四倍——信息被重新排列,但没有丢失。
| |
| − |
| |
| − | '''变量分解'''(factoring out):在每个尺度结束时,将当前表示的一半维度提取为潜在变量 <math>\mathbf{z}^{(i)}</math>,剩下的一半 <math>\mathbf{h}^{(i)}</math> 继续进入下一尺度。最终所有 <math>\mathbf{z}^{(i)}</math> 展平后拼接成完整的潜在编码 <math>\mathbf{z}</math>,其总维度与输入维度相等。
| |
| − |
| |
| − | 该设计具有以下优势:
| |
| − | # '''层次化表示''':早期提取的 <math>\mathbf{z}</math> 对应局部纹理(如边缘、颜色),后期提取的对应全局语义(如物体姿态、场景结构)。
| |
| − | # '''梯度分散''':损失信号能直接传递到所有尺度,避免梯度在深层消失。
| |
| − | # '''降低计算负担''':越早提取的维度越多,后续层需要处理的特征图越小。
| |
| − |
| |
| − | <!-- 图4:多尺度架构流程图 -->
| |
| − |
| |
| − | == 批量归一化:训练深层的稳定器 ==
| |
| − |
| |
| − | 批量归一化(BatchNorm)应用于每个耦合层的输出之后,用于稳定深层训练。
| |
| − |
| |
| − | <math>
| |
| − | \mathbf{x} \mapsto \frac{\mathbf{x} - \tilde{\boldsymbol{\mu}}}{\sqrt{\tilde{\boldsymbol{\sigma}}^2 + \epsilon}}
| |
| − | </math>
| |
| − |
| |
| − | 它的雅可比行列式是各维度缩放因子的乘积,可直接加入对数似然。此外,BatchNorm 起到训练深耦合层堆叠时的稳定作用——它抑制了由缩放参数 <math>\exp(\mathbf{s})</math> 引起的数值爆炸,使梯度稳定传播。
| |
| − |
| |
| − | = 数学原理 =
| |
| − |
| |
| − | == 标准化流与变量替换公式 ==
| |
| − |
| |
| − | 标准化流的核心是概率论中的'''变量替换公式'''(change of variables)。设 <math>\mathbf{z} \sim p_Z(\mathbf{z})</math> 是已知先验(通常取标准正态 <math>\mathcal{N}(0, \mathbf{I})</math>),<math>f = g^{-1}</math> 是从数据 <math>\mathbf{x}</math> 到 <math>\mathbf{z}</math> 的可逆映射(编码器)。则 <math>\mathbf{x}</math> 的密度为:
| |
| − |
| |
| − | {{NumBlk|:|
| |
| − | <math>
| |
| − | p_X(\mathbf{x}) = p_Z\!\bigl(f(\mathbf{x})\bigr)\;\left|\det\!\left(\frac{\partial f(\mathbf{x})}{\partial \mathbf{x}^\top}\right)\right|
| |
| − | </math>
| |
| − | |{{EquationRef|3}}}}
| |
| − |
| |
| − | 取对数得到训练用的目标:
| |
| − |
| |
| − | {{NumBlk|:|
| |
| − | <math>
| |
| − | \log p_X(\mathbf{x}) = \log p_Z\!\bigl(f(\mathbf{x})\bigr) + \log\left|\det\!\left(\frac{\partial f(\mathbf{x})}{\partial \mathbf{x}^\top}\right)\right|
| |
| − | </math>
| |
| − | |{{EquationRef|4}}}}
| |
| − |
| |
| − | 上式中,第一项 <math>\log p_Z(f(\mathbf{x}))</math> 衡量编码后分布与标准高斯的接近程度;第二项(对数雅可比行列式)则是'''体积补偿项'''——如果 <math>f</math> 在某个局部使空间扩张(<math>\det > 1</math>),密度必须相应降低,反之亦然。当流由 <math>K</math> 个变换复合而成 <math>f = f_K \circ \cdots \circ f_1</math> 时,总对数密度是各层对数行列式的求和:
| |
| − |
| |
| − | <math>
| |
| − | \log p_X(\mathbf{x}) = \log p_Z\!\bigl(f(\mathbf{x})\bigr) + \sum_{k=1}^K \log\left|\det\!\left(\frac{\partial f_k}{\partial \mathbf{x}_k^\top}\right)\right|
| |
| − | </math>
| |
| − |
| |
| − | 采样时通过逆向进行:<math>\mathbf{z} \sim p_Z</math>,<math>\mathbf{x} = g(\mathbf{z}) = f_1^{-1} \circ \cdots \circ f_K^{-1}(\mathbf{z})</math>,每层内部运算可并行,因此整体采样速度高于自回归模型。
| |
| − |
| |
| − | == 仿射耦合的雅可比行列式与可逆性 ==
| |
| − |
| |
| − | 仿射耦合层对前 <math>d</math> 维进行恒等映射,对后 <math>D-d</math> 维进行仿射映射,因而雅可比矩阵具有分块三角结构:
| |
| − |
| |
| − | <math>
| |
| − | \frac{\partial \mathbf{y}}{\partial \mathbf{x}^\top} =
| |
| − | \begin{bmatrix}
| |
| − | \mathbf{I}_d & \mathbf{0} \\[8pt]
| |
| − | \dfrac{\partial \mathbf{y}_{d+1:D}}{\partial \mathbf{x}_{1:d}^\top} & \operatorname{diag}\!\bigl(\exp[\mathbf{s}(\mathbf{x}_{1:d})]\bigr)
| |
| − | \end{bmatrix}
| |
| − | </math>
| |
| − |
| |
| − | 由于左上角是单位阵,整个矩阵的行列式等于右下角对角阵的行列式:
| |
| − |
| |
| − | {{NumBlk|:|
| |
| − | <math>
| |
| − | \det\!\left(\frac{\partial \mathbf{y}}{\partial \mathbf{x}^\top}\right) = \exp\!\left(\sum_{j=1}^{D-d} s_j(\mathbf{x}_{1:d})\right)
| |
| − | </math>
| |
| − | |{{EquationRef|5}}}}
| |
| − |
| |
| − | 上述性质是 RealNVP 可处理性的关键:计算行列式不需要对神经网络 <math>\mathbf{s}</math> 或 <math>\mathbf{t}</math> 求导。因此 <math>\mathbf{s}</math> 和 <math>\mathbf{t}</math> 可以是任意复杂的深度残差网络,而不会破坏密度评估的可处理性。多个耦合层复合时,行列式相乘、逆变换按相反顺序复合,性质仍然保持。
| |
| − |
| |
| − | 仿射耦合的逆变换为:对于公式 ({{EquationNote|1}}) 中的前向变换,经过代数变换即可得到公式 ({{EquationNote|2}}) 中的逆变换。无需对 <math>\mathbf{s}</math> 或 <math>\mathbf{t}</math> 求逆,只需按逆变换公式进行减法和除法即可。因此'''编码(求密度)和解码(采样)同样高效'''。
| |
| − |
| |
| − | == 加性耦合、仿射耦合与体积保持 ==
| |
| − |
| |
| − | 下表对比了三种耦合方式:
| |
| − |
| |
| − | {| class="wikitable"
| |
| − | |-
| |
| − | ! 耦合类型 !! 变换 !! 雅可比行列式 !! 体积行为
| |
| − | |-
| |
| − | | '''加性'''(NICE) || <math>\mathbf{y}_2 = \mathbf{x}_2 + \mathbf{t}(\mathbf{x}_1)</math> || <math>1</math> || 体积保持
| |
| − | |-
| |
| − | | '''乘法''' || <math>\mathbf{y}_2 = \mathbf{x}_2 \odot \mathbf{s}(\mathbf{x}_1)</math> || <math>\prod s_j</math> || 非体积保持
| |
| − | |-
| |
| − | | '''仿射'''(RealNVP) || <math>\mathbf{y}_2 = \mathbf{x}_2 \odot \exp(\mathbf{s}(\mathbf{x}_1)) + \mathbf{t}(\mathbf{x}_1)</math> || <math>\prod \exp(s_j)</math> || 非体积保持
| |
| − | |}
| |
| − |
| |
| − | 其中 <math>\odot</math> 为逐元素乘积,体现为空间的拉伸。NICE 的加性耦合对应于平移变换——只改变位置,不拉伸空间;RealNVP 的仿射耦合则允许缩放与平移的组合,更适合匹配真实数据中不同维度、不同尺度的变化。后续理论表明,缺乏这种"非体积保持"能力的流模型,在表达能力上存在本质限制<ref name="Draxler2024" />。
| |
| − |
| |
| − | == 损失函数与最大似然训练 ==
| |
| − |
| |
| − | RealNVP 通过最大化数据对数似然来训练,等价于最小化数据分布与模型分布的前向 KL 散度:
| |
| − |
| |
| − | {{NumBlk|:|
| |
| − | <math>
| |
| − | \mathcal{L}(\theta) = -\mathbb{E}_{p^*(\mathbf{x})}\left[\log p_Z\!\bigl(f(\mathbf{x})\bigr) + \log\left|\det\!\left(\frac{\partial f(\mathbf{x})}{\partial \mathbf{x}^\top}\right)\right|\right]
| |
| − | </math>
| |
| − | |{{EquationRef|6}}}}
| |
| − |
| |
| − | 对于训练集 <math>\{\mathbf{x}^{(i)}\}_{i=1}^N</math>,使用蒙特卡洛近似:
| |
| − |
| |
| − | <math>
| |
| − | \mathcal{L}(\theta) \approx -\frac{1}{N}\sum_{i=1}^N \left[\log p_Z\!\bigl(f(\mathbf{x}^{(i)})\bigr) + \sum_{k=1}^K \log\left|\det\!\left(\frac{\partial f_k}{\partial \mathbf{x}_k^\top}\right)\right|\right]
| |
| − | </math>
| |
| − |
| |
| − | 损失函数包含两项:
| |
| − | * '''先验项''' <math>\log p_Z(f(\mathbf{x}))</math>:促使编码后的 <math>\mathbf{z}</math> 聚集在标准正态分布中心附近,相当于对潜在空间的正则化。
| |
| − | * '''行列式项''':促使模型在数据密集的区域扩张体积、在稀疏区域收缩体积——这与信息论中将码空间分配给高概率事件的原则一致。
| |
| − |
| |
| − | 从对偶视角看(Papamakarios et al., 2021)<ref name="Papamakarios2021">{{cite journal|author1=Papamakarios G.|author2=Nalisnick E.|author3=Rezende D. J.|author4=Mohamed S.|author5=Lakshminarayanan B.|title=Normalizing Flows for Probabilistic Modeling and Inference|journal=Journal of Machine Learning Research|year=2021|volume=22|issue=57|pages=1-64}}</ref>:在数据上最小化前向 KL,等价于在潜在空间中最小化推前分布与先验之间的反向 KL。
| |
| − |
| |
| − | '''实际训练配置''':Adam 优化器,权重衰减 <math>5\times10^{-5}</math>,批量大小 64,先验为标准高斯。图像数据通常先经 logit 变换 <math>\operatorname{logit}(\alpha + (1-\alpha)\mathbf{x}/256)</math> 处理,以消除像素边界的边界效应。
| |
| − |
| |
| − | = 优缺点 =
| |
| − |
| |
| − | == 优势 ==
| |
| − |
| |
| − | * '''精确且可处理的对数似然''':无需变分下界或对抗训练,直接给出数据的精确密度值,适用于异常检测、贝叶斯推断等需要显式概率的场景。
| |
| − | * '''并行采样与推断''':编码和解码均可在维度上完全并行,速度高于自回归模型。
| |
| − | * '''语义潜在空间''':同维度的潜在表示支持属性插值与操控,适合表示学习。
| |
| − | * '''架构灵活''':<math>\mathbf{s}</math> 和 <math>\mathbf{t}</math> 网络可使用任意深度 CNN/ResNet,表达能力不受耦合结构本身限制。
| |
| − | * '''综合多种模型特性''':兼具自回归模型的精确似然、VAE 的快速采样、以及不依赖固定重建损失的生成能力。
| |
| − |
| |
| − | == 局限 ==
| |
| − |
| |
| − | * '''似然性能未达最优''':在 bits/dim 上仍略逊于 PixelRNN 等先进自回归基线。
| |
| − | * '''维度保持约束''':单层流无法降维,需通过多尺度架构的"分解"操作间接实现。
| |
| − | * '''仿射耦合的表达力上限''':相比后续 Flow++ 的 Logistic 混合 CDF 耦合、Neural Spline Flows 的有理二次样条耦合,仿射函数形式较简单<ref name="FlowPlusPlus2019">{{cite journal|author1=Ho J.|author2=Chen X.|author3=Srinivas A.|author4=Duan Y.|author5=Abbeel P.|title=Flow++: Improving Flow-Based Generative Models with Variational Dequantization and Architecture Design|journal=ICML|year=2019}}</ref>。
| |
| − | * '''均匀去量化的次优性''':对离散像素加均匀噪声的做法,后来被变分去量化改进。
| |
| − | * '''分区固定性''':掩码模式在训练前固定,Glow 的可逆 <math>1\times1</math> 卷积通过学习置换提供了更灵活的分区<ref name="Glow2018">{{cite journal|author1=Kingma D. P.|author2=Dhariwal P.|title=Glow: Generative Flow with Invertible 1×1 Convolutions|journal=NeurIPS|year=2018}}</ref>。
| |
| − |
| |
| − | == 与相关框架的关系 ==
| |
| − |
| |
| − | RealNVP 在标准化流的发展中处于承上启下的位置:
| |
| − |
| |
| − | '''前驱工作'''
| |
| − |
| |
| − | {| class="wikitable"
| |
| − | |-
| |
| − | ! 方法 !! 年份 !! 核心贡献 !! 与 RealNVP 的关系
| |
| − | |-
| |
| − | | '''NICE'''<ref name="NICE2014" /> || 2014 || 加性耦合层 || RealNVP 的直接前身,将加性耦合扩展为仿射耦合
| |
| − | |-
| |
| − | | '''Rezende & Mohamed NFs'''<ref name="Rezende2015">{{cite journal|author1=Rezende D. J.|author2=Mohamed S.|title=Variational Inference with Normalizing Flows|journal=ICML|year=2015}}</ref> || 2015 || 标准化流术语 + 平面流/径向流 || 提供了变分推断中标准化流的理论框架
| |
| − | |}
| |
| − |
| |
| − | '''后继发展'''
| |
| − |
| |
| − | {| class="wikitable"
| |
| − | |-
| |
| − | ! 方法 !! 年份 !! 核心创新 !! 与 RealNVP 的对比
| |
| − | |-
| |
| − | | '''MAF'''<ref name="MAF2017">{{cite journal|author1=Papamakarios G.|author2=Pavlakou T.|author3=Murray I.|title=Masked Autoregressive Flow for Density Estimation|journal=NIPS|year=2017}}</ref> || 2017 || 全自回归条件 || 密度评估更灵活,但采样需顺序进行
| |
| − | |-
| |
| − | | '''Glow'''<ref name="Glow2018" /> || 2018 || 可逆 1×1 卷积 + actnorm || 刷新了图像生成基准
| |
| − | |-
| |
| − | | '''FFJORD'''<ref name="FFJORD2019">{{cite journal|author1=Grathwohl W.|author2=Chen R. T. Q.|author3=Bettencourt J.|author4=Sutskever I.|author5=Duvenaud D.|title=FFJORD: Free-form Continuous Dynamics for Scalable Reversible Generative Models|journal=ICLR|year=2019}}</ref> || 2019 || 连续时间流 + ODE 描述 || 消除架构约束,但需数值积分
| |
| − | |-
| |
| − | | '''Flow++'''<ref name="FlowPlusPlus2019" /> || 2019 || 变分去量化 + Logistic 混合 CDF 耦合 || 改进 RealNVP 在密度估计、去量化和耦合函数上的短板
| |
| − | |-
| |
| − | | '''Residual Flows'''<ref name="ResidualFlows2019">{{cite journal|author1=Chen R. T. Q.|author2=Behrmann J.|author3=Duvenaud D.|author4=Jacobsen J.-H.|title=Residual Flows for Invertible Generative Modeling|journal=NeurIPS|year=2019}}</ref> || 2019 || 无偏行列式估计 || 将残差网络引入可逆建模
| |
| − | |}
| |
| − |
| |
| − | '''理论分析'''
| |
| − |
| |
| − | * '''Draxler et al.'''(ICML 2024)<ref name="Draxler2024" />:证明耦合型标准化流(含 RealNVP)在良好条件下是分布普适的;体积保持流则不是,说明 NICE 存在理论局限。
| |
| − |
| |
| − | <!-- 图7:标准化流发展谱系简图 -->
| |
| − |
| |
| − | = 应用 =
| |
| − |
| |
| − | == 自然图像密度估计与生成 ==
| |
| − |
| |
| − | RealNVP 在多个图像基准上验证了其密度估计与生成性能:
| |
| − |
| |
| − | {| class="wikitable"
| |
| − | |-
| |
| − | ! 数据集 !! 分辨率 !! 测试对数似然(bits/dim) !! 关键发现
| |
| − | |-
| |
| − | | CIFAR-10 || <math>32 \times 32</math> || 3.49 || 生成样本全局连贯,优于 VAE
| |
| − | |-
| |
| − | | ImageNet || <math>32 \times 32</math> || 4.28 || 有效建模大规模自然图像分布
| |
| − | |-
| |
| − | | ImageNet || <math>64 \times 64</math> || 3.98 || 能捕捉前景/背景分割与光照一致性
| |
| − | |-
| |
| − | | LSUN(卧室/塔楼/教堂) || <math>64 \times 64</math> || — || 建模了室内外场景的语义结构
| |
| − | |-
| |
| − | | CelebA || <math>64 \times 64</math> || — || 潜在空间具有可解释的语义方向
| |
| − | |}
| |
| − |
| |
| − | 与 VAE 相比,RealNVP 不依赖固定的重建损失(如 MSE),避免了过度平滑高频细节;与自回归模型(如 PixelRNN)相比,RealNVP 的采样在维度上完全并行,速度更快。
| |
| − |
| |
| − | <!-- 图5:CelebA 生成样本与真实样本对比 -->
| |
| − |
| |
| − | == 潜在空间插值与语义操控 ==
| |
| − |
| |
| − | RealNVP 的潜在空间具有可解释的语义结构。给定四个样本的编码 <math>\mathbf{z}^{(1)}, \dots, \mathbf{z}^{(4)}</math>,可在潜在空间中做球面插值:
| |
| − |
| |
| − | <math>
| |
| − | \mathbf{z}(\phi, \phi') = \cos\phi\,(\cos\phi'\,\mathbf{z}^{(1)} + \sin\phi'\,\mathbf{z}^{(2)}) + \sin\phi\,(\cos\phi'\,\mathbf{z}^{(3)} + \sin\phi'\,\mathbf{z}^{(4)})
| |
| − | </math>
| |
| − |
| |
| − | 解码后能看到姿态、表情、背景等属性的平滑过渡,而非简单的像素混合。在 CelebA 的类条件模型中,沿着特定方向移动潜在编码可系统性地操控性别、眼镜、微笑等属性,表明该空间具有类似词向量的线性语义结构。
| |
| − |
| |
| − | == 重建设置中的推断 ==
| |
| − |
| |
| − | 由于编码器 <math>f</math> 与解码器 <math>g</math> 互为逆映射(<math>\mathbf{x} = g(f(\mathbf{x}))</math>),RealNVP 适合图像修复、去噪、着色等任务。以图像修复为例:已知像素 <math>\mathbf{x}_O</math> 固定,对缺失像素 <math>\mathbf{x}_H</math> 用梯度上升最大化 <math>\log p_X(\mathbf{x}_O, \mathbf{x}_H)</math>,并加入少量高斯噪声扰动:
| |
| − |
| |
| − | <math>
| |
| − | \mathbf{x}_{H}^{(t+1)} = \mathbf{x}_{H}^{(t)} + \alpha_t \left(\frac{\partial \log p_X(\mathbf{x}_O, \mathbf{x}_{H}^{(t)})}{\partial \mathbf{x}_H} + \boldsymbol{\epsilon}\right)
| |
| − | </math>
| |
| − |
| |
| − | 由于模型学习了全数据分布的精确密度,它能对任意形状的掩码产生合理的语义补全,而非仅记忆特定训练掩码。
| |
| − |
| |
| − | == 在 NIS/NIS+ 因果涌现框架中的应用 ==
| |
| − |
| |
| − | 在 [[NIS]](神经信息挤压器)及 [[NIS+]] 中,RealNVP 被用作可逆编码器(INN),粗粒化策略被建模为两阶段过程:
| |
| − |
| |
| − | # '''无损变换''':由 RealNVP 耦合层堆叠构成的可逆神经网络(INN)<math>\psi_\alpha: \mathbb{R}^p \to \mathbb{R}^p</math> 将微观状态 <math>\mathbf{x}_t</math> 映射到等维潜在空间 <math>\mathbf{x}'_t</math>。'''该阶段信息不丢失'''。
| |
| − | # '''信息丢弃''':投影算子 <math>\chi_{p,q}</math> 丢弃 <math>p-q</math> 个维度,得到宏观状态 <math>\mathbf{y}_t = \chi_{p,q}(\psi_\alpha(\mathbf{x}_t))</math>。
| |
| − |
| |
| − | 解码时,将宏观预测 <math>\hat{\mathbf{y}}_{t+1}</math> 与 <math>p-q</math> 维标准高斯噪声拼接,通过逆 INN <math>\psi_\alpha^{-1}</math> 重构微观状态。由于 RealNVP 的编码器与解码器只是方向反转,'''参数完全共享''',模型参数量直接减半。
| |
| − |
| |
| − | <!-- 图6:NIS 框架中 RealNVP 作为 INN 的位置示意图 -->
| |
| − |
| |
| − | NIS 论文给出选用 RealNVP 的三点依据<ref name="NIS2022">{{cite journal|author1=Zhang J.|author2=Liu K.|title=Neural Information Squeezer for Causal Emergence|journal=Entropy|year=2022|volume=25|issue=1|page=26}}</ref>:
| |
| − | # '''精确可逆性''':微观到潜在的变换不损失信息,信息丢弃量 <math>p-q</math> 成为显式可控的超参数。
| |
| − | # '''参数共享''':<math>\psi_\alpha</math> 与 <math>\psi_\alpha^{-1}</math> 共用一套参数,显著压缩模型规模。
| |
| − | # '''行列式可解析''':三角雅可比结构使有效信息(EI)上界和最优宏观维度 <math>q</math> 的存在性等核心定理得以严格推导。
| |
| − |
| |
| − | 消融实验表明,若将 RealNVP 替换为普通前馈网络或 VAE,多步预测误差显著上升;在分布外泛化测试中,仅基于 RealNVP 的 NIS/NIS+ 保持了低误差。论文指出:'''可逆神经网络作为编码器和解码器是必需的'''。在 NIS+ 中,RealNVP 继续承担编码–解码功能,而 EI 最大化等改进发生在投影后的宏观动力学空间上,不改动 INN 模块本身<ref name="NISPlus2025">{{cite journal|author1=Yang M.|author2=Wang Z.|author3=Liu K.|author4=Rong Y.|author5=Yuan B.|author6=Zhang J.|title=Finding Emergence in Data by Maximizing Effective Information|journal=National Science Review|year=2025|volume=12|issue=1|page=nwae279}}</ref>。
| |
| − |
| |
| − | = 参考文献 =
| |
| − |
| |
| − | # Dinh L., Sohl-Dickstein J., Bengio S. Density Estimation Using Real NVP. International Conference on Learning Representations (ICLR), 2017. https://arxiv.org/abs/1605.08803
| |
| − | # Chen S. S., Gopinath R. A. Gaussianization. Advances in Neural Information Processing Systems (NIPS), 2000.
| |
| − | # Tabak E. G., Vanden-Eijnden E. Density Estimation by Dual Ascent of the Log-Likelihood. Communications in Mathematical Sciences, 2010, 8(1): 217-233.
| |
| − | # Dinh L., Krueger D., Bengio Y. NICE: Non-linear Independent Components Estimation. ICLR 2015 Workshop, 2014. https://arxiv.org/abs/1410.8516
| |
| − | # Draxler F., Wahl S., Schnörr C., Köthe U. On the Universality of Volume-Preserving and Coupling-Based Normalizing Flows. Proceedings of the 41st International Conference on Machine Learning (ICML), PMLR 235, 2024.
| |
| − | # Ho J., Chen X., Srinivas A., Duan Y., Abbeel P. Flow++: Improving Flow-Based Generative Models with Variational Dequantization and Architecture Design. ICML, 2019.
| |
| − | # Kingma D. P., Dhariwal P. Glow: Generative Flow with Invertible 1×1 Convolutions. NeurIPS, 2018.
| |
| − | # Rezende D. J., Mohamed S. Variational Inference with Normalizing Flows. ICML, 2015.
| |
| − | # Papamakarios G., Pavlakou T., Murray I. Masked Autoregressive Flow for Density Estimation. NIPS, 2017.
| |
| − | # Grathwohl W., Chen R. T. Q., Bettencourt J., Sutskever I., Duvenaud D. FFJORD: Free-form Continuous Dynamics for Scalable Reversible Generative Models. ICLR, 2019.
| |
| − | # Chen R. T. Q., Behrmann J., Duvenaud D., Jacobsen J.-H. Residual Flows for Invertible Generative Modeling. NeurIPS, 2019.
| |
| − | # Papamakarios G., Nalisnick E., Rezende D. J., Mohamed S., Lakshminarayanan B. Normalizing Flows for Probabilistic Modeling and Inference. Journal of Machine Learning Research, 2021, 22(57): 1-64.
| |
| − | # Zhang J., Liu K. Neural Information Squeezer for Causal Emergence. Entropy, 2022, 25(1): 26.
| |
| − | # Yang M., Wang Z., Liu K., Rong Y., Yuan B., Zhang J. Finding Emergence in Data by Maximizing Effective Information. National Science Review, 2025, 12(1): nwae279.
| |
| − |
| |
| − | = 署名 =
| |
| − |
| |
| − | 本词条由 [编写者姓名] 编写,[审阅者姓名] 审阅,[日期] 发布。
| |
| − |
| |
| − | '''贡献者''':集智百科团队
| |
| − | <references />
| |