【理论推导】随机微分方程(SDE)视角下的Diffusion Model与Score-based Model

文章介绍了扩散模型DDPM(去噪扩散潜变量模型)与随机微分方程(SDE)的关联,展示了DDPM如何通过离散迭代逼近SDE的形式。在DDPM中,正向过程是逐步添加噪声,逆过程则通过SDE描述。NCSN(噪声对比估计网络)对应的是VarianceExplodingSDE,而DDPM对应VariancePreservingSDE。两者都利用SDE来建模数据生成的过程,DDPM的去噪器可以通过祖先采样解决SDE方程,而NCSN则依赖Langevin动力学进行迭代优化。

SDE与DDPM

以 DDPM 为例,DDPM的通项公式为
x t ∼ N ( α ‾ t x 0 , ( 1 − α ‾ t ) I ) x_t \sim \mathcal N(\sqrt{\overline{\alpha}_t}x_0, (1-\overline{\alpha}_t) I) xtN(αt x0,(1αt)I)
当我们固定 t t t 的取值时, x t x_t xt 是定义在样本空间上的函数,即为一随机变量,当我们固定 x x x的随机性时,即为关于变量 t t t 的一个函数,因此 x t x_t xt 是一随机过程,而对于一组确定的 { x t } t = 0 T \{x_t\}_{t=0}^T { xt}t=0T,称为随机过程的一个实现,或是一条轨迹/轨道,而随机过程可以使用随机微分方程(Stochastic Differential Equation)进行描述

SDE定义为
d X t = b ( t , X t ) d t + σ ( t , X t ) d B t dX_t = b(t,X_t)dt + \sigma(t,X_t)dB_t dXt=b(t,Xt)dt+σ(t,Xt)dBt
其中 B t B_t Bt 表示布朗运动,此方程的解称为伊藤(Itô)过程或是扩散过程。如果我们将 DDPM的迭代式从离散扩展到连续区间,即 x t → x t + Δ t      ( Δ t → 0 ) x_t\rightarrow x_{t+\Delta t}\;\;(\Delta t\rightarrow 0) xtxt+Δt(Δt0),即可得到SDE形式的扩散过程,论文中表示为
d x = f ( x , t ) d t + g ( t ) d w dx = f(x,t)dt + g(t)dw dx=f(x,t)dt+g(t)dw
其中 w w w 表示一个标准布朗运动, f ( ⋅ , t ) f(\cdot,t) f(,t) 称作是漂移系数 (drift coefficient),描述了确定性的变化过程, g ( ⋅ ) g(\cdot) g() 称作是扩散系数 (diffusion coefficient),描述了不确定的变化过程

SDE视角下的生成模型

SDE的离散形式表示如下所示
x t + Δ t − x t = f ( x , t ) Δ t + g ( t ) Δ t ε x_{t+\Delta_t}-x_t = f(x,t)\Delta t + g(t)\sqrt{\Delta t} \varepsilon xt+Δtxt=f(x,t)Δt+g(t)Δt ε
其中 ε ∼ N ( 0 , I ) \varepsilon \sim \mathcal N(0,I) εN(0,I),因此有条件概率分布
x t + Δ t ∣ x t ∼ N ( x t + f ( x t , t ) Δ t , g 2 ( t ) Δ t I ) x_{t+\Delta_t}|x_t \sim \mathcal N(x_t+f(x_t,t)\Delta t, g^2(t)\Delta t I) xt+ΔtxtN(xt+f(xt,t)Δt,g2(t)ΔtI)
考虑逆过程 x t ∣ x t + Δ t x_t|x_{t+\Delta t} xtxt+Δt,有
p ( x t ∣ x t + Δ t ) = p ( x t + Δ t ∣ x t ) p ( x t ) p ( x t + Δ t ) = p ( x t + Δ t ∣ x t ) exp ⁡ ( log ⁡ p ( x t ) − log ⁡ p ( x t + Δ t ) ) ≈ p ( x t + Δ t ∣ x t ) exp ⁡ { − ( x t + Δ t − x t ) ▽ x t log ⁡ p ( x t ) − Δ t ∂ ∂ t log ⁡ p ( x t ) } ∝ exp ⁡ { − ∣ ∣ x t + Δ t − x t − f ( x t , t ) Δ t ∣ ∣ 2 2 2 g 2 ( t ) Δ t − ( x t + Δ t − x t ) ▽ x t log ⁡ p ( x t ) − Δ t ∂ ∂ t log ⁡ p ( x t ) } = exp ⁡ { − 1 2 g 2 ( t ) Δ t ∣ ∣ ( x t + Δ t − x t ) − ( f ( x t , t ) − g 2 ( t ) ▽ x t log ⁡ p ( x t ) ) Δ t ∣ ∣ 2 2 − Δ t ∂ ∂ t log ⁡ p ( x t ) − f 2 ( x t , t ) Δ t 2 g 2 ( t ) + ( f ( x t , t ) − g 2 ( t ) ▽ x t log ⁡ p ( x t ) ) 2 Δ t 2 g 2 ( t ) } = Δ t → 0 exp ⁡ { − 1 2 g 2 ( t + Δ t ) Δ t ∣ ∣ ( x t + Δ t − x t ) − ( f ( x t + Δ t , t + Δ t ) − g 2 ( t + Δ t ) ▽ x t + Δ t log ⁡ p ( x t + Δ t ) ) Δ t ∣ ∣ 2 2 } \begin{align} p(x_t|x_{t+\Delta t}) &= \frac{p(x_{t+\Delta t}|x_t)p(x_t)}{p(x_{t+\Delta t})} \nonumber \\&= p(x_{t+\Delta t}|x_t)\exp(\log p(x_t)-\log p(x_{t+\Delta t})) \nonumber \\&\approx p(x_{t+\Delta t}|x_t)\exp \{ - (x_{t+\Delta t}-x_t)\triangledown_{x_t} \log p(x_t)-\Delta t \frac{\partial }{\partial t}\log p(x_{t})\} \nonumber \\&\propto \exp \{-\frac{||x_{t+\Delta t}-x_t - f(x_t,t)\Delta t||_2^2}{2g^2(t)\Delta t} - (x_{t+\Delta t} - x_t)\triangledown_{x_t}\log p(x_t)- \Delta t \frac{\partial }{\partial t}\log p(x_t)\} \nonumber \\&= \exp \left\{ -\frac{1}{2g^2(t)\Delta t}||(x_{t+\Delta t}-x_t)-(f(x_t,t)-g^2(t)\triangledown_{x_t}\log p(x_t))\Delta t||_2^2 -\Delta t \frac{\partial }{\partial t}\log p(x_t) - \frac{f^2(x_t,t)\Delta t}{2g^2(t)} + \frac{(f(x_t,t)-g^2(t)\triangledown_{x_t}\log p(x_t))^2\Delta t}{2g^2(t)} \right\} \nonumber \\&\overset{\Delta t\rightarrow 0}{=} \exp \left\{ -\frac{1}{2g^2(t+\Delta t)\Delta t}||(x_{t+\Delta t}-x_t)-(f(x_{t+\Delta t},t+\Delta t)-g^2(t+\Delta t)\triangledown_{x_{t+\Delta t}}\log p(x_{t+\Delta t}))\Delta t||_2^2 \right \} \nonumber \end{align} p(xtxt+Δt)=p(xt+Δt)</

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值