扩散模型经典改进:Improved Denoising Diffusion Probabilistic Models

这个文章是关于论文《Improved Denoising Diffusion Probabilistic Models》的论文解读。


Improving the Log-likelihood

In this paper, we show that DDPMs can achieve loglikelihoods competitive with other likelihood-based models, even on high-diversity datasets like ImageNet.

写作动机就是:虽然发现DDPMs可以根据FID和Inception Score生成高保真度的样本,但是这些模型无法实现具有竞争力的对数似然。

对数似然是生成式建模中广泛使用的度量,一般认为优化对数似然迫使生成式模型捕获数据分布的所有模式。

所以这个工作的目的就是提高扩散模型的对数似然

0 提高T

作者发现将T加到4000可以提升对数似然,本节中剩余部分都是使用 <math xmlns="http://www.w3.org/1998/Math/MathML"> T = 4000 T=4000 </math>T=4000

1 Learning <math xmlns="http://www.w3.org/1998/Math/MathML"> Σ θ ( x t , t ) Σ_θ(x_t, t) </math>Σθ(xt,t)

起初 <math xmlns="http://www.w3.org/1998/Math/MathML"> β ~ t \tilde{\beta}_t </math>β~t非常小,随着扩散步数的增加, <math xmlns="http://www.w3.org/1998/Math/MathML"> β t β_t </math>βt和 <math xmlns="http://www.w3.org/1998/Math/MathML"> β ~ t \tilde{\beta}_t </math>β~t几乎相等。 表明,随着扩散步骤增加 <math xmlns="http://www.w3.org/1998/Math/MathML"> σ t σ_t </math>σt的选择对样本质量可能根本无关紧要。也就是说,随着我们增加更多的扩散步长,模型均值 <math xmlns="http://www.w3.org/1998/Math/MathML"> μ θ ( x t , t ) μ_θ ( x_t , t) </math>μθ(xt,t)比 <math xmlns="http://www.w3.org/1998/Math/MathML"> Σ θ ( x t , t ) Σ_θ ( x_t , t) </math>Σθ(xt,t)更能决定分布。

图2表明扩散过程的前几步对变分下界的贡献最大。因此,似乎可以通过更好地选择 <math xmlns="http://www.w3.org/1998/Math/MathML"> Σ θ ( x t , t ) Σ_θ ( x_t , t) </math>Σθ(xt,t)来提高对数似然值。

对数域内将方差参数化为 <math xmlns="http://www.w3.org/1998/Math/MathML"> β t {\beta}_t </math>βt和 <math xmlns="http://www.w3.org/1998/Math/MathML"> β ~ t \tilde{\beta}t </math>β~t之间的插值更好。 模型输出一个每维包含一个分量的向量 <math xmlns="http://www.w3.org/1998/Math/MathML"> v v </math>v,我们将这个输出转化为方差如下: <math xmlns="http://www.w3.org/1998/Math/MathML"> Σ θ ( x t , t ) = exp ⁡ ( v log ⁡ β t + ( 1 − v ) log ⁡ β ~ t ) \Sigma\theta\left(x_t, t\right)=\exp \left(v \log \beta_t+(1-v) \log \tilde{\beta}_t\right) </math>Σθ(xt,t)=exp(vlogβt+(1−v)logβ~t)

Since <math xmlns="http://www.w3.org/1998/Math/MathML"> L simple L_{\text {simple }} </math>Lsimple doesn't depend on <math xmlns="http://www.w3.org/1998/Math/MathML"> Σ θ ( x t , t ) \Sigma_\theta\left(x_t, t\right) </math>Σθ(xt,t), we define a new hybrid objective: <math xmlns="http://www.w3.org/1998/Math/MathML"> L hybrid = L simple + λ L v l b L_{\text {hybrid }}=L_{\text {simple }}+\lambda L_{\mathrm{vlb}} </math>Lhybrid =Lsimple +λLvlb

2 Improving the Noise Schedule

