《Common Diffusion Noise Schedules and Sample Steps are Flawed》总结

这篇文章认为现有的diffusion noise schedules和sample steps有两个比较大的问题:

  1. noise scheduler没有保证在最后一个timestep时,信噪比为0。这样会导致模型在训练时sample的均值等低频信息被泄露给网络,但在推理时指定均值为0的高斯噪声,导致推理时无法生成很亮或很暗的图。
  2. DDIM等采样的step没有从最后一个timestep开始,进一步加剧了上述问题。

推理

Diffusion基础

预先定义扩散率βt\beta_t,令αt=1−βt\alpha_t=1-\beta_t,αˉt=∏i=1Tαi\bar{\alpha}_t = \prod_{i=1}^T \alpha_i

有 q(xt∣x0)=N(xt;αˉtx0,(1−αˉt)I)q(\mathbf{x}_t \vert \mathbf{x}_0) = \mathcal{N}(\mathbf{x}_t; \sqrt{\bar{\alpha}_t} \mathbf{x}_0, (1-\bar{\alpha}_t)\mathbf{I}) 即 xt=αtˉx0+1−αtˉϵx_t=\sqrt{\bar{\alpha_t}}x_0+\sqrt{1-\bar{\alpha_t}}\epsilon

则定义信噪比SNR可以被定义为: SNR(t)=αˉ1−αˉSNR(t)=\frac{\bar{\alpha}}{1-\bar{\alpha}}

现有的几种常见方案

Stable Diffusion使用的这种β\beta Schedule,在最后t=1000的时刻,x1000=0.068265x0+0.997667ϵx_{1000}=0.068265x_0+0.997667\epsilon

其中Stable Diffusion的Schedule的这个问题比较严重,因为最后一步大概有7%的信号是sample,而不是噪声。但cosine schedule很低,可以忽略。

论文提出的解决方案

调整schedule

对于Stable Diffusion这样的schedule,可以定义α1000ˉ\sqrt{\bar{\alpha_{1000}}}为0,α0ˉ\sqrt{\bar{\alpha_{0}}}维持原值,然后响应地线性放缩中间值:

alphas_bar_sqrt -= alphas_bar_sqrt_T
alphas_bar_sqrt *= alphas_bar_sqrt_0 / (alphas_bar_sqrt_0 - alphas_bar_sqrt_T)

更换训练target

在保证Zero SNR之后,t=Tt=T时刻的网络输入是纯噪声,依然要求网络预测ϵ\epsilon即噪声,已经没什么意义了。因此,应该切换成v-prediction模式,即预测vt=αˉϵ−1−αˉx0v_t=\sqrt{\bar{\alpha}}\epsilon-\sqrt{1-\bar{\alpha}}x_0

论文链接:Common Diffusion Noise Schedules and Sample Steps are Flawed