Step 1
\[
\alpha_t=1-\beta_t,\quad \bar{\alpha}_t=\prod_{s=1}^{t}\alpha_s,\quad q(x_t|x_0)=\mathcal{N}(\sqrt{\bar{\alpha}_t}x_0,(1-\bar{\alpha}_t)I).
\](DDPM-2)
前向链是高斯马尔可夫链,因此任意 t 可闭式采样。
本步使用 Gaussian composition:每一步都是线性高斯变换,多步叠加后仍是高斯。于是 \(x_t\) 可以直接从 \(x_0\) 和一个标准高斯噪声构造,不必真的模拟 \(1\) 到 \(t\) 的完整加噪链。
Step 2
\[
x_t=\sqrt{\bar{\alpha}_t}x_0+\sqrt{1-\bar{\alpha}_t}\epsilon,\quad \epsilon\sim\mathcal{N}(0,I).
\](DDPM-3)
训练无需逐步运行前向链。
本步使用 reparameterization:随机性来自外部 \(\epsilon\sim\mathcal{N}(0,I)\),\(x_t\) 是 \(x_0,t,\epsilon\) 的确定函数。这让训练可以随机抽一个时间步、直接构造噪声样本并反向传播。
Step 3
\[
q(x_{t-1}|x_t,x_0)=\mathcal{N}(\tilde{\mu}_t(x_t,x_0),\tilde{\beta}_t I).
\](DDPM-4)
前向过程固定,所以 posterior 可解析。
本步使用 Gaussian posterior identity:\(q(x_t|x_{t-1})\) 和 \(q(x_{t-1}|x_0)\) 都是线性高斯,条件化到 \(x_t,x_0\) 后仍是高斯。这个解析 posterior 是反向模型要逼近的老师。
Step 4
\[
\tilde{\mu}_t=\frac{\sqrt{\bar{\alpha}_{t-1}}\beta_t}{1-\bar{\alpha}_t}x_0+\frac{\sqrt{\alpha_t}(1-\bar{\alpha}_{t-1})}{1-\bar{\alpha}_t}x_t,\quad \tilde{\beta}_t=\frac{1-\bar{\alpha}_{t-1}}{1-\bar{\alpha}_t}\beta_t.
\](DDPM-5)
反向模型学习逼近这个 posterior 的 mean/variance。
本步使用 Gaussian conditioning:解析 posterior 的均值由 \(x_t\) 和 \(x_0\) 的线性组合给出。采样时 \(x_0\) 不可知,因此网络通过预测噪声或 \(\hat{x}_0\) 来间接构造反向均值。
Step 5
\[
L_{t-1}=D_{KL}\left(q(x_{t-1}|x_t,x_0)\Vert p_\theta(x_{t-1}|x_t,c)\right).
\](DDPM-6)
DDPM ELBO 的核心项是每一步 posterior matching。
本步使用 variational bound:真实反向链不可直接最大似然,于是用固定前向链构造下界。下界中的主要训练项,是让 \(p_\theta(x_{t-1}|x_t,c)\) 匹配解析 posterior \(q(x_{t-1}|x_t,x_0)\)。
Step 6
\[
\mathcal{J}_{simple}=\mathbb{E}_{x_0\sim p_{\mathrm{data}},\epsilon\sim\mathcal{N}(0,I),t}\left\|\epsilon-\epsilon_\theta(x_t,t,c)\right\|_2^2.
\](DDPM-7)
实践中常用噪声预测简化目标。
本步把固定方差 Gaussian KL 化简为 MSE:若方差日程固定,posterior matching 的主要差异落在均值;均值又可由噪声 \(\epsilon\) 参数化,所以训练常写成预测真实噪声的平方误差。
Step 7
\[
\hat{x}_0=\frac{x_t-\sqrt{1-\bar{\alpha}_t}\epsilon_\theta(x_t,t,c)}{\sqrt{\bar{\alpha}_t}},\quad s_\theta(x_t,t)\approx-\frac{\epsilon_\theta(x_t,t)}{\sqrt{1-\bar{\alpha}_t}}.
\](DDPM-8)
epsilon、x0、score 是同一反向信息的不同参数化。
本步使用 DDPM 参数化关系:若 \(x_t=\sqrt{\bar{\alpha}_t}x_0+\sqrt{1-\bar{\alpha}_t}\epsilon\),最优噪声预测满足 \(\epsilon^*(x_t,t)=-\sqrt{1-\bar{\alpha}_t}\nabla_{x_t}\log p_t(x_t)\)。所以 \(\epsilon\)-prediction 与 score prediction 只差一个时间相关尺度;\(\hat{x}_0\) 则由同一个 score 通过 Tweedie identity 还原。
Step 8
\[
v=\sqrt{\bar{\alpha}_t}\epsilon-\sqrt{1-\bar{\alpha}_t}x_0.
\](DDPM-9)
v-parameterization 改善不同噪声等级的数值平衡。
本步使用 signal/noise rotation:\(v\) 可以看成在 \(x_0\) 与 \(\epsilon\) 之间旋转后的目标,使高噪声和低噪声时间步的尺度更平衡,常有利于稳定训练和少步采样。