线性噪声调度对高分辨率图像效果较好,但对于分辨率为64 × 64和32 × 32的图像效果欠佳。并且在这些分辨率下,前向加噪过程的末尾噪声太大,因此对样本质量的贡献不大。

图四:反向过程跳步达到20%的时候对FID也不会有什么明显影响。

综上,本文 <math xmlns="http://www.w3.org/1998/Math/MathML"> α t α_t </math>αt构造了一个不同的噪声调度: <math xmlns="http://www.w3.org/1998/Math/MathML"> α ˉ t = f ( t ) f ( 0 ) , f ( t ) = cos ⁡ ( t / T + s 1 + s ⋅ π 2 ) 2 \bar{\alpha}_t=\frac{f(t)}{f(0)}, \quad f(t)=\cos \left(\frac{t / T+s}{1+s} \cdot \frac{\pi}{2}\right)^2 </math>αˉt=f(0)f(t),f(t)=cos(1+st/T+s⋅2π)2 <math xmlns="http://www.w3.org/1998/Math/MathML"> β t = 1 − α ˉ t α ˉ t − 1 \beta_t=1-\frac{\bar{\alpha}t}{\bar{\alpha}{t-1}} </math>βt=1−αˉt−1αˉt 限制 <math xmlns="http://www.w3.org/1998/Math/MathML"> β t ≤ 0.999 β_t\leq0.999 </math>βt≤0.999,以防止在扩散过程接近 <math xmlns="http://www.w3.org/1998/Math/MathML"> t = T t = T </math>t=T时出现奇怪现象。

图5可以看出,线性方差表更快地将图片破坏为噪声,但是cos方差表在 <math xmlns="http://www.w3.org/1998/Math/MathML"> t = 0 t=0 </math>t=0 和 <math xmlns="http://www.w3.org/1998/Math/MathML"> t = T t=T </math>t=T 附近变化很小,以防止噪声水平的突然变化。

开始时噪声太小会让网络难以准确地预测 <math xmlns="http://www.w3.org/1998/Math/MathML"> ϵ \epsilon </math>ϵ,因此使用一个小的偏移量 <math xmlns="http://www.w3.org/1998/Math/MathML"> s = 0.008 s = 0.008 </math>s=0.008,以防止在 <math xmlns="http://www.w3.org/1998/Math/MathML"> t = 0 t=0 </math>t=0 附近 <math xmlns="http://www.w3.org/1998/Math/MathML"> β t β_t </math>βt太小。

用 <math xmlns="http://www.w3.org/1998/Math/MathML"> c o s 2 cos^2 </math>cos2纯属巧合,作者想要一个两端平滑中间线性下降的函数,换成别的能work也可以。

3 Reducing Gradient Noise

理论上直接优化 <math xmlns="http://www.w3.org/1998/Math/MathML"> L v l b L_{vlb} </math>Lvlb 可以获得更好地对数似然。但是下图可以看到,实际中 <math xmlns="http://www.w3.org/1998/Math/MathML"> L v l b L_{vlb} </math>Lvlb很难优化,甚至 <math xmlns="http://www.w3.org/1998/Math/MathML"> L h y v r i d L_{hyvrid} </math>Lhyvrid获得更好的对数似然。但是他们俩噪声都很大。

直接优化 <math xmlns="http://www.w3.org/1998/Math/MathML"> L v l b L_{vlb} </math>Lvlb,但是要寻找一种降低其方差的方法。因为图2中不同项差的量级很大,作者猜测是因为时间步均匀采样导致的梯度噪声大,所以提出了重要性采样的方法: <math xmlns="http://www.w3.org/1998/Math/MathML"> L v l b = E t ∼ p t [ L t p t ] , where p t ∝ E [ L t 2 ] and ∑ p t = 1 L_{\mathrm{vlb}}=E_{t \sim p_t}\left[\frac{L_t}{p_t}\right] \text {, where } p_t \propto \sqrt{E\left[L_t^2\right]} \text { and } \sum p_t=1 </math>Lvlb=Et∼pt[ptLt], where pt∝E[Lt2] and ∑pt=1

由于 <math xmlns="http://www.w3.org/1998/Math/MathML"> E [ L t 2 ] E[L_t^2] </math>E[Lt2] 无法获取准确值, 所以保存每个时间步前 10 次的损失求平均来估计, 这样损失越大的时间步采样频率越低, 从而整体上可以保证损失的稳定性。

使用重要性采样单独训练 <math xmlns="http://www.w3.org/1998/Math/MathML"> L v l b L_{vlb} </math>Lvlb 确实有效,损失也更稳定了。 直接训练 <math xmlns="http://www.w3.org/1998/Math/MathML"> L h y b r i d L_{hybrid} </math>Lhybrid 的损失也可以降到和使用重要性采样的 <math xmlns="http://www.w3.org/1998/Math/MathML"> L v l b L_{vlb} </math>Lvlb 差不多, 损失曲线稍微不稳定一点,所以可以自由选择。

(来自 其他4

个人觉得第二句话有问题。重要性采样对于 <math xmlns="http://www.w3.org/1998/Math/MathML"> L v l b L_{vlb} </math>Lvlb 确实有效,但是对于 <math xmlns="http://www.w3.org/1998/Math/MathML"> L h y b r i d L_{hybrid} </math>Lhybrid原文只提到:

We found that the importance sampling technique was not helpful when optimizing the less-noisy Lhybrid objective directly.

就是对噪声较小的混合目标进行优化时候没有用。

但是对噪声大的地方应该也是有用的,所以重要性采样对 <math xmlns="http://www.w3.org/1998/Math/MathML"> L h y b r i d L_{hybrid} </math>Lhybrid也是有效的.

所以训练的时候可以使用 <math xmlns="http://www.w3.org/1998/Math/MathML"> L h y b r i d L_{hybrid} </math>Lhybrid或者 <math xmlns="http://www.w3.org/1998/Math/MathML"> L v l b L_{vlb} </math>Lvlb。

Improving Sampling Speed

we evaluate FIDs for an <math xmlns="http://www.w3.org/1998/Math/MathML"> L h y b r i d L_{hybrid} </math>Lhybrid model and an <math xmlns="http://www.w3.org/1998/Math/MathML"> L s i m p l e L_{simple} </math>Lsimple model that were trained with 4000 steps, using 25, 50, 100, 200, 400, 1000, and 4000 sampling steps.

<math xmlns="http://www.w3.org/1998/Math/MathML"> L h y b r i d L_{hybrid} </math>Lhybrid model with learnt sigmas maintains high sample quality. With this model, 100 sampling steps is sufficient to achieve near-optimal FIDs for our fully trained models.

其他

相关推荐
小羊在奋斗21 分钟前
【C++】探秘二叉搜索树
c++·人工智能·神经网络·机器学习
爱数模的小云38 分钟前
【华为杯】2024华为杯数模研赛E题 解题思路
算法·华为
白葵新40 分钟前
PCL addLine可视化K近邻
c++·人工智能·算法·计算机视觉·3d
seanli10081 小时前
线性dp 总结&详解
算法·动态规划
小丁爱养花1 小时前
记忆化搜索专题——算法简介&力扣实战应用
java·开发语言·算法·leetcode·深度优先
Faris_yzf1 小时前
物联网LoRa定位技术详解
科技·算法
Crossoads1 小时前
【数据结构】排序算法---快速排序
c语言·开发语言·数据结构·算法·排序算法
DS数模1 小时前
2024华为杯研赛E题保姆级教程思路分析
算法·数学建模·华为·华为杯数学建模·2024华为杯·2024研赛
眰恦3741 小时前
数据结构--第五章树与二叉树
数据结构·算法
鸽芷咕2 小时前
【Python报错已解决】ModuleNotFoundError: No module named ‘tensorflow‘
python·机器学习·tensorflow·bug·neo4j