Denoising Diffusion Implicit Models | AGIDaily
AGI Daily
资讯日报词条论文人物新创
返回论文列表
摘要1 引言2 背景3 非马尔可夫前向过程的变分推断3.1 非马尔可夫前向过程3.2 生成过程与统一变分推断目标定理 1。4 从广义生成过程采样4.1 Denoising Diffusion Implicit Models4.2 加速生成过程4.3 与 Neural ODE 的关系命题 1。5 实验5.1 样本质量与效率5.2 DDIM 中的样本一致性5.3 确定性生成过程中的插值5.4 从潜空间重建6 相关工作7 讨论AcknowledgementsReferences附录 A 离散情形的非马尔可夫前向过程附录 B 证明引理 1。证明。证明。证明。DDIM 的 ODE 形式VE-SDE 的 ODE 形式附录 C 补充推导C.1 加速采样过程C.2 DDPM 去噪目标的推导附录 D 实验细节D.1 数据集与架构D.2 反向过程子序列选择D.3 每步采样的闭式方程D.4 样本与一致性D.5 插值
返回论文列表
目录

Denoising Diffusion Implicit Models

收录于 ICLR 2021;arXiv:2010.02502
打开论文来源

Denoising Diffusion Implicit Models

Jiaming Song    Chenlin Meng & Stefano Ermon Affiliation:  Stanford University Email:  {tsong,chenlin,ermon}@cs.stanford.edu

Abstract

摘要

Denoising diffusion probabilistic models (DDPMs) have achieved high quality image generation without adversarial training, yet they require simulating a Markov chain for many steps in order to produce a sample. To accelerate sampling, we present denoising diffusion implicit models (DDIMs), a more efficient class of iterative implicit probabilistic models with the same training procedure as DDPMs. In DDPMs, the generative process is defined as the reverse of a particular Markovian diffusion process. We generalize DDPMs via a class of non-Markovian diffusion processes that lead to the same training objective. These non-Markovian processes can correspond to generative processes that are deterministic, giving rise to implicit models that produce high quality samples much faster. We empirically demonstrate that DDIMs can produce high quality samples 10×10\times10× to 50×50\times50× faster in terms of wall-clock time compared to DDPMs, allow us to trade off computation for sample quality, perform semantically meaningful image interpolation directly in the latent space, and reconstruct observations with very low error.

去噪扩散概率模型(DDPM)无需对抗训练即可生成高质量图像,但采样需模拟很长的马尔可夫链。为加速采样,我们提出去噪扩散隐式模型(DDIM):一类更高效的迭代隐式概率模型,训练过程与 DDPM 相同。在 DDPM 中,生成过程定义为某特定马尔可夫扩散过程的逆。我们通过一类非马尔可夫扩散过程推广 DDPM,它们导向相同的训练目标。这些非马尔可夫过程可对应确定性的生成过程,从而得到能更快产出高质量样本的隐式模型。经验表明,相对 DDPM,DDIM 在墙钟时间上可快 10×10\times10× 到 50×50\times50× 产出高质量样本,允许在计算与样本质量之间权衡,可在潜空间直接做语义有意义的图像插值,并能以很低误差重建观测。

1 Introduction

1 引言

Deep generative models have demonstrated the ability to produce high quality samples in many domains (Karras et al. 2020; van den Oord et al. 2016a). In terms of image generation, generative adversarial networks (GANs, Goodfellow et al. 2014) currently exhibits higher sample quality than likelihood-based methods such as variational autoencoders (Kingma & Welling 2013), autoregressive models (van den Oord et al. 2016b) and normalizing flows (Rezende & Mohamed 2015; Dinh et al. 2016). However, GANs require very specific choices in optimization and architectures in order to stabilize training (Arjovsky et al. 2017; Gulrajani et al. 2017; Karras et al. 2018; Brock et al. 2018), and could fail to cover modes of the data distribution (Zhao et al. 2018).

深度生成模型已在许多领域展示高质量采样能力 (Karras et al. 2020; van den Oord et al. 2016a)。图像生成方面,生成对抗网络(GAN, Goodfellow et al. 2014)目前样本质量通常高于变分自编码器 (Kingma & Welling 2013)、自回归模型 (van den Oord et al. 2016b) 与归一化流 (Rezende & Mohamed 2015; Dinh et al. 2016) 等基于似然的方法。但 GAN 需要非常特定的优化与结构选择才能稳住训练 (Arjovsky et al. 2017; Gulrajani et al. 2017; Karras et al. 2018; Brock et al. 2018),也可能覆盖不到数据分布的全部模态 (Zhao et al. 2018)。

Recent works on iterative generative models (Bengio et al. 2014), such as denoising diffusion probabilistic models (DDPM, Ho et al. 2020) and noise conditional score networks (NCSN, Song & Ermon 2019) have demonstrated the ability to produce samples comparable to that of GANs, without having to perform adversarial training. To achieve this, many denoising autoencoding models are trained to denoise samples corrupted by various levels of Gaussian noise. Samples are then produced by a Markov chain which, starting from white noise, progressively denoises it into an image. This generative Markov Chain process is either based on Langevin dynamics (Song & Ermon 2019) or obtained by reversing a forward diffusion process that progressively turns an image into noise (Sohl-Dickstein et al. 2015).

关于迭代生成模型的近期工作 (Bengio et al. 2014),例如去噪扩散概率模型(DDPM, Ho et al. 2020)与噪声条件分数网络(NCSN, Song & Ermon 2019),已表明无需对抗训练也能产出可比 GAN 的样本。做法是训练许多去噪自编码模型,对被不同程度高斯噪声腐蚀的样本去噪;再从白噪声出发,用一条马尔可夫链逐步去噪成图像。该生成马尔可夫链过程要么基于 Langevin 动力学 (Song & Ermon 2019),要么通过对逐步把图像变成噪声的前向扩散过程取逆得到 (Sohl-Dickstein et al. 2015)。

A critical drawback of these models is that they require many iterations to produce a high quality sample. For DDPMs, this is because that the generative process (from noise to data) approximates the reverse of the forward diffusion process (from data to noise), which could have thousands of steps; iterating over all the steps is required to produce a single sample, which is much slower compared to GANs, which only needs one pass through a network. For example, it takes around 20 hours to sample 50k images of size 32×3232\times 3232×32 from a DDPM, but less than a minute to do so from a GAN on a Nvidia 2080 Ti GPU. This becomes more problematic for larger images as sampling 50k images of size 256×256256\times 256256×256 could take nearly 100010001000 hours on the same GPU.

这类模型的关键缺点是:要产出高质量样本需要很多次迭代。对 DDPM 而言,是因为生成过程(噪声到数据)近似前向扩散过程(数据到噪声)的逆,后者可能有数千步;要得到单个样本就必须遍历全部步骤,远慢于只需一次网络前向的 GAN。例如,在 Nvidia 2080 Ti 上,从 DDPM 采样 5 万张 32×3232\times 3232×32 图像约需 20 小时,而 GAN 不到一分钟。图像更大时更糟:同 GPU 上采 5 万张 256×256256\times 256256×256 可能接近 100010001000 小时。

To close this efficiency gap between DDPMs and GANs, we present denoising diffusion implicit models (DDIMs). DDIMs are implicit probabilistic models (Mohamed & Lakshminarayanan 2016) and are closely related to DDPMs, in the sense that they are trained with the same objective function. In Section 3, we generalize the forward diffusion process used by DDPMs, which is Markovian, to non-Markovian ones, for which we are still able to design suitable reverse generative Markov chains. We show that the resulting variational training objectives have a shared surrogate objective, which is exactly the objective used to train DDPM. Therefore, we can freely choose from a large family of generative models using the same neural network simply by choosing a different, non-Markovian diffusion process (Section 4.1) and the corresponding reverse generative Markov Chain. In particular, we are able to use non-Markovian diffusion processes which lead to ”short” generative Markov chains (Section 4.2) that can be simulated in a small number of steps. This can massively increase sample efficiency only at a minor cost in sample quality.

为缩小 DDPM 与 GAN 之间的效率差距,我们提出去噪扩散隐式模型(DDIM)。DDIM 是隐式概率模型 (Mohamed & Lakshminarayanan 2016),与 DDPM 密切相关:训练目标函数相同。第 3 节把 DDPM 使用的马尔可夫前向扩散过程推广到非马尔可夫过程,并仍能设计合适的反向生成马尔可夫链。我们证明所得变分训练目标有一个共享替代目标,恰好是训练 DDPM 所用目标。因此,只需选择不同的非马尔可夫扩散过程(第 4.1 节)及相应反向生成马尔可夫链,即可用同一神经网络自由选用一大族生成模型。特别地,我们能使用导向「短」生成马尔可夫链的非马尔可夫扩散过程(第 4.2 节),用很少步数即可模拟。这可在样本质量仅小幅下降的代价下大幅提高采样效率。

In Section 5, we demonstrate several empirical benefits of DDIMs over DDPMs. First, DDIMs have superior sample generation quality compared to DDPMs, when we accelerate sampling by 10×10\times10× to 100×100\times100× using our proposed method. Second, DDIM samples have the following “consistency” property, which does not hold for DDPMs: if we start with the same initial latent variable and generate several samples with Markov chains of various lengths, these samples would have similar high-level features. Third, because of “consistency” in DDIMs, we can perform semantically meaningful image interpolation by manipulating the initial latent variable in DDIMs, unlike DDPMs which interpolates near the image space due to the stochastic generative process.

第 5 节展示 DDIM 相对 DDPM 的若干经验优势。第一,用所提方法把采样加速 10×10\times10× 到 100×100\times100× 时,DDIM 样本质量优于 DDPM。第二,DDIM 样本具有 DDPM 所不具备的「一致性」:从同一初始潜变量出发、用不同长度的马尔可夫链生成多个样本时,这些样本会有相似的高层特征。第三,因 DDIM 有「一致性」,可通过操纵初始潜变量做语义有意义的图像插值;而 DDPM 因生成过程随机,插值更靠近图像空间。

2 Background

2 背景

Figure 1: Graphical models for diffusion (left) and non-Markovian (right) inference models.

图 1:扩散(左)与非马尔可夫(右)推断模型的图模型。

Given samples from a data distribution q(x0)q({\bm{x}}_{0})q(x0​), we are interested in learning a model distribution pθ(x0)p_{\theta}({\bm{x}}_{0})pθ​(x0​) that approximates q(x0)q({\bm{x}}_{0})q(x0​) and is easy to sample from. Denoising diffusion probabilistic models (DDPMs, Sohl-Dickstein et al. 2015; Ho et al. 2020) are latent variable models of the form

给定数据分布 q(x0)q({\bm{x}}_{0})q(x0​) 的样本,我们希望学习近似 q(x0)q({\bm{x}}_{0})q(x0​) 且易于采样的模型分布 pθ(x0)p_{\theta}({\bm{x}}_{0})pθ​(x0​)。去噪扩散概率模型(DDPM, Sohl-Dickstein et al. 2015; Ho et al. 2020)是如下形式的潜变量模型

pθ(x0)=∫pθ(x0:T)dx1:T,wherepθ(x0:T):=pθ(xT)∏t=1Tpθ(t)(xt−1∣xt)(1)\displaystyle p_{\theta}({\bm{x}}_{0})=\int p_{\theta}({\bm{x}}_{0:T})\mathrm{d}{\bm{x}}_{1:T},\quad\text{where}\quad p_{\theta}({\bm{x}}_{0:T}):=p_{\theta}({\bm{x}}_{T})\prod_{t=1}^{T}p^{(t)}_{\theta}({\bm{x}}_{t-1}|{\bm{x}}_{t}) \tag{1}pθ​(x0​)=∫pθ​(x0:T​)dx1:T​,wherepθ​(x0:T​):=pθ​(xT​)t=1∏T​pθ(t)​(xt−1​∣xt​)(1)

where x1,…,xT{\bm{x}}_{1},\ldots,{\bm{x}}_{T}x1​,…,xT​ are latent variables in the same sample space as x0{\bm{x}}_{0}x0​ (denoted as X{\mathcal{X}}X). The parameters θ\thetaθ are learned to fit the data distribution q(x0)q({\bm{x}}_{0})q(x0​) by maximizing a variational lower bound:

其中 x1,…,xT{\bm{x}}_{1},\ldots,{\bm{x}}_{T}x1​,…,xT​ 是与 x0{\bm{x}}_{0}x0​ 同一样本空间(记为 X{\mathcal{X}}X)中的潜变量。参数 θ\thetaθ 通过最大化变分下界来拟合数据分布 q(x0)q({\bm{x}}_{0})q(x0​):

max⁡θEq(x0)[log⁡pθ(x0)]≤max⁡θEq(x0,x1,…,xT)[log⁡pθ(x0:T)−log⁡q(x1:T∣x0)](2)\displaystyle\max_{\theta}{\mathbb{E}}_{q({\bm{x}}_{0})}[\log p_{\theta}({\bm{x}}_{0})]\leq\max_{\theta}{\mathbb{E}}_{q({\bm{x}}_{0},{\bm{x}}_{1},\ldots,{\bm{x}}_{T})}\left[\log p_{\theta}({\bm{x}}_{0:T})-\log q({\bm{x}}_{1:T}|{\bm{x}}_{0})\right] \tag{2}θmax​Eq(x0​)​[logpθ​(x0​)]≤θmax​Eq(x0​,x1​,…,xT​)​[logpθ​(x0:T​)−logq(x1:T​∣x0​)](2)

where q(x1:T∣x0)q({\bm{x}}_{1:T}|{\bm{x}}_{0})q(x1:T​∣x0​) is some inference distribution over the latent variables. Unlike typical latent variable models (such as the variational autoencoder (Rezende et al. 2014)), DDPMs are learned with a fixed (rather than trainable) inference procedure q(x1:T∣x0)q({\bm{x}}_{1:T}|{\bm{x}}_{0})q(x1:T​∣x0​), and latent variables are relatively high dimensional. For example, Ho et al. 2020 considered the following Markov chain with Gaussian transitions parameterized by a decreasing sequence α1:T∈(0,1]T\alpha_{1:T}\in(0,1]^{T}α1:T​∈(0,1]T:

其中 q(x1:T∣x0)q({\bm{x}}_{1:T}|{\bm{x}}_{0})q(x1:T​∣x0​) 是潜变量上的某推断分布。与典型潜变量模型(如变分自编码器 (Rezende et al. 2014))不同,DDPM 用固定(而非可训练)的推断程序 q(x1:T∣x0)q({\bm{x}}_{1:T}|{\bm{x}}_{0})q(x1:T​∣x0​) 学习,且潜变量维数相对较高。例如,Ho et al. 2020 考虑了由递减序列 α1:T∈(0,1]T\alpha_{1:T}\in(0,1]^{T}α1:T​∈(0,1]T 参数化的如下高斯转移马尔可夫链:

q(x1:T∣x0):=∏t=1Tq(xt∣xt−1),where q(xt∣xt−1):=N(αtαt−1xt−1,(1−αtαt−1)I)(3)\displaystyle q({\bm{x}}_{1:T}|{\bm{x}}_{0}):=\prod_{t=1}^{T}q({\bm{x}}_{t}|{\bm{x}}_{t-1}),\text{where}\ q({\bm{x}}_{t}|{\bm{x}}_{t-1}):={\mathcal{N}}\left(\sqrt{\frac{\alpha_{t}}{\alpha_{t-1}}}{\bm{x}}_{t-1},\left(1-\frac{\alpha_{t}}{\alpha_{t-1}}\right){\bm{I}}\right) \tag{3}q(x1:T​∣x0​):=t=1∏T​q(xt​∣xt−1​),where q(xt​∣xt−1​):=N(αt−1​αt​​​xt−1​,(1−αt−1​αt​​)I)(3)

where the covariance matrix is ensured to have positive terms on its diagonal. This is called the forward process due to the autoregressive nature of the sampling procedure (from x0{\bm{x}}_{0}x0​ to xT{\bm{x}}_{T}xT​). We call the latent variable model pθ(x0:T)p_{\theta}({\bm{x}}_{0:T})pθ​(x0:T​), which is a Markov chain that samples from xT{\bm{x}}_{T}xT​ to x0{\bm{x}}_{0}x0​, the generative process, since it approximates the intractable reverse process q(xt−1∣xt)q({\bm{x}}_{t-1}|{\bm{x}}_{t})q(xt−1​∣xt​). Intuitively, the forward process progressively adds noise to the observation x0{\bm{x}}_{0}x0​, whereas the generative process progressively denoises a noisy observation (Figure 1, left).

其中协方差矩阵对角项保证为正。因其采样过程的自回归性质(从 x0{\bm{x}}_{0}x0​ 到 xT{\bm{x}}_{T}xT​),这称为前向过程。我们把从 xT{\bm{x}}_{T}xT​ 采到 x0{\bm{x}}_{0}x0​ 的潜变量模型 pθ(x0:T)p_{\theta}({\bm{x}}_{0:T})pθ​(x0:T​) 称为生成过程,因为它近似难处理的反向过程 q(xt−1∣xt)q({\bm{x}}_{t-1}|{\bm{x}}_{t})q(xt−1​∣xt​)。直观上,前向过程逐步给观测 x0{\bm{x}}_{0}x0​ 加噪,生成过程则逐步给带噪观测去噪(图 1,左)。

A special property of the forward process is that

前向过程的一个特殊性质是

q(xt∣x0):=∫q(x1:t∣x0)dx1:(t−1)=N(xt;αtx0,(1−αt)I);q({\bm{x}}_{t}|{\bm{x}}_{0}):=\int q({\bm{x}}_{1:t}|{\bm{x}}_{0})\mathrm{d}{\bm{x}}_{1:(t-1)}={\mathcal{N}}({\bm{x}}_{t};\sqrt{\alpha_{t}}{\bm{x}}_{0},(1-\alpha_{t}){\bm{I}});q(xt​∣x0​):=∫q(x1:t​∣x0​)dx1:(t−1)​=N(xt​;αt​​x0​,(1−αt​)I);

so we can express xt{\bm{x}}_{t}xt​ as a linear combination of x0{\bm{x}}_{0}x0​ and a noise variable ϵ\epsilonϵ:

因此可将 xt{\bm{x}}_{t}xt​ 写成 x0{\bm{x}}_{0}x0​ 与噪声变量 ϵ\epsilonϵ 的线性组合:

xt=αtx0+1−αtϵ,whereϵ∼N(0,I).(4)\displaystyle{\bm{x}}_{t}=\sqrt{\alpha_{t}}{\bm{x}}_{0}+\sqrt{1-\alpha_{t}}\epsilon,\quad\text{where}\quad\epsilon\sim{\mathcal{N}}({\bm{0}},{\bm{I}}). \tag{4}xt​=αt​​x0​+1−αt​​ϵ,whereϵ∼N(0,I).(4)

When we set αT\alpha_{T}αT​ sufficiently close to 000, q(xT∣x0)q({\bm{x}}_{T}|{\bm{x}}_{0})q(xT​∣x0​) converges to a standard Gaussian for all x0{\bm{x}}_{0}x0​, so it is natural to set pθ(xT):=N(0,I)p_{\theta}({\bm{x}}_{T}):={\mathcal{N}}({\bm{0}},{\bm{I}})pθ​(xT​):=N(0,I). If all the conditionals are modeled as Gaussians with trainable mean functions and fixed variances, the objective in Eq. (2) can be simplified to[^1]:

当把 αT\alpha_{T}αT​ 设得充分接近 000 时,对一切 x0{\bm{x}}_{0}x0​,q(xT∣x0)q({\bm{x}}_{T}|{\bm{x}}_{0})q(xT​∣x0​) 收敛到标准高斯,因而自然取 pθ(xT):=N(0,I)p_{\theta}({\bm{x}}_{T}):={\mathcal{N}}({\bm{0}},{\bm{I}})pθ​(xT​):=N(0,I)。若所有条件分布都建模为具有可训练均值函数与固定方差的高斯,则式 (2) 中的目标可简化为[^1]:

Lγ(ϵθ):=∑t=1TγtEx0∼q(x0),ϵt∼N(0,I)[∥ϵθ(t)(αtx0+1−αtϵt)−ϵt∥22](5)\displaystyle L_{\gamma}(\epsilon_{\theta}) \\ \displaystyle:=\sum_{t=1}^{T}\gamma_{t}{\mathbb{E}}_{{\bm{x}}_{0}\sim q({\bm{x}}_{0}),\epsilon_{t}\sim{\mathcal{N}}({\bm{0}},{\bm{I}})}\left[{\lVert{\epsilon_{\theta}^{(t)}(\sqrt{\alpha_{t}}{\bm{x}}_{0}+\sqrt{1-\alpha_{t}}\epsilon_{t})-\epsilon_{t}}\rVert}_{2}^{2}\right] \tag{5}Lγ​(ϵθ​):=t=1∑T​γt​Ex0​∼q(x0​),ϵt​∼N(0,I)​[∥ϵθ(t)​(αt​​x0​+1−αt​​ϵt​)−ϵt​∥22​](5)

where ϵθ:={ϵθ(t)}t=1T\epsilon_{\theta}:=\{\epsilon_{\theta}^{(t)}\}_{t=1}^{T}ϵθ​:={ϵθ(t)​}t=1T​ is a set of TTT functions, each ϵθ(t):X→X\epsilon_{\theta}^{(t)}:{\mathcal{X}}\to{\mathcal{X}}ϵθ(t)​:X→X (indexed by ttt) is a function with trainable parameters θ(t)\theta^{(t)}θ(t), and γ:=[γ1,…,γT]\gamma:=[\gamma_{1},\ldots,\gamma_{T}]γ:=[γ1​,…,γT​] is a vector of positive coefficients in the objective that depends on α1:T\alpha_{1:T}α1:T​. In Ho et al. 2020, the objective with γ=1\gamma={\bm{1}}γ=1 is optimized instead to maximize generation performance of the trained model; this is also the same objective used in noise conditional score networks (Song & Ermon 2019) based on score matching (Hyvärinen 2005; Vincent 2011). From a trained model, x0{\bm{x}}_{0}x0​ is sampled by first sampling xT{\bm{x}}_{T}xT​ from the prior pθ(xT)p_{\theta}({\bm{x}}_{T})pθ​(xT​), and then sampling xt−1{\bm{x}}_{t-1}xt−1​ from the generative processes iteratively.

其中 ϵθ:={ϵθ(t)}t=1T\epsilon_{\theta}:=\{\epsilon_{\theta}^{(t)}\}_{t=1}^{T}ϵθ​:={ϵθ(t)​}t=1T​ 是 TTT 个函数的集合,每个 ϵθ(t):X→X\epsilon_{\theta}^{(t)}:{\mathcal{X}}\to{\mathcal{X}}ϵθ(t)​:X→X(由 ttt 索引)带可训练参数 θ(t)\theta^{(t)}θ(t),γ:=[γ1,…,γT]\gamma:=[\gamma_{1},\ldots,\gamma_{T}]γ:=[γ1​,…,γT​] 是目标中依赖 α1:T\alpha_{1:T}α1:T​ 的正系数向量。Ho et al. 2020 优化 γ=1\gamma={\bm{1}}γ=1 的目标以提升训练模型的生成表现;这也与基于分数匹配 (Hyvärinen 2005; Vincent 2011) 的噪声条件分数网络 (Song & Ermon 2019) 所用目标相同。从训练好的模型采样 x0{\bm{x}}_{0}x0​ 时,先从先验 pθ(xT)p_{\theta}({\bm{x}}_{T})pθ​(xT​) 采 xT{\bm{x}}_{T}xT​,再迭代地从生成过程采 xt−1{\bm{x}}_{t-1}xt−1​。

The length TTT of the forward process is an important hyperparameter in DDPMs. From a variational perspective, a large TTT allows the reverse process to be close to a Gaussian (Sohl-Dickstein et al. 2015), so that the generative process modeled with Gaussian conditional distributions becomes a good approximation; this motivates the choice of large TTT values, such as T=1000T=1000T=1000 in Ho et al. 2020. However, as all TTT iterations have to be performed sequentially, instead of in parallel, to obtain a sample x0{\bm{x}}_{0}x0​, sampling from DDPMs is much slower than sampling from other deep generative models, which makes them impractical for tasks where compute is limited and latency is critical.

前向过程长度 TTT 是 DDPM 的重要超参数。从变分视角看,大 TTT 使反向过程接近高斯 (Sohl-Dickstein et al. 2015),从而用高斯条件分布建模的生成过程成为好近似;这促使选择如 Ho et al. 2020 中 T=1000T=1000T=1000 的大 TTT。但要得到样本 x0{\bm{x}}_{0}x0​,全部 TTT 次迭代必须串行而非并行,因而从 DDPM 采样远慢于其他深度生成模型,在算力有限、延迟关键的任务上不实用。

3 Variational Inference for non-Markovian Forward Processes

3 非马尔可夫前向过程的变分推断

Because the generative model approximates the reverse of the inference process, we need to rethink the inference process in order to reduce the number of iterations required by the generative model. Our key observation is that the DDPM objective in the form of LγL_{\gamma}Lγ​ only depends on the marginals[^2] q(xt∣x0)q({\bm{x}}_{t}|{\bm{x}}_{0})q(xt​∣x0​), but not directly on the joint q(x1:T∣x0)q({\bm{x}}_{1:T}|{\bm{x}}_{0})q(x1:T​∣x0​). Since there are many inference distributions (joints) with the same marginals, we explore alternative inference processes that are non-Markovian, which leads to new generative processes (Figure 1, right). These non-Markovian inference process lead to the same surrogate objective function as DDPM, as we will show below. In Appendix A, we show that the non-Markovian perspective also applies beyond the Gaussian case.

因为生成模型近似推断过程的逆,要减少生成模型所需迭代次数,就需要重新思考推断过程。关键观察是:形如 LγL_{\gamma}Lγ​ 的 DDPM 目标只依赖边缘[^2] q(xt∣x0)q({\bm{x}}_{t}|{\bm{x}}_{0})q(xt​∣x0​),而不直接依赖联合 q(x1:T∣x0)q({\bm{x}}_{1:T}|{\bm{x}}_{0})q(x1:T​∣x0​)。由于有许多具有相同边缘的推断分布(联合),我们探索非马尔可夫的替代推断过程,从而得到新的生成过程(图 1,右)。如下所示,这些非马尔可夫推断过程导向与 DDPM 相同的替代目标函数。附录 A 表明非马尔可夫视角也适用于高斯情形之外。

3.1 Non-Markovian forward processes

3.1 非马尔可夫前向过程

Let us consider a family Q{\mathcal{Q}}Q of inference distributions, indexed by a real vector σ∈R≥0T\sigma\in\mathbb{R}_{\geq 0}^{T}σ∈R≥0T​:

考虑由实向量 σ∈R≥0T\sigma\in\mathbb{R}_{\geq 0}^{T}σ∈R≥0T​ 索引的一族推断分布 Q{\mathcal{Q}}Q:

qσ(x1:T∣x0):=qσ(xT∣x0)∏t=2Tqσ(xt−1∣xt,x0)(6)\displaystyle q_{\sigma}({\bm{x}}_{1:T}|{\bm{x}}_{0}):=q_{\sigma}({\bm{x}}_{T}|{\bm{x}}_{0})\prod_{t=2}^{T}q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0}) \tag{6}qσ​(x1:T​∣x0​):=qσ​(xT​∣x0​)t=2∏T​qσ​(xt−1​∣xt​,x0​)(6)

where qσ(xT∣x0)=N(αTx0,(1−αT)I)q_{\sigma}({\bm{x}}_{T}|{\bm{x}}_{0})={\mathcal{N}}(\sqrt{\alpha_{T}}{\bm{x}}_{0},(1-\alpha_{T}){\bm{I}})qσ​(xT​∣x0​)=N(αT​​x0​,(1−αT​)I) and for all t>1t>1t>1,

其中 qσ(xT∣x0)=N(αTx0,(1−αT)I)q_{\sigma}({\bm{x}}_{T}|{\bm{x}}_{0})={\mathcal{N}}(\sqrt{\alpha_{T}}{\bm{x}}_{0},(1-\alpha_{T}){\bm{I}})qσ​(xT​∣x0​)=N(αT​​x0​,(1−αT​)I),且对一切 t>1t>1t>1,

qσ(xt−1∣xt,x0)=N(αt−1x0+1−αt−1−σt2⋅xt−αtx01−αt,σt2I).(7)\displaystyle q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})={\mathcal{N}}\left(\sqrt{\alpha_{t-1}}{\bm{x}}_{0}+\sqrt{1-\alpha_{t-1}-\sigma^{2}_{t}}\cdot{\frac{{\bm{x}}_{t}-\sqrt{\alpha_{t}}{\bm{x}}_{0}}{\sqrt{1-\alpha_{t}}}},\sigma_{t}^{2}{\bm{I}}\right). \tag{7}qσ​(xt−1​∣xt​,x0​)=N(αt−1​​x0​+1−αt−1​−σt2​​⋅1−αt​​xt​−αt​​x0​​,σt2​I).(7)

The mean function is chosen to order to ensure that qσ(xt∣x0)=N(αtx0,(1−αt)I)q_{\sigma}({\bm{x}}_{t}|{\bm{x}}_{0})={\mathcal{N}}(\sqrt{\alpha_{t}}{\bm{x}}_{0},(1-\alpha_{t}){\bm{I}})qσ​(xt​∣x0​)=N(αt​​x0​,(1−αt​)I) for all ttt (see Lemma 1 of Appendix B), so that it defines a joint inference distribution that matches the ‘‘marginals’’ as desired. The forward process[^3] can be derived from Bayes’ rule:

均值函数的选取是为了保证对一切 ttt 有 qσ(xt∣x0)=N(αtx0,(1−αt)I)q_{\sigma}({\bm{x}}_{t}|{\bm{x}}_{0})={\mathcal{N}}(\sqrt{\alpha_{t}}{\bm{x}}_{0},(1-\alpha_{t}){\bm{I}})qσ​(xt​∣x0​)=N(αt​​x0​,(1−αt​)I)(见附录 B 引理 1),从而定义匹配所需「边缘」的联合推断分布。前向过程[^3]可由贝叶斯法则导出:

qσ(xt∣xt−1,x0)=qσ(xt−1∣xt,x0)qσ(xt∣x0)qσ(xt−1∣x0),(8)\displaystyle q_{\sigma}({\bm{x}}_{t}|{\bm{x}}_{t-1},{\bm{x}}_{0})=\frac{q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})q_{\sigma}({\bm{x}}_{t}|{\bm{x}}_{0})}{q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{0})}, \tag{8}qσ​(xt​∣xt−1​,x0​)=qσ​(xt−1​∣x0​)qσ​(xt−1​∣xt​,x0​)qσ​(xt​∣x0​)​,(8)

which is also Gaussian (although we do not use this fact for the remainder of this paper). Unlike the diffusion process in Eq. (3), the forward process here is no longer Markovian, since each xt{\bm{x}}_{t}xt​ could depend on both xt−1{\bm{x}}_{t-1}xt−1​ and x0{\bm{x}}_{0}x0​. The magnitude of σ\sigmaσ controls the how stochastic the forward process is; when σ→0\sigma\to{\bm{0}}σ→0, we reach an extreme case where as long as we observe x0{\bm{x}}_{0}x0​ and xt{\bm{x}}_{t}xt​ for some ttt, then xt−1{\bm{x}}_{t-1}xt−1​ become known and fixed.

它也是高斯的(后文虽不用这一事实)。与式 (3) 中的扩散过程不同,这里的前向过程不再是马尔可夫的,因为每个 xt{\bm{x}}_{t}xt​ 可能同时依赖 xt−1{\bm{x}}_{t-1}xt−1​ 与 x0{\bm{x}}_{0}x0​。σ\sigmaσ 的大小控制前向过程有多随机;当 σ→0\sigma\to{\bm{0}}σ→0 时,达到极端情形:只要观察到某 ttt 的 x0{\bm{x}}_{0}x0​ 与 xt{\bm{x}}_{t}xt​,xt−1{\bm{x}}_{t-1}xt−1​ 便已知且固定。

3.2 Generative process and unified variational inference objective

3.2 生成过程与统一变分推断目标

Next, we define a trainable generative process pθ(x0:T)p_{\theta}({\bm{x}}_{0:T})pθ​(x0:T​) where each pθ(t)(xt−1∣xt)p_{\theta}^{(t)}({\bm{x}}_{t-1}|{\bm{x}}_{t})pθ(t)​(xt−1​∣xt​) leverages knowledge of qσ(xt−1∣xt,x0)q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})qσ​(xt−1​∣xt​,x0​). Intuitively, given a noisy observation xt{\bm{x}}_{t}xt​, we first make a prediction[^4] of the corresponding x0{\bm{x}}_{0}x0​, and then use it to obtain a sample xt−1{\bm{x}}_{t-1}xt−1​ through the reverse conditional distribution qσ(xt−1∣xt,x0)q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})qσ​(xt−1​∣xt​,x0​), which we have defined.

接下来定义可训练生成过程 pθ(x0:T)p_{\theta}({\bm{x}}_{0:T})pθ​(x0:T​),其中每个 pθ(t)(xt−1∣xt)p_{\theta}^{(t)}({\bm{x}}_{t-1}|{\bm{x}}_{t})pθ(t)​(xt−1​∣xt​) 利用 qσ(xt−1∣xt,x0)q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})qσ​(xt−1​∣xt​,x0​) 的知识。直观上,给定带噪观测 xt{\bm{x}}_{t}xt​,我们先对其对应的 x0{\bm{x}}_{0}x0​ 做预测[^4],再通过已定义的反向条件分布 qσ(xt−1∣xt,x0)q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})qσ​(xt−1​∣xt​,x0​) 得到样本 xt−1{\bm{x}}_{t-1}xt−1​。

For some x0∼q(x0){\bm{x}}_{0}\sim q({\bm{x}}_{0})x0​∼q(x0​) and ϵt∼N(0,I)\epsilon_{t}\sim{\mathcal{N}}({\bm{0}},{\bm{I}})ϵt​∼N(0,I), xt{\bm{x}}_{t}xt​ can be obtained using Eq. (4). The model ϵθ(t)(xt)\epsilon_{\theta}^{(t)}({\bm{x}}_{t})ϵθ(t)​(xt​) then attempts to predict ϵt\epsilon_{t}ϵt​ from xt{\bm{x}}_{t}xt​, without knowledge of x0{\bm{x}}_{0}x0​. By rewriting Eq. (4), one can then predict the denoised observation, which is a prediction of x0{\bm{x}}_{0}x0​ given xt{\bm{x}}_{t}xt​:

对某 x0∼q(x0){\bm{x}}_{0}\sim q({\bm{x}}_{0})x0​∼q(x0​) 与 ϵt∼N(0,I)\epsilon_{t}\sim{\mathcal{N}}({\bm{0}},{\bm{I}})ϵt​∼N(0,I),可用式 (4) 得到 xt{\bm{x}}_{t}xt​。模型 ϵθ(t)(xt)\epsilon_{\theta}^{(t)}({\bm{x}}_{t})ϵθ(t)​(xt​) 试图在不知 x0{\bm{x}}_{0}x0​ 的情况下从 xt{\bm{x}}_{t}xt​ 预测 ϵt\epsilon_{t}ϵt​。改写式 (4),即可预测去噪观测,亦即给定 xt{\bm{x}}_{t}xt​ 对 x0{\bm{x}}_{0}x0​ 的预测:

fθ(t)(xt):=(xt−1−αt⋅ϵθ(t)(xt))/αt.(9)\displaystyle f_{\theta}^{(t)}({\bm{x}}_{t}):=({\bm{x}}_{t}-\sqrt{1-\alpha_{t}}\cdot\epsilon_{\theta}^{(t)}({\bm{x}}_{t}))/\sqrt{\alpha_{t}}. \tag{9}fθ(t)​(xt​):=(xt​−1−αt​​⋅ϵθ(t)​(xt​))/αt​​.(9)

We can then define the generative process with a fixed prior pθ(xT)=N(0,I)p_{\theta}({\bm{x}}_{T})={\mathcal{N}}({\bm{0}},{\bm{I}})pθ​(xT​)=N(0,I) and

于是可用固定先验 pθ(xT)=N(0,I)p_{\theta}({\bm{x}}_{T})={\mathcal{N}}({\bm{0}},{\bm{I}})pθ​(xT​)=N(0,I) 定义生成过程,并取

$$\displaystyle p_{\theta}^{(t)}({\bm{x}}{t-1}|{\bm{x}}{t})=\begin{cases}{\mathcal{N}}(f_{\theta}^{(1)}({\bm{x}}{1}),\sigma{1}^{2}{\bm{I}})&\text{if}\ t=1\
q_{\sigma}({\bm{x}}{t-1}|{\bm{x}}{t},f_{\theta}^{(t)}({\bm{x}}_{t}))&\text{otherwise,}\end{cases} \tag{10}$$

where qσ(xt−1∣xt,fθ(t)(xt))q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},f_{\theta}^{(t)}({\bm{x}}_{t}))qσ​(xt−1​∣xt​,fθ(t)​(xt​)) is defined as in Eq. (7) with x0{\bm{x}}_{0}x0​ replaced by fθ(t)(xt)f_{\theta}^{(t)}({\bm{x}}_{t})fθ(t)​(xt​). We add some Gaussian noise (with covariance σ12I\sigma_{1}^{2}{\bm{I}}σ12​I) for the case of t=1t=1t=1 to ensure that the generative process is supported everywhere.

其中 qσ(xt−1∣xt,fθ(t)(xt))q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},f_{\theta}^{(t)}({\bm{x}}_{t}))qσ​(xt−1​∣xt​,fθ(t)​(xt​)) 按式 (7) 定义,只是把 x0{\bm{x}}_{0}x0​ 换成 fθ(t)(xt)f_{\theta}^{(t)}({\bm{x}}_{t})fθ(t)​(xt​)。对 t=1t=1t=1 的情形,我们加入协方差为 σ12I\sigma_{1}^{2}{\bm{I}}σ12​I 的高斯噪声,以保证生成过程在处处有支撑。

We optimize θ\thetaθ via the following variational inference objective (which is a functional over ϵθ\epsilon_{\theta}ϵθ​):

我们通过如下变分推断目标(作为 ϵθ\epsilon_{\theta}ϵθ​ 上的泛函)优化 θ\thetaθ:

Jσ(ϵθ):=Ex0:T∼qσ(x0:T)[log⁡qσ(x1:T∣x0)−log⁡pθ(x0:T)]= Ex0:T∼qσ(x0:T)[log⁡qσ(xT∣x0)+∑t=2Tlog⁡qσ(xt−1∣xt,x0)−∑t=1Tlog⁡pθ(t)(xt−1∣xt)−log⁡pθ(xT)](11)\displaystyle J_{\sigma}(\epsilon_{\theta}):={\mathbb{E}}_{{\bm{x}}_{0:T}\sim q_{\sigma}({\bm{x}}_{0:T})}[\log q_{\sigma}({\bm{x}}_{1:T}|{\bm{x}}_{0})-\log p_{\theta}({\bm{x}}_{0:T})] \\ \displaystyle= \\ \displaystyle\ {\mathbb{E}}_{{\bm{x}}_{0:T}\sim q_{\sigma}({\bm{x}}_{0:T})}\left[\log q_{\sigma}({\bm{x}}_{T}|{\bm{x}}_{0})+\sum_{t=2}^{T}\log q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})-\sum_{t=1}^{T}\log p_{\theta}^{(t)}({\bm{x}}_{t-1}|{\bm{x}}_{t})-\log p_{\theta}({\bm{x}}_{T})\right] \tag{11}Jσ​(ϵθ​):=Ex0:T​∼qσ​(x0:T​)​[logqσ​(x1:T​∣x0​)−logpθ​(x0:T​)]= Ex0:T​∼qσ​(x0:T​)​[logqσ​(xT​∣x0​)+t=2∑T​logqσ​(xt−1​∣xt​,x0​)−t=1∑T​logpθ(t)​(xt−1​∣xt​)−logpθ​(xT​)](11)

where we factorize qσ(x1:T∣x0)q_{\sigma}({\bm{x}}_{1:T}|{\bm{x}}_{0})qσ​(x1:T​∣x0​) according to Eq. (6) and pθ(x0:T)p_{\theta}({\bm{x}}_{0:T})pθ​(x0:T​) according to Eq. (1).

其中我们按式 (6) 分解 qσ(x1:T∣x0)q_{\sigma}({\bm{x}}_{1:T}|{\bm{x}}_{0})qσ​(x1:T​∣x0​),按式 (1) 分解 pθ(x0:T)p_{\theta}({\bm{x}}_{0:T})pθ​(x0:T​)。

From the definition of JσJ_{\sigma}Jσ​, it would appear that a different model has to be trained for every choice of σ\sigmaσ, since it corresponds to a different variational objective (and a different generative process). However, JσJ_{\sigma}Jσ​ is equivalent to LγL_{\gamma}Lγ​ for certain weights γ\gammaγ, as we show below.

从 JσJ_{\sigma}Jσ​ 的定义看,似乎对每个 σ\sigmaσ 都要训练不同模型,因为它对应不同变分目标(以及不同生成过程)。但如下所示,对某些权重 γ\gammaγ,JσJ_{\sigma}Jσ​ 等价于 LγL_{\gamma}Lγ​。

Theorem 1.

For all σ>0\sigma>{\bm{0}}σ>0, there exists γ∈R>0T\gamma\in\mathbb{R}_{>0}^{T}γ∈R>0T​ and C∈RC\in\mathbb{R}C∈R, such that Jσ=Lγ+CJ_{\sigma}=L_{\gamma}+CJσ​=Lγ​+C.

定理 1。

对一切 σ>0\sigma>{\bm{0}}σ>0,存在 γ∈R>0T\gamma\in\mathbb{R}_{>0}^{T}γ∈R>0T​ 与 C∈RC\in\mathbb{R}C∈R,使得 Jσ=Lγ+CJ_{\sigma}=L_{\gamma}+CJσ​=Lγ​+C.

The variational objective LγL_{\gamma}Lγ​ is special in the sense that if parameters θ\thetaθ of the models ϵθ(t)\epsilon_{\theta}^{(t)}ϵθ(t)​ are not shared across different ttt, then the optimal solution for ϵθ\epsilon_{\theta}ϵθ​ will not depend on the weights γ\gammaγ (as global optimum is achieved by separately maximizing each term in the sum). This property of LγL_{\gamma}Lγ​ has two implications. On the one hand, this justified the use of L1L_{\bm{1}}L1​ as a surrogate objective function for the variational lower bound in DDPMs; on the other hand, since JσJ_{\sigma}Jσ​ is equivalent to some LγL_{\gamma}Lγ​ from Theorem 1, the optimal solution of JσJ_{\sigma}Jσ​ is also the same as that of L1L_{\bm{1}}L1​. Therefore, if parameters are not shared across ttt in the model ϵθ\epsilon_{\theta}ϵθ​, then the L1L_{\bm{1}}L1​ objective used by Ho et al. 2020 can be used as a surrogate objective for the variational objective JσJ_{\sigma}Jσ​ as well.

变分目标 LγL_{\gamma}Lγ​ 的特殊之处在于:若模型 ϵθ(t)\epsilon_{\theta}^{(t)}ϵθ(t)​ 的参数 θ\thetaθ 在不同 ttt 之间不共享,则 ϵθ\epsilon_{\theta}ϵθ​ 的最优解不依赖权重 γ\gammaγ(因为全局最优可通过分别最大化求和中的每一项达到)。LγL_{\gamma}Lγ​ 的这一性质有两重含义。一方面,它为在 DDPM 中用 L1L_{\bm{1}}L1​ 作为变分下界的替代目标提供了理由;另一方面,由定理 1,JσJ_{\sigma}Jσ​ 等价于某 LγL_{\gamma}Lγ​,因而 JσJ_{\sigma}Jσ​ 的最优解也与 L1L_{\bm{1}}L1​ 相同。因此,若模型 ϵθ\epsilon_{\theta}ϵθ​ 中参数不跨 ttt 共享,则 Ho et al. 2020 使用的 L1L_{\bm{1}}L1​ 目标也可作为变分目标 JσJ_{\sigma}Jσ​ 的替代目标。

4 Sampling from Generalized Generative Processes

4 从广义生成过程采样

With L1L_{\bm{1}}L1​ as the objective, we are not only learning a generative process for the Markovian inference process considered in Sohl-Dickstein et al. 2015 and Ho et al. 2020, but also generative processes for many non-Markovian forward processes parametrized by σ\sigmaσ that we have described. Therefore, we can essentially use pretrained DDPM models as the solutions to the new objectives, and focus on finding a generative process that is better at producing samples subject to our needs by changing σ\sigmaσ.

以 L1L_{\bm{1}}L1​ 为目标时,我们不仅在为 Sohl-Dickstein et al. 2015 与 Ho et al. 2020 所考虑的马尔可夫推断过程学习生成过程,也为由 σ\sigmaσ 参数化的许多非马尔可夫前向过程学习生成过程。因此,本质上可以把预训练 DDPM 模型当作新目标的解,并通过改变 σ\sigmaσ 去寻找更符合需求的生成过程,而无需重训。

4.1 Denoising Diffusion Implicit Models

From pθ(x1:T)p_{\theta}({\bm{x}}_{1:T})pθ​(x1:T​) in Eq. (10), one can generate a sample xt−1{\bm{x}}_{t-1}xt−1​ from a sample xt{\bm{x}}_{t}xt​ via:

由式 (10) 中的 pθ(x1:T)p_{\theta}({\bm{x}}_{1:T})pθ​(x1:T​),可从样本 xt{\bm{x}}_{t}xt​ 生成样本 xt−1{\bm{x}}_{t-1}xt−1​:

xt−1=αt−1(xt−1−αtϵθ(t)(xt)αt)⏟“ predicted x0”+1−αt−1−σt2⋅ϵθ(t)(xt)⏟“direction pointing to xt”+σtϵt⏟random noise(12)\displaystyle{\bm{x}}_{t-1} \\ \displaystyle=\sqrt{\alpha_{t-1}}\underbrace{\left(\frac{{\bm{x}}_{t}-\sqrt{1-\alpha_{t}}\epsilon_{\theta}^{(t)}({\bm{x}}_{t})}{\sqrt{\alpha_{t}}}\right)}_{\text{`` predicted }{\bm{x}}_{0}\text{''}}+\underbrace{\sqrt{1-\alpha_{t-1}-\sigma_{t}^{2}}\cdot\epsilon_{\theta}^{(t)}({\bm{x}}_{t})}_{\text{``direction pointing to }{\bm{x}}_{t}\text{''}}+\underbrace{\sigma_{t}\epsilon_{t}}_{\text{random noise}} \tag{12}xt−1​=αt−1​​“ predicted x0​”(αt​​xt​−1−αt​​ϵθ(t)​(xt​)​)​​+“direction pointing to xt​”1−αt−1​−σt2​​⋅ϵθ(t)​(xt​)​​+random noiseσt​ϵt​​​(12)

where ϵt∼N(0,I)\epsilon_{t}\sim{\mathcal{N}}({\bm{0}},{\bm{I}})ϵt​∼N(0,I) is standard Gaussian noise independent of xt{\bm{x}}_{t}xt​, and we define α0:=1\alpha_{0}:=1α0​:=1. Different choices of σ\sigmaσ values results in different generative processes, all while using the same model ϵθ\epsilon_{\theta}ϵθ​, so re-training the model is unnecessary. When σt=(1−αt−1)/(1−αt)1−αt/αt−1\sigma_{t}=\sqrt{(1-\alpha_{t-1})/(1-\alpha_{t})}\sqrt{1-\alpha_{t}/\alpha_{t-1}}σt​=(1−αt−1​)/(1−αt​)​1−αt​/αt−1​​ for all ttt, the forward process becomes Markovian, and the generative process becomes a DDPM.

其中 ϵt∼N(0,I)\epsilon_{t}\sim{\mathcal{N}}({\bm{0}},{\bm{I}})ϵt​∼N(0,I) 是与 xt{\bm{x}}_{t}xt​ 独立的标准高斯噪声,并定义 α0:=1\alpha_{0}:=1α0​:=1。不同 σ\sigmaσ 取值给出不同生成过程,却共用同一模型 ϵθ\epsilon_{\theta}ϵθ​,因而无需重训。当对一切 ttt 取 σt=(1−αt−1)/(1−αt)1−αt/αt−1\sigma_{t}=\sqrt{(1-\alpha_{t-1})/(1-\alpha_{t})}\sqrt{1-\alpha_{t}/\alpha_{t-1}}σt​=(1−αt−1​)/(1−αt​)​1−αt​/αt−1​​ 时,前向过程变为马尔可夫,生成过程变为 DDPM。

We note another special case when σt=0\sigma_{t}=0σt​=0 for all ttt[^5]; the forward process becomes deterministic given xt−1{\bm{x}}_{t-1}xt−1​ and x0{\bm{x}}_{0}x0​, except for t=1t=1t=1; in the generative process, the coefficient before the random noise ϵt\epsilon_{t}ϵt​ becomes zero. The resulting model becomes an implicit probabilistic model (Mohamed & Lakshminarayanan 2016), where samples are generated from latent variables with a fixed procedure (from xT{\bm{x}}_{T}xT​ to x0{\bm{x}}_{0}x0​). We name this the denoising diffusion implicit model (DDIM, pronounced /d:Im/), because it is an implicit probabilistic model trained with the DDPM objective (despite the forward process no longer being a diffusion).

另一特殊情形是对一切 ttt 取 σt=0\sigma_{t}=0σt​=0[^5]:给定 xt−1{\bm{x}}_{t-1}xt−1​ 与 x0{\bm{x}}_{0}x0​,前向过程变为确定性的(t=1t=1t=1 除外);生成过程中随机噪声 ϵt\epsilon_{t}ϵt​ 前的系数变为零。所得模型成为隐式概率模型 (Mohamed & Lakshminarayanan 2016),样本由潜变量经固定程序(从 xT{\bm{x}}_{T}xT​ 到 x0{\bm{x}}_{0}x0​)生成。我们称之为去噪扩散隐式模型(DDIM,读作 /d:Im/),因为它虽用 DDPM 目标训练,却是隐式概率模型(尽管前向过程已不再是扩散)。

4.2 Accelerated generation processes

4.2 加速生成过程

In the previous sections, the generative process is considered as the approximation to the reverse process; since of the forward process has TTT steps, the generative process is also forced to sample TTT steps. However, as the denoising objective L1L_{\bm{1}}L1​ does not depend on the specific forward procedure as long as qσ(xt∣x0)q_{\sigma}({\bm{x}}_{t}|{\bm{x}}_{0})qσ​(xt​∣x0​) is fixed, we may also consider forward processes with lengths smaller than TTT, which accelerates the corresponding generative processes without having to train a different model.

前几节把生成过程视为反向过程的近似;由于前向过程有 TTT 步,生成过程也被强制采样 TTT 步。但只要 qσ(xt∣x0)q_{\sigma}({\bm{x}}_{t}|{\bm{x}}_{0})qσ​(xt​∣x0​) 固定,去噪目标 L1L_{\bm{1}}L1​ 就不依赖具体前向程序,因而也可考虑长度小于 TTT 的前向过程,从而在无需另训模型的情况下加速对应生成过程。

Figure 2: Graphical model for accelerated generation, where τ=[1,3]\tau=[1,3]τ=[1,3].

图 2:加速生成的图模型,其中 τ=[1,3]\tau=[1,3]τ=[1,3]。

Let us consider the forward process as defined not on all the latent variables x1:T{\bm{x}}_{1:T}x1:T​, but on a subset {xτ1,…,xτS}\{{\bm{x}}_{\tau_{1}},\ldots,{\bm{x}}_{\tau_{S}}\}{xτ1​​,…,xτS​​}, where τ\tauτ is an increasing sub-sequence of [1,…,T][1,\ldots,T][1,…,T] of length SSS. In particular, we define the sequential forward process over xτ1,…,xτS{\bm{x}}_{\tau_{1}},\ldots,{\bm{x}}_{\tau_{S}}xτ1​​,…,xτS​​ such that q(xτi∣x0)=N(ατix0,(1−ατi)I)q({\bm{x}}_{\tau_{i}}|{\bm{x}}_{0})={\mathcal{N}}(\sqrt{\alpha_{\tau_{i}}}{\bm{x}}_{0},(1-\alpha_{\tau_{i}}){\bm{I}})q(xτi​​∣x0​)=N(ατi​​​x0​,(1−ατi​​)I) matches the “marginals” (see Figure 2 for an illustration). The generative process now samples latent variables according to reversed(τ)\text{reversed}(\tau)reversed(τ), which we term (sampling) trajectory. When the length of the sampling trajectory is much smaller than TTT, we may achieve significant increases in computational efficiency due to the iterative nature of the sampling process.

考虑前向过程不是定义在全部潜变量 x1:T{\bm{x}}_{1:T}x1:T​ 上,而是定义在子集 {xτ1,…,xτS}\{{\bm{x}}_{\tau_{1}},\ldots,{\bm{x}}_{\tau_{S}}\}{xτ1​​,…,xτS​​} 上,其中 τ\tauτ 是 [1,…,T][1,\ldots,T][1,…,T] 的长度为 SSS 的递增子序列。特别地,我们在 xτ1,…,xτS{\bm{x}}_{\tau_{1}},\ldots,{\bm{x}}_{\tau_{S}}xτ1​​,…,xτS​​ 上定义序列前向过程,使 q(xτi∣x0)=N(ατix0,(1−ατi)I)q({\bm{x}}_{\tau_{i}}|{\bm{x}}_{0})={\mathcal{N}}(\sqrt{\alpha_{\tau_{i}}}{\bm{x}}_{0},(1-\alpha_{\tau_{i}}){\bm{I}})q(xτi​​∣x0​)=N(ατi​​​x0​,(1−ατi​​)I) 匹配「边缘」(示意见图 2)。生成过程现在按 reversed(τ)\text{reversed}(\tau)reversed(τ) 采样潜变量,我们称之为*(采样)轨迹*。当采样轨迹长度远小于 TTT 时,因采样过程的迭代本质,可显著提高计算效率。

Using a similar argument as in Section 3, we can justify using the model trained with the L1L_{\bm{1}}L1​ objective, so no changes are needed in training. We show that only slight changes to the updates in Eq. (12) are needed to obtain the new, faster generative processes, which applies to DDPM, DDIM, as well as all generative processes considered in Eq. (10). We include these details in Appendix C.1.

用与第 3 节类似的论证,可以说明使用以 L1L_{\bm{1}}L1​ 目标训练的模型是合理的,因而训练无需改动。我们证明:对式 (12) 的更新只需轻微修改,即可得到新的、更快的生成过程,适用于 DDPM、DDIM 以及式 (10) 中考虑的全部生成过程。细节见附录 C.1。

In principle, this means that we can train a model with an arbitrary number of forward steps but only sample from some of them in the generative process. Therefore, the trained model could consider many more steps than what is considered in (Ho et al. 2020) or even a continuous time variable ttt (Chen et al. 2020). We leave empirical investigations of this aspect as future work.

原则上,这意味着可用任意数量的前向步训练模型,但在生成过程中只从其中一部分采样。因此,训练模型可考虑远多于 (Ho et al. 2020) 的步数,甚至连续时间变量 ttt (Chen et al. 2020)。经验研究留作未来工作。

4.3 Relevance to Neural ODEs

4.3 与 Neural ODE 的关系

Moreover, we can rewrite the DDIM iterate according to Eq. (12), and its similarity to Euler integration for solving ordinary differential equations (ODEs) becomes more apparent:

此外,可按式 (12) 改写 DDIM 迭代,其与求解常微分方程(ODE)的欧拉积分的相似性更加明显:

xt−Δtαt−Δt=xtαt+(1−αt−Δtαt−Δt−1−αtαt)ϵθ(t)(xt)(13)\displaystyle\frac{{\bm{x}}_{t-\Delta t}}{\sqrt{\alpha_{t-\Delta t}}}=\frac{{\bm{x}}_{t}}{\sqrt{\alpha_{t}}}+\left(\sqrt{\frac{1-\alpha_{t-\Delta t}}{\alpha_{t-\Delta t}}}-\sqrt{\frac{1-\alpha_{t}}{\alpha_{t}}}\right)\epsilon_{\theta}^{(t)}({\bm{x}}_{t}) \tag{13}αt−Δt​​xt−Δt​​=αt​​xt​​+(αt−Δt​1−αt−Δt​​​−αt​1−αt​​​)ϵθ(t)​(xt​)(13)

To derive the corresponding ODE, we can reparameterize (1−α/α)(\sqrt{1-\alpha}/\sqrt{\alpha})(1−α​/α​) with σ\sigmaσ and (x/α)({\bm{x}}/\sqrt{\alpha})(x/α​) with xˉ\bar{{\bm{x}}}xˉ. In the continuous case, σ\sigmaσ and x{\bm{x}}x are functions of ttt, where σ:R≥0→R≥0\sigma:{\mathbb{R}}_{\geq 0}\to{\mathbb{R}}_{\geq 0}σ:R≥0​→R≥0​ is continous, increasing with σ(0)=0\sigma(0)=0σ(0)=0. Equation (13) with can be treated as a Euler method over the following ODE:

为导出对应 ODE,可用 σ\sigmaσ 重参数化 (1−α/α)(\sqrt{1-\alpha}/\sqrt{\alpha})(1−α​/α​),用 xˉ\bar{{\bm{x}}}xˉ 重参数化 (x/α)({\bm{x}}/\sqrt{\alpha})(x/α​)。连续情形下,σ\sigmaσ 与 x{\bm{x}}x 是 ttt 的函数,其中 σ:R≥0→R≥0\sigma:{\mathbb{R}}_{\geq 0}\to{\mathbb{R}}_{\geq 0}σ:R≥0​→R≥0​ 连续、递增且 σ(0)=0\sigma(0)=0σ(0)=0。带式 (13) 的更新可视为如下 ODE 上的欧拉法:

dxˉ(t)=ϵθ(t)(xˉ(t)σ2+1)dσ(t),(14)\displaystyle\mathrm{d}\bar{{\bm{x}}}(t)=\epsilon_{\theta}^{(t)}\left(\frac{\bar{{\bm{x}}}(t)}{\sqrt{\sigma^{2}+1}}\right)\mathrm{d}\sigma(t), \tag{14}dxˉ(t)=ϵθ(t)​(σ2+1​xˉ(t)​)dσ(t),(14)

where the initial conditions is x(T)∼N(0,σ(T)){\bm{x}}(T)\sim{\mathcal{N}}(0,\sigma(T))x(T)∼N(0,σ(T)) for a very large σ(T)\sigma(T)σ(T) (which corresponds to the case of α≈0\alpha\approx 0α≈0). This suggests that with enough discretization steps, the we can also reverse the generation process (going from t=0t=0t=0 to TTT), which encodes x0{\bm{x}}_{0}x0​ to xT{\bm{x}}_{T}xT​ and simulates the reverse of the ODE in Eq. (14). This suggests that unlike DDPM, we can use DDIM to obtain encodings of the observations (as the form of xT{\bm{x}}_{T}xT​), which might be useful for other downstream applications that requires latent representations of a model.

初值为 x(T)∼N(0,σ(T)){\bm{x}}(T)\sim{\mathcal{N}}(0,\sigma(T))x(T)∼N(0,σ(T)),且 σ(T)\sigma(T)σ(T) 很大(对应 α≈0\alpha\approx 0α≈0)。这表明在足够多的离散化步下,我们也可反转生成过程(从 t=0t=0t=0 走到 TTT),把 x0{\bm{x}}_{0}x0​ 编码到 xT{\bm{x}}_{T}xT​,并模拟式 (14) 中 ODE 的逆。这表明与 DDPM 不同,我们可用 DDIM 得到观测的编码(形式为 xT{\bm{x}}_{T}xT​),这可能对需要模型潜表示的其他下游应用有用。

In a concurrent work, (Song et al. 2020) proposed a “probability flow ODE” that aims to recover the marginal densities of a stochastic differential equation (SDE) based on scores, from which a similar sampling schedule can be obtained. Here, we state that the our ODE is equivalent to a special case of theirs (which corresponds to a continuous-time analog of DDPM).

同期工作 (Song et al. 2020) 提出「概率流 ODE」,旨在恢复基于分数的随机微分方程(SDE)的边缘密度,并可得到类似采样日程。此处我们指出:我们的 ODE 等价于他们的一个特例(对应 DDPM 的连续时间类比)。

Proposition 1.

The ODE in Eq. (14) with the optimal model ϵθ(t)\epsilon_{\theta}^{(t)}ϵθ(t)​ has an equivalent probability flow ODE corresponding to the “Variance-Exploding” SDE in Song et al. 2020.

命题 1。

式 (14) 中带最优模型 ϵθ(t)\epsilon_{\theta}^{(t)}ϵθ(t)​ 的 ODE,有等价的概率流 ODE,对应于 Song et al. 2020 中的「方差爆炸」SDE。

We include the proof in Appendix B. While the ODEs are equivalent, the sampling procedures are not, since the Euler method for the probability flow ODE will make the following update:

证明见附录 B。尽管 ODE 等价,采样程序并不相同,因为概率流 ODE 的欧拉法将做如下更新:

xt−Δtαt−Δt=xtαt+12(1−αt−Δtαt−Δt−1−αtαt)⋅αt1−αt⋅ϵθ(t)(xt)(15)\displaystyle\frac{{\bm{x}}_{t-\Delta t}}{\sqrt{\alpha_{t-\Delta t}}}=\frac{{\bm{x}}_{t}}{\sqrt{\alpha_{t}}}+\frac{1}{2}\left(\frac{1-\alpha_{t-\Delta t}}{\alpha_{t-\Delta t}}-\frac{1-\alpha_{t}}{\alpha_{t}}\right)\cdot\sqrt{\frac{\alpha_{t}}{1-\alpha_{t}}}\cdot\epsilon_{\theta}^{(t)}({\bm{x}}_{t}) \tag{15}αt−Δt​​xt−Δt​​=αt​​xt​​+21​(αt−Δt​1−αt−Δt​​−αt​1−αt​​)⋅1−αt​αt​​​⋅ϵθ(t)​(xt​)(15)

which is equivalent to ours if αt\alpha_{t}αt​ and αt−Δt\alpha_{t-\Delta t}αt−Δt​ are close enough. In fewer sampling steps, however, these choices will make a difference; we take Euler steps with respect to dσ(t)\mathrm{d}\sigma(t)dσ(t) (which depends less directly on the scaling of “time” ttt) whereas Song et al. 2020 take Euler steps with respect to dt\mathrm{d}tdt.

若 αt\alpha_{t}αt​ 与 αt−Δt\alpha_{t-\Delta t}αt−Δt​ 足够接近,则与我们的更新等价。但在更少采样步时,这些选择会有差别:我们相对 dσ(t)\mathrm{d}\sigma(t)dσ(t) 走欧拉步(对「时间」ttt 的缩放依赖更间接),而 Song et al. 2020 相对 dt\mathrm{d}tdt 走欧拉步。

5 Experiments

5 实验

In this section, we show that DDIMs outperform DDPMs in terms of image generation when fewer iterations are considered, giving speed ups of 10×10\times10× to 100×100\times100× over the original DDPM generation process. Moreover, unlike DDPMs, once the initial latent variables xT{\bm{x}}_{T}xT​ are fixed, DDIMs retain high-level image features regardless of the generation trajectory, so they are able to perform interpolation directly from the latent space. DDIMs can also be used to encode samples that reconstruct them from the latent code, which DDPMs cannot do due to the stochastic sampling process.

本节表明:在考虑更少迭代时,DDIM 在图像生成上优于 DDPM,相对原始 DDPM 生成过程可加速 10×10\times10× 到 100×100\times100×。此外,与 DDPM 不同,一旦固定初始潜变量 xT{\bm{x}}_{T}xT​,无论生成轨迹如何,DDIM 都保留高层图像特征,因而能直接从潜空间插值。DDIM 还可用于编码样本并从潜码重建,而 DDPM 因采样随机无法做到。

For each dataset, we use the same trained model with T=1000T=1000T=1000 and the objective being LγL_{\gamma}Lγ​ from Eq. (5) with γ=1\gamma={\bm{1}}γ=1; as we argued in Section 3, no changes are needed with regards to the training procedure. The only changes that we make is how we produce samples from the model; we achieve this by controlling τ\tauτ (which controls how fast the samples are obtained) and σ\sigmaσ (which interpolates between the deterministic DDIM and the stochastic DDPM).

对每个数据集,我们使用同一以 T=1000T=1000T=1000、目标为式 (5) 中 γ=1\gamma={\bm{1}}γ=1 的 LγL_{\gamma}Lγ​ 训练的模型;如第 3 节所论,训练过程无需改动。唯一改动是如何从模型产出样本;我们通过控制 τ\tauτ(控制采样有多快)与 σ\sigmaσ(在确定性 DDIM 与随机 DDPM 之间插值)实现。

We consider different sub-sequences τ\tauτ of [1,…,T][1,\ldots,T][1,…,T] and different variance hyperparameters σ\sigmaσ indexed by elements of τ\tauτ. To simplify comparisons, we consider σ\sigmaσ with the form:

我们考虑 [1,…,T][1,\ldots,T][1,…,T] 的不同子序列 τ\tauτ,以及由 τ\tauτ 元素索引的不同方差超参数 σ\sigmaσ。为简化比较,考虑如下形式的 σ\sigmaσ:

στi(η)=η(1−ατi−1)/(1−ατi)1−ατi/ατi−1,(16)\displaystyle\sigma_{\tau_{i}}(\eta)=\eta\sqrt{(1-\alpha_{\tau_{i-1}})/(1-\alpha_{\tau_{i}})}\sqrt{1-{\alpha_{\tau_{i}}}/{\alpha_{\tau_{i-1}}}}, \tag{16}στi​​(η)=η(1−ατi−1​​)/(1−ατi​​)​1−ατi​​/ατi−1​​​,(16)

where η∈R≥0\eta\in\mathbb{R}_{\geq 0}η∈R≥0​ is a hyperparameter that we can directly control. This includes an original DDPM generative process when η=1\eta=1η=1 and DDIM when η=0\eta=0η=0. We also consider DDPM where the random noise has a larger standard deviation than σ(1)\sigma(1)σ(1), which we denote as σ^\hat{\sigma}σ^: σ^τi=1−ατi/ατi−1\hat{\sigma}_{\tau_{i}}=\sqrt{1-{\alpha_{\tau_{i}}}/{\alpha_{\tau_{i-1}}}}σ^τi​​=1−ατi​​/ατi−1​​​ . This is used by the implementation in Ho et al. 2020 only to obtain the CIFAR10 samples, but not samples of the other datasets. We include more details in Appendix D.

其中 η∈R≥0\eta\in\mathbb{R}_{\geq 0}η∈R≥0​ 是可直接控制的超参数。这包含 η=1\eta=1η=1 时的原始 DDPM 生成过程与 η=0\eta=0η=0 时的 DDIM。我们也考虑随机噪声标准差大于 σ(1)\sigma(1)σ(1) 的 DDPM,记为 σ^\hat{\sigma}σ^:σ^τi=1−ατi/ατi−1\hat{\sigma}_{\tau_{i}}=\sqrt{1-{\alpha_{\tau_{i}}}/{\alpha_{\tau_{i-1}}}}σ^τi​​=1−ατi​​/ατi−1​​​。Ho et al. 2020 的实现仅在获取 CIFAR10 样本时使用它,其他数据集样本则不用。更多细节见附录 D。

5.1 Sample quality and efficiency

5.1 样本质量与效率

In Table 1, we report the quality of the generated samples with models trained on CIFAR10 and CelebA, as measured by Frechet Inception Distance (FID (Heusel et al. 2017)), where we vary the number of timesteps used to generate a sample (dim⁡(τ)\dim(\tau)dim(τ)) and the stochasticity of the process (η\etaη). As expected, the sample quality becomes higher as we increase dim⁡(τ)\dim(\tau)dim(τ), presenting a trade-off between sample quality and computational costs. We observe that DDIM (η=0\eta=0η=0) achieves the best sample quality when dim⁡(τ)\dim(\tau)dim(τ) is small, and DDPM (η=1\eta=1η=1 and σ^\hat{\sigma}σ^) typically has worse sample quality compared to its less stochastic counterparts with the same dim⁡(τ)\dim(\tau)dim(τ), except for the case for dim⁡(τ)=1000\dim(\tau)=1000dim(τ)=1000 and σ^\hat{\sigma}σ^ reported by Ho et al. 2020 where DDIM is marginally worse. However, the sample quality of σ^\hat{\sigma}σ^ becomes much worse for smaller dim⁡(τ)\dim(\tau)dim(τ), which suggests that it is ill-suited for shorter trajectories. DDIM, on the other hand, achieves high sample quality much more consistently.

表 1 报告在 CIFAR10 与 CelebA 上训练的模型生成样本质量,以 Frechet Inception Distance(FID (Heusel et al. 2017))度量;我们改变生成样本所用时间步数(dim⁡(τ)\dim(\tau)dim(τ))与过程随机性(η\etaη)。一如预期,增大 dim⁡(τ)\dim(\tau)dim(τ) 时样本质量变高,呈现样本质量与计算成本的权衡。我们观察到:当 dim⁡(τ)\dim(\tau)dim(τ) 较小时,DDIM(η=0\eta=0η=0)取得最佳样本质量;在相同 dim⁡(τ)\dim(\tau)dim(τ) 下,DDPM(η=1\eta=1η=1 与 σ^\hat{\sigma}σ^)通常比更不随机的对应物更差,唯一例外是 Ho et al. 2020 报告的 dim⁡(τ)=1000\dim(\tau)=1000dim(τ)=1000 且用 σ^\hat{\sigma}σ^ 时 DDIM 略差。但 σ^\hat{\sigma}σ^ 在更小 dim⁡(τ)\dim(\tau)dim(τ) 时质量急剧变差,说明它不适合更短轨迹。相较之下,DDIM 能更稳定地达到高质量。

In Figure 3, we show CIFAR10 and CelebA samples with the same number of sampling steps and varying σ\sigmaσ. For the DDPM, the sample quality deteriorates rapidly when the sampling trajectory has 10 steps. For the case of σ^\hat{\sigma}σ^, the generated images seem to have more noisy perturbations under short trajectories; this explains why the FID scores are much worse than other methods, as FID is very sensitive to such perturbations (as discussed in Jolicoeur-Martineau et al. 2020).

图 3 展示相同采样步数、不同 σ\sigmaσ 下的 CIFAR10 与 CelebA 样本。对 DDPM,采样轨迹只有 10 步时质量迅速恶化。对 σ^\hat{\sigma}σ^,短轨迹下生成图像似乎带有更多噪声扰动;这解释了为何 FID 远差于其他方法,因为 FID 对此类扰动非常敏感(见 Jolicoeur-Martineau et al. 2020 讨论)。

In Figure 4, we show that the amount of time needed to produce a sample scales linearly with the length of the sample trajectory. This suggests that DDIM is useful for producing samples more efficiently, as samples can be generated in much fewer steps. Notably, DDIM is able to produce samples with quality comparable to 1000 step models within 202020 to 100100100 steps, which is a 10×10\times10× to 50×50\times50× speed up compared to the original DDPM. Even though DDPM could also achieve reasonable sample quality with 100×100\times100× steps, DDIM requires much fewer steps to achieve this; on CelebA, the FID score of the 100 step DDPM is similar to that of the 20 step DDIM.

图 4 表明产出一个样本所需时间随采样轨迹长度线性增长。这说明 DDIM 有助于更高效产出样本,因为可用少得多的步数生成。值得注意的是,DDIM 能在 202020 到 100100100 步内产出与 1000 步模型可比的质量,相对原始 DDPM 加速 10×10\times10× 到 50×50\times50×。尽管 DDPM 用 100×100\times100× 步也能达到合理质量,DDIM 达到该质量所需步数少得多;在 CelebA 上,100 步 DDPM 的 FID 与 20 步 DDIM 相近。

CIFAR10 (32×3232\times 3232×32) CelebA (64×6464\times 6464×64)
SSS 10 20 50 100 1000 10 20 50 100 1000
η\etaη 0.00.00.0 13.36 6.84 4.67 4.16 4.04 17.33 13.73 9.17 6.53 3.51
0.2 14.04 7.11 4.77 4.25 4.09 17.66 14.11 9.51 6.79 3.64
0.5 16.66 8.35 5.25 4.46 4.29 19.86 16.06 11.01 8.09 4.28
1.0 41.07 18.36 8.01 5.78 4.73 33.12 26.03 18.48 13.93 5.98
σ^\hat{\sigma}σ^ 367.43 133.37 32.72 9.99 3.17 299.71 183.83 71.71 45.20 3.26

Table 1: CIFAR10 and CelebA image generation measured in FID. η=1.0\eta=1.0η=1.0 and σ^\hat{\sigma}σ^ are cases of DDPM (although Ho et al. 2020 only considered T=1000T=1000T=1000 steps, and S<TS<TS<T can be seen as simulating DDPMs trained with SSS steps), and η=0.0\eta=0.0η=0.0 indicates DDIM.

CIFAR10 (32×3232\times 3232×32) CelebA (64×6464\times 6464×64)
SSS 10 20 50 100 1000 10 20 50 100 1000
η\etaη 0.00.00.0 13.36 6.84 4.67 4.16 4.04 17.33 13.73 9.17 6.53 3.51
0.2 14.04 7.11 4.77 4.25 4.09 17.66 14.11 9.51 6.79 3.64
0.5 16.66 8.35 5.25 4.46 4.29 19.86 16.06 11.01 8.09 4.28
1.0 41.07 18.36 8.01 5.78 4.73 33.12 26.03 18.48 13.93 5.98
σ^\hat{\sigma}σ^ 367.43 133.37 32.72 9.99 3.17 299.71 183.83 71.71 45.20 3.26

表 1:CIFAR10 与 CelebA 图像生成的 FID。η=1.0\eta=1.0η=1.0 与 σ^\hat{\sigma}σ^ 为 DDPM 情形(尽管 Ho et al. 2020 只考虑了 T=1000T=1000T=1000 步,S<TS<TS<T 可视为模拟以 SSS 步训练的 DDPM),η=0.0\eta=0.0η=0.0 表示 DDIM。

Figure 3: CIFAR10 and CelebA samples with dim⁡(τ)=10\dim(\tau)=10dim(τ)=10 and dim⁡(τ)=100\dim(\tau)=100dim(τ)=100.

图 3:dim⁡(τ)=10\dim(\tau)=10dim(τ)=10 与 dim⁡(τ)=100\dim(\tau)=100dim(τ)=100 时的 CIFAR10 与 CelebA 样本。

Figure 4: Hours to sample 50k images with one Nvidia 2080 Ti GPU and samples at different steps.

图 4:在一块 Nvidia 2080 Ti GPU 上采样 5 万张图像所需小时数,以及不同步数下的样本。

5.2 Sample consistency in DDIMs

5.2 DDIM 中的样本一致性

For DDIM, the generative process is deterministic, and x0{\bm{x}}_{0}x0​ would depend only on the initial state xT{\bm{x}}_{T}xT​. In Figure 5, we observe the generated images under different generative trajectories (i.e. different τ\tauτ) while starting with the same initial xT{\bm{x}}_{T}xT​. Interestingly, for the generated images with the same initial xT{\bm{x}}_{T}xT​, most high-level features are similar, regardless of the generative trajectory. In many cases, samples generated with only 20 steps are already very similar to ones generated with 1000 steps in terms of high-level features, with only minor differences in details. Therefore, it would appear that xT{\bm{x}}_{T}xT​ alone would be an informative latent encoding of the image; and minor details that affects sample quality are encoded in the parameters, as longer sample trajectories gives better quality samples but do not significantly affect the high-level features. We show more samples in Appendix D.4.

对 DDIM,生成过程是确定性的,x0{\bm{x}}_{0}x0​ 只依赖初始状态 xT{\bm{x}}_{T}xT​。图 5 中,我们观察从同一初始 xT{\bm{x}}_{T}xT​ 出发、不同生成轨迹(即不同 τ\tauτ)下的生成图像。有趣的是,对相同初始 xT{\bm{x}}_{T}xT​ 的生成图像,无论生成轨迹如何,多数高层特征相似。许多情形下,仅 20 步生成的样本在高层特征上已与 1000 步非常接近,仅细节有小差别。因此,xT{\bm{x}}_{T}xT​ 本身似乎就是图像的信息性潜编码;而影响样本质量的次要细节编码在参数中,因为更长采样轨迹给出更好质量,却不显著改变高层特征。更多样本见附录 D.4。

Figure 5: Samples from DDIM with the same random xT{\bm{x}}_{T}xT​ and different number of steps.

图 5:同一随机 xT{\bm{x}}_{T}xT​、不同步数下的 DDIM 样本。

5.3 Interpolation in deterministic generative processes

5.3 确定性生成过程中的插值

Figure 6: Interpolation of samples from DDIM with dim⁡(τ)=50\dim(\tau)=50dim(τ)=50.

图 6:dim⁡(τ)=50\dim(\tau)=50dim(τ)=50 时 DDIM 样本的插值。

Since the high level features of the DDIM sample is encoded by xT{\bm{x}}_{T}xT​, we are interested to see whether it would exhibit the semantic interpolation effect similar to that observed in other implicit probabilistic models, such as GANs (Goodfellow et al. 2014). This is different from the interpolation procedure in Ho et al. 2020, since in DDPM the same xT{\bm{x}}_{T}xT​ would lead to highly diverse x0{\bm{x}}_{0}x0​ due to the stochastic generative process[^6]. In Figure 6, we show that simple interpolations in xT{\bm{x}}_{T}xT​ can lead to semantically meaningful interpolations between two samples. We include more details and samples in Appendix D.5. This allows DDIM to control the generated images on a high level directly through the latent variables, which DDPMs cannot.

由于 DDIM 样本的高层特征由 xT{\bm{x}}_{T}xT​ 编码,我们关心它是否会表现出与 GAN (Goodfellow et al. 2014) 等其他隐式概率模型类似的语义插值效应。这不同于 Ho et al. 2020 中的插值程序:在 DDPM 中,因生成过程随机,同一 xT{\bm{x}}_{T}xT​ 会导致高度多样的 x0{\bm{x}}_{0}x0​[^6]。图 6 表明,在 xT{\bm{x}}_{T}xT​ 上做简单插值即可得到两样本之间语义有意义的插值。更多细节与样本见附录 D.5。这使得 DDIM 能通过潜变量在高层直接控制生成图像,而 DDPM 做不到。

5.4 Reconstruction from Latent Space

5.4 从潜空间重建

As DDIM is the Euler integration for a particular ODE, it would be interesting to see whether it can encode from x0{\bm{x}}_{0}x0​ to xT{\bm{x}}_{T}xT​ (reverse of Eq. (14)) and reconstruct x0{\bm{x}}_{0}x0​ from the resulting xT{\bm{x}}_{T}xT​ (forward of Eq. (14))[^7]. We consider encoding and decoding on the CIFAR-10 test set with the CIFAR-10 model with SSS steps for both encoding and decoding; we report the per-dimension mean squared error (scaled to [0,1][0,1][0,1]) in Table 2. Our results show that DDIMs have lower reconstruction error for larger SSS values and have properties similar to Neural ODEs and normalizing flows. The same cannot be said for DDPMs due to their stochastic nature.

由于 DDIM 是某 ODE 的欧拉积分,值得看它能否从 x0{\bm{x}}_{0}x0​ 编码到 xT{\bm{x}}_{T}xT​(式 (14) 的逆)并从所得 xT{\bm{x}}_{T}xT​ 重建 x0{\bm{x}}_{0}x0​(式 (14) 的正演)[^7]。我们在 CIFAR-10 测试集上,用 CIFAR-10 模型以 SSS 步做编码与解码;表 2 报告缩放到 [0,1][0,1][0,1] 的逐维均方误差。结果表明:更大的 SSS 下 DDIM 重建误差更低,并具有类似 Neural ODE 与归一化流的性质。DDPM 因随机性不能如是说。

SSS 10 20 50 100 200 500 1000
Error 0.014 0.0065 0.0023 0.0009 0.0004 0.0001 0.00010.00010.0001

Table 2: Reconstruction error with DDIM on CIFAR-10 test set, rounded to 10−410^{-4}10−4.

SSS 10 20 50 100 200 500 1000
Error 0.014 0.0065 0.0023 0.0009 0.0004 0.0001 0.00010.00010.0001

表 2:CIFAR-10 测试集上 DDIM 的重建误差,四舍五入到 10−410^{-4}10−4。

6 Related Work

6 相关工作

Our work is based on a large family of existing methods on learning generative models as transition operators of Markov chains (Sohl-Dickstein et al. 2015; Bengio et al. 2014; Salimans et al. 2014; Song et al. 2017; Goyal et al. 2017; Levy et al. 2017). Among them, denoising diffusion probabilistic models (DDPMs, Ho et al. 2020) and noise conditional score networks (NCSN, Song & Ermon 2019; Song & Ermon 2020) have recently achieved high sample quality comparable to GANs (Brock et al. 2018; Karras et al. 2018). DDPMs optimize a variational lower bound to the log-likelihood, whereas NCSNs optimize the score matching objective (Hyvärinen 2005) over a nonparametric Parzen density estimator of the data (Vincent 2011; Raphan & Simoncelli 2011).

本工作建立在把生成模型学成马尔可夫链转移算子的一大族已有方法之上 (Sohl-Dickstein et al. 2015; Bengio et al. 2014; Salimans et al. 2014; Song et al. 2017; Goyal et al. 2017; Levy et al. 2017)。其中,去噪扩散概率模型(DDPM, Ho et al. 2020)与噪声条件分数网络(NCSN, Song & Ermon 2019; Song & Ermon 2020)近来达到了可比 GAN (Brock et al. 2018; Karras et al. 2018) 的高样本质量。DDPM 优化对数似然的变分下界,而 NCSN 在数据的非参数 Parzen 密度估计上优化分数匹配目标 (Hyvärinen 2005) (Vincent 2011; Raphan & Simoncelli 2011)。

Despite their different motivations, DDPMs and NCSNs are closely related. Both use a denoising autoencoder objective for many noise levels, and both use a procedure similar to Langevin dynamics to produce samples (Neal et al. 2011). Since Langevin dynamics is a discretization of a gradient flow (Jordan et al. 1998), both DDPM and NCSN require many steps to achieve good sample quality. This aligns with the observation that DDPM and existing NCSN methods have trouble generating high-quality samples in a few iterations.

尽管动机不同,DDPM 与 NCSN 密切相关。两者都对许多噪声水平使用去噪自编码目标,两者都用类似 Langevin 动力学的程序产出样本 (Neal et al. 2011)。由于 Langevin 动力学是梯度流的离散化 (Jordan et al. 1998),DDPM 与 NCSN 都需要很多步才能达到好样本质量。这与 DDPM 及现有 NCSN 方法难以在很少迭代内生成高质量样本的观察一致。

DDIM, on the other hand, is an implicit generative model (Mohamed & Lakshminarayanan 2016) where samples are uniquely determined from the latent variables. Hence, DDIM has certain properties that resemble GANs (Goodfellow et al. 2014) and invertible flows (Dinh et al. 2016), such as the ability to produce semantically meaningful interpolations. We derive DDIM from a purely variational perspective, where the restrictions of Langevin dynamics are not relevant; this could partially explain why we are able to observe superior sample quality compared to DDPM under fewer iterations. The sampling procedure of DDIM is also reminiscent of neural networks with continuous depth (Chen et al. 2018; Grathwohl et al. 2018), since the samples it produces from the same latent variable have similar high-level visual features, regardless of the specific sample trajectory.

另一方面,DDIM 是隐式生成模型 (Mohamed & Lakshminarayanan 2016),样本由潜变量唯一决定。因此 DDIM 具有类似 GAN (Goodfellow et al. 2014) 与可逆流 (Dinh et al. 2016) 的某些性质,例如产出语义有意义插值的能力。我们从纯变分视角导出 DDIM,Langevin 动力学的限制在此并不相关;这可部分解释为何在更少迭代下我们能观察到优于 DDPM 的样本质量。DDIM 的采样程序也让人联想到连续深度神经网络 (Chen et al. 2018; Grathwohl et al. 2018):从同一潜变量出发,无论具体采样轨迹如何,产出的样本都有相似的高层视觉特征。

7 Discussion

7 讨论

We have presented DDIMs – an implicit generative model trained with denoising auto-encoding / score matching objectives – from a purely variational perspective. DDIM is able to generate high-quality samples much more efficiently than existing DDPMs and NCSNs, with the ability to perform meaningful interpolations from the latent space. The non-Markovian forward process presented here seems to suggest continuous forward processes other than Gaussian (which cannot be done in the original diffusion framework, since Gaussian is the only stable distribution with finite variance). We also demonstrated a discrete case with a multinomial forward process in Appendix A, and it would be interesting to investigate similar alternatives for other combinatorial structures.

我们从纯变分视角提出了 DDIM——用去噪自编码/分数匹配目标训练的隐式生成模型。相对现有 DDPM 与 NCSN,DDIM 能更高效地生成高质量样本,并能从潜空间做有意义插值。此处给出的非马尔可夫前向过程似乎暗示:除高斯外还可有连续前向过程(在原始扩散框架中做不到,因为有限方差的稳定分布只有高斯)。我们也在附录 A 展示了多项前向过程的离散情形;对其它组合结构研究类似替代会很有趣。

Moreover, since the sampling procedure of DDIMs is similar to that of an neural ODE, it would be interesting to see if methods that decrease the discretization error in ODEs, including multi-step methods such as Adams-Bashforth (Butcher & Goodwin 2008), could be helpful for further improving sample quality in fewer steps (Queiruga et al. 2020). It is also relevant to investigate whether DDIMs exhibit other properties of existing implicit models (Bau et al. 2019).

此外,由于 DDIM 采样程序类似 neural ODE,值得看减少 ODE 离散化误差的方法——包括 Adams-Bashforth (Butcher & Goodwin 2008) 等多步法——是否有助于在更少步内进一步提高样本质量 (Queiruga et al. 2020)。探究 DDIM 是否还表现出现有隐式模型的其他性质 (Bau et al. 2019) 也很相关。

Acknowledgements

The authors would like to thank Yang Song and Shengjia Zhao for helpful discussions over the ideas, Kuno Kim for reviewing an earlier draft of the paper, and Sharvil Nanavati and Sophie Liu for identifying typos. This research was supported by NSF (#1651565, #1522054, #1733686), ONR (N00014-19-1-2145), AFOSR (FA9550-19-1-0024), and Amazon AWS.

作者感谢 Yang Song 与 Shengjia Zhao 对想法的有益讨论,感谢 Kuno Kim 审阅论文初稿,感谢 Sharvil Nanavati 与 Sophie Liu 指出笔误。本研究得到 NSF (#1651565, #1522054, #1733686)、ONR (N00014-19-1-2145)、AFOSR (FA9550-19-1-0024) 与 Amazon AWS 资助。

References

Arjovsky et al. (2017) Martin Arjovsky, Soumith Chintala, and Léon Bottou. Wasserstein GAN. arXiv preprint arXiv:1701.07875 , January 2017.

Bau et al. (2019) David Bau, Jun-Yan Zhu, Jonas Wulff, William Peebles, Hendrik Strobelt, Bolei Zhou, and Antonio Torralba. Seeing what a gan cannot generate. In Proceedings of the IEEE International Conference on Computer Vision , pp. 4502–4511, 2019.

Bengio et al. (2014) Yoshua Bengio, Eric Laufer, Guillaume Alain, and Jason Yosinski. Deep generative stochastic networks trainable by backprop. In International Conference on Machine Learning , pp. 226–234, January 2014.

Bishop (2006) Christopher M Bishop. Pattern recognition and machine learning . springer, 2006.

Brock et al. (2018) Andrew Brock, Jeff Donahue, and Karen Simonyan. Large scale GAN training for high fidelity natural image synthesis. arXiv preprint arXiv:1809.11096 , September 2018.

Butcher & Goodwin (2008) John Charles Butcher and Nicolette Goodwin. Numerical methods for ordinary differential equations , volume 2. Wiley Online Library, 2008.

Chen et al. (2020) Nanxin Chen, Yu Zhang, Heiga Zen, Ron J Weiss, Mohammad Norouzi, and William Chan. WaveGrad: Estimating gradients for waveform generation. arXiv preprint arXiv:2009.00713 , September 2020.

Chen et al. (2018) Ricky T Q Chen, Yulia Rubanova, Jesse Bettencourt, and David Duvenaud. Neural ordinary differential equations. arXiv preprint arXiv:1806.07366 , June 2018.

Dinh et al. (2016) Laurent Dinh, Jascha Sohl-Dickstein, and Samy Bengio. Density estimation using real NVP. arXiv preprint arXiv:1605.08803 , May 2016.

Goodfellow et al. (2014) Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In Advances in neural information processing systems , pp. 2672–2680, 2014.

Goyal et al. (2017) Anirudh Goyal, Nan Rosemary Ke, Surya Ganguli, and Yoshua Bengio. Variational walkback: Learning a transition operator as a stochastic recurrent net. In Advances in Neural Information Processing Systems , pp. 4392–4402, 2017.

Grathwohl et al. (2018) Will Grathwohl, Ricky T Q Chen, Jesse Bettencourt, Ilya Sutskever, and David Duvenaud. FFJORD: Free-form continuous dynamics for scalable reversible generative models. arXiv preprint arXiv:1810.01367 , October 2018.

Gulrajani et al. (2017) Ishaan Gulrajani, Faruk Ahmed, Martin Arjovsky, Vincent Dumoulin, and Aaron C Courville. Improved training of wasserstein gans. In Advances in Neural Information Processing Systems , pp. 5769–5779, 2017.

Heusel et al. (2017) Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. GANs trained by a two Time-Scale update rule converge to a local nash equilibrium. arXiv preprint arXiv:1706.08500 , June 2017.

Ho et al. (2020) Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. arXiv preprint arXiv:2006.11239 , June 2020.

Hyvärinen (2005) Aapo Hyvärinen. Estimation of Non-Normalized statistical models by score matching. Journal of Machine Learning Researc h , 6:695–709, 2005.

Jolicoeur-Martineau et al. (2020) Alexia Jolicoeur-Martineau, Rémi Piché-Taillefer, Rémi Tachet des Combes, and Ioannis Mitliagkas. Adversarial score matching and improved sampling for image generation. September 2020.

Jordan et al. (1998) Richard Jordan, David Kinderlehrer, and Felix Otto. The variational formulation of the fokker–planck equation. SIAM journal on mathematical analysis , 29(1):1–17, 1998.

Karras et al. (2018) Tero Karras, Samuli Laine, and Timo Aila. A Style-Based generator architecture for generative adversarial networks. arXiv preprint arXiv:1812.04948 , December 2018.

Karras et al. (2020) Tero Karras, Samuli Laine, Miika Aittala, Janne Hellsten, Jaakko Lehtinen, and Timo Aila. Analyzing and improving the image quality of stylegan. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition , pp. 8110–8119, 2020.

Kingma & Welling (2013) Diederik P Kingma and Max Welling. Auto-Encoding variational bayes. arXiv preprint arXiv:1312.6114v10 , December 2013.

Levy et al. (2017) Daniel Levy, Matthew D Hoffman, and Jascha Sohl-Dickstein. Generalizing hamiltonian monte carlo with neural networks. arXiv preprint arXiv:1711.09268 , 2017.

Mohamed & Lakshminarayanan (2016) Shakir Mohamed and Balaji Lakshminarayanan. Learning in implicit generative models. arXiv preprint arXiv:1610.03483 , October 2016.

Neal et al. (2011) Radford M Neal et al. Mcmc using hamiltonian dynamics. Handbook of markov chain monte carlo , 2(11):2, 2011.

Queiruga et al. (2020) Alejandro F Queiruga, N Benjamin Erichson, Dane Taylor, and Michael W Mahoney. Continuous-in-depth neural networks. arXiv preprint arXiv:2008.02389 , 2020.

Raphan & Simoncelli (2011) Martin Raphan and Eero P Simoncelli. Least squares estimation without priors or supervision. Neural computation , 23(2):374–420, February 2011. ISSN 0899-7667, 1530-888X.

Rezende & Mohamed (2015) Danilo Jimenez Rezende and Shakir Mohamed. Variational inference with normalizing flows. arXiv preprint arXiv:1505.05770 , May 2015.

Rezende et al. (2014) Danilo Jimenez Rezende, Shakir Mohamed, and Daan Wierstra. Stochastic backpropagation and approximate inference in deep generative models. arXiv preprint arXiv:1401.4082 , 2014.

Ronneberger et al. (2015) Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In International Conference on Medical image computing and computer-assisted intervention , pp. 234–241. Springer, 2015.

Salimans et al. (2014) Tim Salimans, Diederik P Kingma, and Max Welling. Markov chain monte carlo and variational inference: Bridging the gap. arXiv preprint arXiv:1410.6460 , October 2014.

Shoemake (1985) Ken Shoemake. Animating rotation with quaternion curves. In Proceedings of the 12th annual conference on Computer graphics and interactive techniques , pp. 245–254, 1985.

Sohl-Dickstein et al. (2015) Jascha Sohl-Dickstein, Eric A Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. arXiv preprint arXiv:1503.03585 , March 2015.

Song et al. (2017) Jiaming Song, Shengjia Zhao, and Stefano Ermon. A-nice-mc: Adversarial training for mcmc. arXiv preprint arXiv:1706.07561 , June 2017.

Song & Ermon (2019) Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. arXiv preprint arXiv:1907.05600 , July 2019.

Song & Ermon (2020) Yang Song and Stefano Ermon. Improved techniques for training Score-Based generative models. arXiv preprint arXiv:2006.09011 , June 2020.

Song et al. (2020) Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. arXiv preprint arXiv:2011.13456 , 2020.

van den Oord et al. (2016a) Aaron van den Oord, Sander Dieleman, Heiga Zen, Karen Simonyan, Oriol Vinyals, Alex Graves, Nal Kalchbrenner, Andrew Senior, and Koray Kavukcuoglu. WaveNet: A generative model for raw audio. arXiv preprint arXiv:1609.03499 , September 2016a.

van den Oord et al. (2016b) Aaron van den Oord, Nal Kalchbrenner, and Koray Kavukcuoglu. Pixel recurrent neural networks. arXiv preprint arXiv:1601.06759 , January 2016b.

Vincent (2011) Pascal Vincent. A connection between score matching and denoising autoencoders. Neural computation , 23(7):1661–1674, 2011.

Zagoruyko & Komodakis (2016) Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. arXiv preprint arXiv:1605.07146 , May 2016.

Zhao et al. (2018) Shengjia Zhao, Hongyu Ren, Arianna Yuan, Jiaming Song, Noah Goodman, and Stefano Ermon. Bias and generalization in deep generative models: An empirical study. In Advances in Neural Information Processing Systems , pp. 10792–10801, 2018.

Appendix A Non-Markovian Forward Processes for a Discrete Case

附录 A 离散情形的非马尔可夫前向过程

In this section, we describe a non-Markovian forward processes for discrete data and corresponding variational objectives. Since the focus of this paper is to accelerate reverse models corresponding to the Gaussian diffusion, we leave empirical evaluations as future work.

本节描述离散数据的非马尔可夫前向过程及相应变分目标。由于本文重点是加速对应高斯扩散的反向模型,经验评估留作未来工作。

For a categorical observation x0{\bm{x}}_{0}x0​ that is a one-hot vector with KKK possible values, we define the forward process as follows. First, we have q(xt∣x0)q({\bm{x}}_{t}|{\bm{x}}_{0})q(xt​∣x0​) as the following categorical distribution:

对取 KKK 个可能值的 one-hot 向量类别观测 x0{\bm{x}}_{0}x0​,如下定义前向过程。首先,把 q(xt∣x0)q({\bm{x}}_{t}|{\bm{x}}_{0})q(xt​∣x0​) 取为如下类别分布:

q(xt∣x0)=Cat(αtx0+(1−αt)1K)(17)\displaystyle q({\bm{x}}_{t}|{\bm{x}}_{0})=\mathrm{Cat}(\alpha_{t}{\bm{x}}_{0}+(1-\alpha_{t}){\bm{1}}_{K}) \tag{17}q(xt​∣x0​)=Cat(αt​x0​+(1−αt​)1K​)(17)

where 1K∈RK{\bm{1}}_{K}\in\mathbb{R}^{K}1K​∈RK is a vector with all entries being 1/K1/K1/K, and αt\alpha_{t}αt​ decreasing from α0=1\alpha_{0}=1α0​=1 for t=0t=0t=0 to αT=0\alpha_{T}=0αT​=0 for t=Tt=Tt=T. Then we define q(xt−1∣xt,x0)q({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})q(xt−1​∣xt​,x0​) as the following mixture distribution:

其中 1K∈RK{\bm{1}}_{K}\in\mathbb{R}^{K}1K​∈RK 是各项均为 1/K1/K1/K 的向量,αt\alpha_{t}αt​ 从 t=0t=0t=0 的 α0=1\alpha_{0}=1α0​=1 递减到 t=Tt=Tt=T 的 αT=0\alpha_{T}=0αT​=0。然后把 q(xt−1∣xt,x0)q({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})q(xt−1​∣xt​,x0​) 定义为如下混合分布:

$$\displaystyle q({\bm{x}}{t-1}|{\bm{x}}{t},{\bm{x}}{0})=\begin{cases}\mathrm{Cat}({\bm{x}}{t})&\text{with probability }\sigma_{t}\
\mathrm{Cat}({\bm{x}}{0})&\text{with probability }(\alpha{t-1}-\sigma_{t}\alpha_{t})\
\mathrm{Cat}({\bm{1}}{K})&\text{with probability }(1-\alpha{t-1})-(1-\alpha_{t})\sigma_{t}\end{cases}, \tag{18}$$

or equivalently:

或等价地:

q(xt−1∣xt,x0)=Cat(σtxt+(αt−1−σtαt)x0+((1−αt−1)−(1−αt)σt)1K),(19)\displaystyle q({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})=\mathrm{Cat}\left(\sigma_{t}{\bm{x}}_{t}+(\alpha_{t-1}-\sigma_{t}\alpha_{t}){\bm{x}}_{0}+((1-\alpha_{t-1})-(1-\alpha_{t})\sigma_{t}){\bm{1}}_{K}\right), \tag{19}q(xt−1​∣xt​,x0​)=Cat(σt​xt​+(αt−1​−σt​αt​)x0​+((1−αt−1​)−(1−αt​)σt​)1K​),(19)

which is consistent with how we have defined q(xt∣x0)q({\bm{x}}_{t}|{\bm{x}}_{0})q(xt​∣x0​).

这与我们对 q(xt∣x0)q({\bm{x}}_{t}|{\bm{x}}_{0})q(xt​∣x0​) 的定义一致。

Similarly, we can define our reverse process pθ(xt−1∣xt)p_{\theta}({\bm{x}}_{t-1}|{\bm{x}}_{t})pθ​(xt−1​∣xt​) as:

类似地,可把反向过程 pθ(xt−1∣xt)p_{\theta}({\bm{x}}_{t-1}|{\bm{x}}_{t})pθ​(xt−1​∣xt​) 定义为:

pθ(xt−1∣xt)=Cat(σtxt+(αt−1−σtαt)fθ(t)(xt)+((1−αt−1)−(1−αt)σt)1K),(20)\displaystyle p_{\theta}({\bm{x}}_{t-1}|{\bm{x}}_{t})=\mathrm{Cat}\left(\sigma_{t}{\bm{x}}_{t}+(\alpha_{t-1}-\sigma_{t}\alpha_{t})f_{\theta}^{(t)}({\bm{x}}_{t})+((1-\alpha_{t-1})-(1-\alpha_{t})\sigma_{t}){\bm{1}}_{K}\right), \tag{20}pθ​(xt−1​∣xt​)=Cat(σt​xt​+(αt−1​−σt​αt​)fθ(t)​(xt​)+((1−αt−1​)−(1−αt​)σt​)1K​),(20)

where fθ(t)(xt)f_{\theta}^{(t)}({\bm{x}}_{t})fθ(t)​(xt​) maps xt{\bm{x}}_{t}xt​ to a KKK-dimensional vector. As (1−αt−1)−(1−αt)σt→0(1-\alpha_{t-1})-(1-\alpha_{t})\sigma_{t}\to 0(1−αt−1​)−(1−αt​)σt​→0, the sampling process will become less stochastic, in the sense that it will either choose xt{\bm{x}}_{t}xt​ or the predicted x0{\bm{x}}_{0}x0​ with high probability. The KL divergence

其中 fθ(t)(xt)f_{\theta}^{(t)}({\bm{x}}_{t})fθ(t)​(xt​) 把 xt{\bm{x}}_{t}xt​ 映到 KKK 维向量。当 (1−αt−1)−(1−αt)σt→0(1-\alpha_{t-1})-(1-\alpha_{t})\sigma_{t}\to 0(1−αt−1​)−(1−αt​)σt​→0 时,采样过程会变得更不随机:它将以高概率选择 xt{\bm{x}}_{t}xt​ 或预测的 x0{\bm{x}}_{0}x0​。KL 散度

DKL(q(xt−1∣xt,x0)∥pθ(xt−1∣xt))(21)\displaystyle D_{\mathrm{KL}}(q({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})\|p_{\theta}({\bm{x}}_{t-1}|{\bm{x}}_{t})) \tag{21}DKL​(q(xt−1​∣xt​,x0​)∥pθ​(xt−1​∣xt​))(21)

is well-defined, and is simply the KL divergence between two categoricals. Therefore, the resulting variational objective function should be easy to optimize as well. Moreover, as KL divergence is convex, we have this upper bound (which is tight when the right hand side goes to zero):

有良好定义,且就是两个类别分布之间的 KL 散度。因此所得变分目标函数也应易于优化。此外,由于 KL 散度凸,我们有如下上界(当右侧趋于零时紧):

DKL(q(xt−1∣xt,x0)∥pθ(xt−1∣xt))≤(αt−1−σtαt)DKL(Cat(x0)∥Cat(fθ(t)(xt))).\displaystyle D_{\mathrm{KL}}(q({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})\|p_{\theta}({\bm{x}}_{t-1}|{\bm{x}}_{t}))\leq(\alpha_{t-1}-\sigma_{t}\alpha_{t})D_{\mathrm{KL}}(\mathrm{Cat}({\bm{x}}_{0})\|\mathrm{Cat}(f_{\theta}^{(t)}({\bm{x}}_{t}))).DKL​(q(xt−1​∣xt​,x0​)∥pθ​(xt−1​∣xt​))≤(αt−1​−σt​αt​)DKL​(Cat(x0​)∥Cat(fθ(t)​(xt​))).

The right hand side is simply a multi-class classification loss (up to constants), so we can arrive at similar arguments regarding how changes in σt\sigma_{t}σt​ do not affect the objective (up to re-weighting).

右侧(差常数)就是多类分类损失,因而可得到类似论证:σt\sigma_{t}σt​ 的变化(直至重加权)不影响目标。

Appendix B Proofs

附录 B 证明

Lemma 1.

For qσ(x1:T∣x0)q_{\sigma}({\bm{x}}_{1:T}|{\bm{x}}_{0})qσ​(x1:T​∣x0​) defined in Eq. (6) and qσ(xt−1∣xt,x0)q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})qσ​(xt−1​∣xt​,x0​) defined in Eq. (7), we have:

引理 1。

对式 (6) 定义的 qσ(x1:T∣x0)q_{\sigma}({\bm{x}}_{1:T}|{\bm{x}}_{0})qσ​(x1:T​∣x0​) 与式 (7) 定义的 qσ(xt−1∣xt,x0)q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})qσ​(xt−1​∣xt​,x0​),我们有:

qσ(xt∣x0)=N(αtx0,(1−αt)I)(22)\displaystyle q_{\sigma}({\bm{x}}_{t}|{\bm{x}}_{0})={\mathcal{N}}(\sqrt{\alpha_{t}}{\bm{x}}_{0},(1-\alpha_{t}){\bm{I}}) \tag{22}qσ​(xt​∣x0​)=N(αt​​x0​,(1−αt​)I)(22)

Proof.

Assume for any t≤Tt\leq Tt≤T, qσ(xt∣x0)=N(αtx0,(1−αt)I)q_{\sigma}({\bm{x}}_{t}|{\bm{x}}_{0})={\mathcal{N}}(\sqrt{\alpha_{t}}{\bm{x}}_{0},(1-\alpha_{t}){\bm{I}})qσ​(xt​∣x0​)=N(αt​​x0​,(1−αt​)I) holds, if:

证明。

假设对任意 t≤Tt\leq Tt≤T,qσ(xt∣x0)=N(αtx0,(1−αt)I)q_{\sigma}({\bm{x}}_{t}|{\bm{x}}_{0})={\mathcal{N}}(\sqrt{\alpha_{t}}{\bm{x}}_{0},(1-\alpha_{t}){\bm{I}})qσ​(xt​∣x0​)=N(αt​​x0​,(1−αt​)I) 成立,若:

qσ(xt−1∣x0)=N(αt−1x0,(1−αt−1)I)(23)\displaystyle q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{0})={\mathcal{N}}(\sqrt{\alpha_{t-1}}{\bm{x}}_{0},(1-\alpha_{t-1}){\bm{I}}) \tag{23}qσ​(xt−1​∣x0​)=N(αt−1​​x0​,(1−αt−1​)I)(23)

then we can prove the statement with an induction argument for ttt from TTT to 111, since the base case (t=Tt=Tt=T) already holds.

则可对 ttt 从 TTT 到 111 用归纳论证证明该命题,因为基情形(t=Tt=Tt=T)已成立。

First, we have that

首先,我们有

qσ(xt−1∣x0):=∫xtqσ(xt∣x0)qσ(xt−1∣xt,x0)dxtq_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{0}):=\int_{{\bm{x}}_{t}}q_{\sigma}({\bm{x}}_{t}|{\bm{x}}_{0})q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})\mathrm{d}{\bm{x}}_{t}qσ​(xt−1​∣x0​):=∫xt​​qσ​(xt​∣x0​)qσ​(xt−1​∣xt​,x0​)dxt​

and

以及

qσ(xt∣x0)=N(αtx0,(1−αt)I)qσ(xt−1∣xt,x0)=N(αt−1x0+1−αt−1−σt2⋅xt−αtx01−αt,σt2I).(24)\displaystyle q_{\sigma}({\bm{x}}_{t}|{\bm{x}}_{0})={\mathcal{N}}(\sqrt{\alpha_{t}}{\bm{x}}_{0},(1-\alpha_{t}){\bm{I}}) \\ \displaystyle q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})={\mathcal{N}}\left(\sqrt{\alpha_{t-1}}{\bm{x}}_{0}+\sqrt{1-\alpha_{t-1}-\sigma^{2}_{t}}\cdot{\frac{{\bm{x}}_{t}-\sqrt{\alpha_{t}}{\bm{x}}_{0}}{\sqrt{1-\alpha_{t}}}},\sigma_{t}^{2}{\bm{I}}\right). \tag{24}qσ​(xt​∣x0​)=N(αt​​x0​,(1−αt​)I)qσ​(xt−1​∣xt​,x0​)=N(αt−1​​x0​+1−αt−1​−σt2​​⋅1−αt​​xt​−αt​​x0​​,σt2​I).(24)

From Bishop 2006 (2.115), we have that qσ(xt−1∣x0)q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{0})qσ​(xt−1​∣x0​) is Gaussian, denoted as N(μt−1,Σt−1){\mathcal{N}}(\mu_{t-1},\Sigma_{t-1})N(μt−1​,Σt−1​) where

由 Bishop 2006 (2.115),qσ(xt−1∣x0)q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{0})qσ​(xt−1​∣x0​) 是高斯,记为 N(μt−1,Σt−1){\mathcal{N}}(\mu_{t-1},\Sigma_{t-1})N(μt−1​,Σt−1​),其中

μt−1=αt−1x0+1−αt−1−σt2⋅αtx0−αtx01−αt=αt−1x0(26)\displaystyle\mu_{t-1} \\ \displaystyle=\sqrt{\alpha_{t-1}}{\bm{x}}_{0}+\sqrt{1-\alpha_{t-1}-\sigma^{2}_{t}}\cdot{\frac{\sqrt{\alpha_{t}}{\bm{x}}_{0}-\sqrt{\alpha_{t}}{\bm{x}}_{0}}{\sqrt{1-\alpha_{t}}}} \\ \displaystyle=\sqrt{\alpha_{t-1}}{\bm{x}}_{0} \tag{26}μt−1​=αt−1​​x0​+1−αt−1​−σt2​​⋅1−αt​​αt​​x0​−αt​​x0​​=αt−1​​x0​(26)

and

以及

Σt−1=σt2I+1−αt−1−σt21−αt(1−αt)I=(1−αt−1)I(28)\displaystyle\Sigma_{t-1} \\ \displaystyle=\sigma_{t}^{2}{\bm{I}}+\frac{1-\alpha_{t-1}-\sigma^{2}_{t}}{1-\alpha_{t}}(1-\alpha_{t}){\bm{I}}=(1-\alpha_{t-1}){\bm{I}} \tag{28}Σt−1​=σt2​I+1−αt​1−αt−1​−σt2​​(1−αt​)I=(1−αt−1​)I(28)

Therefore, qσ(xt−1∣x0)=N(αt−1x0,(1−αt−1)I)q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{0})={\mathcal{N}}(\sqrt{\alpha_{t-1}}{\bm{x}}_{0},(1-\alpha_{t-1}){\bm{I}})qσ​(xt−1​∣x0​)=N(αt−1​​x0​,(1−αt−1​)I), which allows us to apply the induction argument. ∎

因此 qσ(xt−1∣x0)=N(αt−1x0,(1−αt−1)I)q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{0})={\mathcal{N}}(\sqrt{\alpha_{t-1}}{\bm{x}}_{0},(1-\alpha_{t-1}){\bm{I}})qσ​(xt−1​∣x0​)=N(αt−1​​x0​,(1−αt−1​)I),从而可应用归纳论证。∎

See 1

见 1

Proof.

From the definition of JσJ_{\sigma}Jσ​:

证明。

由 JσJ_{\sigma}Jσ​ 的定义:

Jσ(ϵθ):=Ex0:T∼q(x0:T)[log⁡qσ(xT∣x0)+∑t=2Tlog⁡qσ(xt−1∣xt,x0)−∑t=1Tlog⁡pθ(t)(xt−1∣xt)]≡Ex0:T∼q(x0:T)[∑t=2TDKL(qσ(xt−1∣xt,x0))∥pθ(t)(xt−1∣xt))−log⁡pθ(1)(x0∣x1)](29)\displaystyle J_{\sigma}(\epsilon_{\theta}) \\ \displaystyle:={\mathbb{E}}_{{\bm{x}}_{0:T}\sim q({\bm{x}}_{0:T})}\left[\log q_{\sigma}({\bm{x}}_{T}|{\bm{x}}_{0})+\sum_{t=2}^{T}\log q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})-\sum_{t=1}^{T}\log p_{\theta}^{(t)}({\bm{x}}_{t-1}|{\bm{x}}_{t})\right] \\ \displaystyle\equiv{\mathbb{E}}_{{\bm{x}}_{0:T}\sim q({\bm{x}}_{0:T})}\left[\sum_{t=2}^{T}D_{\mathrm{KL}}(q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0}))\|p_{\theta}^{(t)}({\bm{x}}_{t-1}|{\bm{x}}_{t}))-\log p_{\theta}^{(1)}({\bm{x}}_{0}|{\bm{x}}_{1})\right] \tag{29}Jσ​(ϵθ​):=Ex0:T​∼q(x0:T​)​[logqσ​(xT​∣x0​)+t=2∑T​logqσ​(xt−1​∣xt​,x0​)−t=1∑T​logpθ(t)​(xt−1​∣xt​)]≡Ex0:T​∼q(x0:T​)​[t=2∑T​DKL​(qσ​(xt−1​∣xt​,x0​))∥pθ(t)​(xt−1​∣xt​))−logpθ(1)​(x0​∣x1​)](29)

where we use ≡\equiv≡ to denote “equal up to a value that does not depend on ϵθ\epsilon_{\theta}ϵθ​ (but may depend on qσq_{\sigma}qσ​)”. For t>1t>1t>1:

其中用 ≡\equiv≡ 表示「相等至一个不依赖 ϵθ\epsilon_{\theta}ϵθ​(但可依赖 qσq_{\sigma}qσ​)的值」。对 t>1t>1t>1:

Ex0,xt∼q(x0,xt)[DKL(qσ(xt−1∣xt,x0))∥pθ(t)(xt−1∣xt))]= Ex0,xt∼q(x0,xt)[DKL(qσ(xt−1∣xt,x0))∥qσ(xt−1∣xt,fθ(t)(xt)))]≡ Ex0,xt∼q(x0,xt)[∥x0−fθ(t)(xt)∥222σt2]= Ex0∼q(x0),ϵ∼N(0,I),xt=αtx0+1−αtϵ[∥(xt−1−αtϵ)αt−(xt−1−αtϵθ(t)(xt))αt∥222σt2]= Ex0∼q(x0),ϵ∼N(0,I),xt=αtx0+1−αtϵ[∥ϵ−ϵθ(t)(xt)∥222dσt2αt](30)\displaystyle{\mathbb{E}}_{{\bm{x}}_{0},{\bm{x}}_{t}\sim q({\bm{x}}_{0},{\bm{x}}_{t})}[D_{\mathrm{KL}}(q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0}))\|p_{\theta}^{(t)}({\bm{x}}_{t-1}|{\bm{x}}_{t}))] \\ \displaystyle= \\ \displaystyle\ {\mathbb{E}}_{{\bm{x}}_{0},{\bm{x}}_{t}\sim q({\bm{x}}_{0},{\bm{x}}_{t})}[D_{\mathrm{KL}}(q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0}))\|q_{\sigma}({\bm{x}}_{t-1}|{\bm{x}}_{t},f_{\theta}^{(t)}({\bm{x}}_{t})))] \\ \displaystyle\equiv \\ \displaystyle\ {\mathbb{E}}_{{\bm{x}}_{0},{\bm{x}}_{t}\sim q({\bm{x}}_{0},{\bm{x}}_{t})}\left[\frac{{\lVert{{\bm{x}}_{0}-f_{\theta}^{(t)}({\bm{x}}_{t})}\rVert}_{2}^{2}}{2\sigma_{t}^{2}}\right] \\ \displaystyle= \\ \displaystyle\ {\mathbb{E}}_{{\bm{x}}_{0}\sim q({\bm{x}}_{0}),\epsilon\sim{\mathcal{N}}({\bm{0}},{\bm{I}}),{\bm{x}}_{t}=\sqrt{\alpha_{t}}{\bm{x}}_{0}+\sqrt{1-\alpha_{t}}\epsilon}\left[\frac{{\lVert{\frac{{({\bm{x}}_{t}-\sqrt{1-\alpha_{t}}\epsilon)}}{\sqrt{\alpha_{t}}}-\frac{({\bm{x}}_{t}-\sqrt{1-\alpha_{t}}\epsilon_{\theta}^{(t)}({\bm{x}}_{t}))}{\sqrt{\alpha_{t}}}}\rVert}_{2}^{2}}{2\sigma_{t}^{2}}\right] \\ \displaystyle= \\ \displaystyle\ {\mathbb{E}}_{{\bm{x}}_{0}\sim q({\bm{x}}_{0}),\epsilon\sim{\mathcal{N}}({\bm{0}},{\bm{I}}),{\bm{x}}_{t}=\sqrt{\alpha_{t}}{\bm{x}}_{0}+\sqrt{1-\alpha_{t}}\epsilon}\left[\frac{{\lVert{\epsilon-\epsilon_{\theta}^{(t)}({\bm{x}}_{t})}\rVert}_{2}^{2}}{2d\sigma_{t}^{2}\alpha_{t}}\right] \tag{30}Ex0​,xt​∼q(x0​,xt​)​[DKL​(qσ​(xt−1​∣xt​,x0​))∥pθ(t)​(xt−1​∣xt​))]= Ex0​,xt​∼q(x0​,xt​)​[DKL​(qσ​(xt−1​∣xt​,x0​))∥qσ​(xt−1​∣xt​,fθ(t)​(xt​)))]≡ Ex0​,xt​∼q(x0​,xt​)​​2σt2​∥x0​−fθ(t)​(xt​)∥22​​​= Ex0​∼q(x0​),ϵ∼N(0,I),xt​=αt​​x0​+1−αt​​ϵ​​2σt2​∥αt​​(xt​−1−αt​​ϵ)​−αt​​(xt​−1−αt​​ϵθ(t)​(xt​))​∥22​​​= Ex0​∼q(x0​),ϵ∼N(0,I),xt​=αt​​x0​+1−αt​​ϵ​​2dσt2​αt​∥ϵ−ϵθ(t)​(xt​)∥22​​​(30)

where ddd is the dimension of x0{\bm{x}}_{0}x0​. For t=1t=1t=1:

其中 ddd 是 x0{\bm{x}}_{0}x0​ 的维数。对 t=1t=1t=1:

 Ex0,x1∼q(x0,x1)[−log⁡pθ(1)(x0∣x1)]≡Ex0,x1∼q(x0,x1)[∥x0−fθ(t)(x1)∥222σ12]= Ex0∼q(x0),ϵ∼N(0,I),x1=α1x0+1−αtϵ[∥ϵ−ϵθ(1)(x1)∥222dσ12α1](33)\displaystyle\ {\mathbb{E}}_{{\bm{x}}_{0},{\bm{x}}_{1}\sim q({\bm{x}}_{0},{\bm{x}}_{1})}\left[-\log p_{\theta}^{(1)}({\bm{x}}_{0}|{\bm{x}}_{1})\right]\equiv{\mathbb{E}}_{{\bm{x}}_{0},{\bm{x}}_{1}\sim q({\bm{x}}_{0},{\bm{x}}_{1})}\left[\frac{{\lVert{{\bm{x}}_{0}-f_{\theta}^{(t)}({\bm{x}}_{1})}\rVert}_{2}^{2}}{2\sigma_{1}^{2}}\right] \\ \displaystyle= \\ \displaystyle\ {\mathbb{E}}_{{\bm{x}}_{0}\sim q({\bm{x}}_{0}),\epsilon\sim{\mathcal{N}}({\bm{0}},{\bm{I}}),{\bm{x}}_{1}=\sqrt{\alpha_{1}}{\bm{x}}_{0}+\sqrt{1-\alpha_{t}}\epsilon}\left[\frac{{\lVert{\epsilon-\epsilon_{\theta}^{(1)}({\bm{x}}_{1})}\rVert}_{2}^{2}}{2d\sigma_{1}^{2}\alpha_{1}}\right] \tag{33} Ex0​,x1​∼q(x0​,x1​)​[−logpθ(1)​(x0​∣x1​)]≡Ex0​,x1​∼q(x0​,x1​)​​2σ12​∥x0​−fθ(t)​(x1​)∥22​​​= Ex0​∼q(x0​),ϵ∼N(0,I),x1​=α1​​x0​+1−αt​​ϵ​​2dσ12​α1​∥ϵ−ϵθ(1)​(x1​)∥22​​​(33)

Therefore, when γt=1/(2dσt2αt)\gamma_{t}=1/(2d\sigma_{t}^{2}\alpha_{t})γt​=1/(2dσt2​αt​) for all t∈{1,…,T}t\in\{1,\ldots,T\}t∈{1,…,T}, we have

因此,当对一切 t∈{1,…,T}t\in\{1,\ldots,T\}t∈{1,…,T} 取 γt=1/(2dσt2αt)\gamma_{t}=1/(2d\sigma_{t}^{2}\alpha_{t})γt​=1/(2dσt2​αt​) 时,我们有

Jσ(ϵθ)≡∑t=1T12dσt2αtE[∥ϵθ(t)(xt)−ϵt∥22]=Lγ(ϵθ)(35)\displaystyle J_{\sigma}(\epsilon_{\theta})\equiv\sum_{t=1}^{T}\frac{1}{2d\sigma_{t}^{2}\alpha_{t}}{\mathbb{E}}\left[{\lVert{\epsilon_{\theta}^{(t)}({\bm{x}}_{t})-\epsilon_{t}}\rVert}_{2}^{2}\right]=L_{\gamma}(\epsilon_{\theta}) \tag{35}Jσ​(ϵθ​)≡t=1∑T​2dσt2​αt​1​E[∥ϵθ(t)​(xt​)−ϵt​∥22​]=Lγ​(ϵθ​)(35)

for all ϵθ\epsilon_{\theta}ϵθ​. From the definition of “≡\equiv≡”, we have that Jσ=Lγ+CJ_{\sigma}=L_{\gamma}+CJσ​=Lγ​+C. ∎

对一切 ϵθ\epsilon_{\theta}ϵθ​ 成立。由「≡\equiv≡」的定义,Jσ=Lγ+CJ_{\sigma}=L_{\gamma}+CJσ​=Lγ​+C。∎

See 1

见 1

Proof.

In the context of the proof, we consider ttt as a continous, independent “time” variable and x{\bm{x}}x and α\alphaα as functions of ttt. First, let us consider a reparametrization between DDIM and the VE-SDE[^8] by introducing the variables xˉ\bar{{\bm{x}}}xˉ and σ\sigmaσ:

证明。

在证明语境中,把 ttt 视为连续、独立的「时间」变量,把 x{\bm{x}}x 与 α\alphaα 视为 ttt 的函数。首先,通过引入变量 xˉ\bar{{\bm{x}}}xˉ 与 σ\sigmaσ,考虑 DDIM 与 VE-SDE[^8] 之间的重参数化:

xˉ(t)=xˉ(0)+σ(t)ϵ,ϵ∼N(0,I),(36)\displaystyle\bar{{\bm{x}}}(t)=\bar{{\bm{x}}}(0)+\sigma(t)\epsilon,\quad\epsilon\sim{\mathcal{N}}(0,{\bm{I}}), \tag{36}xˉ(t)=xˉ(0)+σ(t)ϵ,ϵ∼N(0,I),(36)

for t∈[0,∞)t\in[0,\infty)t∈[0,∞) and an increasing continuous function σ:R≥0→R≥0\sigma:{\mathbb{R}}_{\geq 0}\to{\mathbb{R}}_{\geq 0}σ:R≥0​→R≥0​ where σ(0)=0\sigma(0)=0σ(0)=0.

对 t∈[0,∞)t\in[0,\infty)t∈[0,∞),以及递增连续函数 σ:R≥0→R≥0\sigma:{\mathbb{R}}_{\geq 0}\to{\mathbb{R}}_{\geq 0}σ:R≥0​→R≥0​ 且 σ(0)=0\sigma(0)=0σ(0)=0。

We can then define α(t)\alpha(t)α(t) and x(t){\bm{x}}(t)x(t) corresponding to DDIM case as:

于是可定义对应 DDIM 情形的 α(t)\alpha(t)α(t) 与 x(t){\bm{x}}(t)x(t):

xˉ(t)=x(t)α(t)σ(t)=1−α(t)α(t).(37)\displaystyle\bar{{\bm{x}}}(t)=\frac{{\bm{x}}(t)}{\sqrt{\alpha(t)}} \\ \displaystyle\sigma(t)=\sqrt{\frac{1-\alpha(t)}{\alpha(t)}}. \tag{37}xˉ(t)=α(t)​x(t)​σ(t)=α(t)1−α(t)​​.(37)

This also means that:

这也意味着:

x(t)=xˉ(t)σ2(t)+1α(t)=11+σ2(t),(39)\displaystyle{\bm{x}}(t)=\frac{\bar{{\bm{x}}}(t)}{\sqrt{\sigma^{2}(t)+1}} \\ \displaystyle\alpha(t)=\frac{1}{1+\sigma^{2}(t)}, \tag{39}x(t)=σ2(t)+1​xˉ(t)​α(t)=1+σ2(t)1​,(39)

which establishes an bijection between (x,α)({\bm{x}},\alpha)(x,α) and (xˉ,σ)(\bar{{\bm{x}}},\sigma)(xˉ,σ). From Equation (4) we have (note that α(0)=1\alpha(0)=1α(0)=1):

从而在 (x,α)({\bm{x}},\alpha)(x,α) 与 (xˉ,σ)(\bar{{\bm{x}}},\sigma)(xˉ,σ) 之间建立双射。由式 (4)(注意 α(0)=1\alpha(0)=1α(0)=1):

x(t)α(t)=x(0)α(0)+1−α(t)α(t)ϵ,ϵ∼N(0,I)(41)\displaystyle\frac{{\bm{x}}(t)}{\sqrt{\alpha(t)}}=\frac{{\bm{x}}(0)}{\sqrt{\alpha(0)}}+\sqrt{\frac{1-\alpha(t)}{\alpha(t)}}\epsilon,\quad\epsilon\sim{\mathcal{N}}(0,{\bm{I}}) \tag{41}α(t)​x(t)​=α(0)​x(0)​+α(t)1−α(t)​​ϵ,ϵ∼N(0,I)(41)

which can be reparametrized into a form that is consistent with VE-SDE:

可重参数化为与 VE-SDE 一致的形式:

xˉ(t)=xˉ(0)+σ(t)ϵ.(42)\displaystyle\bar{{\bm{x}}}(t)=\bar{{\bm{x}}}(0)+\sigma(t)\epsilon. \tag{42}xˉ(t)=xˉ(0)+σ(t)ϵ.(42)

Now, we derive the ODE forms for both DDIM and VE-SDE and show that they are equivalent.

现在分别推导 DDIM 与 VE-SDE 的 ODE 形式,并证明它们等价。

ODE form for DDIM

We repeat Equation (13) here:

DDIM 的 ODE 形式

此处重复式 (13):

xt−Δtαt−Δt=xtαt+(1−αt−Δtαt−Δt−1−αtαt)ϵθ(t)(xt),(43)\displaystyle\frac{{\bm{x}}_{t-\Delta t}}{\sqrt{\alpha_{t-\Delta t}}}=\frac{{\bm{x}}_{t}}{\sqrt{\alpha_{t}}}+\left(\sqrt{\frac{1-\alpha_{t-\Delta t}}{\alpha_{t-\Delta t}}}-\sqrt{\frac{1-\alpha_{t}}{\alpha_{t}}}\right)\epsilon_{\theta}^{(t)}({\bm{x}}_{t}), \tag{43}αt−Δt​​xt−Δt​​=αt​​xt​​+(αt−Δt​1−αt−Δt​​​−αt​1−αt​​​)ϵθ(t)​(xt​),(43)

which is equivalent to:

它等价于:

xˉ(t−Δt)=xˉ(t)+(σ(t−Δt)−σ(t))⋅ϵθ(t)(x(t))(44)\displaystyle\bar{{\bm{x}}}(t-\Delta t)=\bar{{\bm{x}}}(t)+(\sigma(t-\Delta t)-\sigma(t))\cdot\epsilon_{\theta}^{(t)}({\bm{x}}(t)) \tag{44}xˉ(t−Δt)=xˉ(t)+(σ(t−Δt)−σ(t))⋅ϵθ(t)​(x(t))(44)

Divide both sides by (−Δt)(-\Delta t)(−Δt) and as Δt→0\Delta t\to 0Δt→0, we have:

两边除以 (−Δt)(-\Delta t)(−Δt),并令 Δt→0\Delta t\to 0Δt→0,得到:

dxˉ(t)dt=dσ(t)dtϵθ(t)(xˉ(t)σ2(t)+1),(45)\displaystyle\frac{\mathrm{d}\bar{{\bm{x}}}(t)}{\mathrm{d}t}=\frac{\mathrm{d}\sigma(t)}{\mathrm{d}t}\epsilon_{\theta}^{(t)}\left(\frac{\bar{{\bm{x}}}(t)}{\sqrt{\sigma^{2}(t)+1}}\right), \tag{45}dtdxˉ(t)​=dtdσ(t)​ϵθ(t)​(σ2(t)+1​xˉ(t)​),(45)

which is exactly what we have in Equation (14).

这正是式 (14) 中的形式。

We note that for the optimal model, ϵθ(t)\epsilon_{\theta}^{(t)}ϵθ(t)​ is a minimizer:

我们指出:对最优模型,ϵθ(t)\epsilon_{\theta}^{(t)}ϵθ(t)​ 是如下最小化者:

ϵθ(t)=arg min⁡ftEx(0)∼q(x),ϵ∼N(0,I)[∥ft(x(t))−ϵ∥22](46)\displaystyle\epsilon_{\theta}^{(t)}=\argmin_{f_{t}}{\mathbb{E}}_{{\bm{x}}(0)\sim q({\bm{x}}),\epsilon\sim{\mathcal{N}}(0,{\bm{I}})}[{\lVert{f_{t}({\bm{x}}(t))-\epsilon}\rVert}_{2}^{2}] \tag{46}ϵθ(t)​=ft​argmin​Ex(0)∼q(x),ϵ∼N(0,I)​[∥ft​(x(t))−ϵ∥22​](46)

where x(t)=α(t)x(t)+1−α(t)ϵ{\bm{x}}(t)=\sqrt{\alpha(t)}{\bm{x}}(t)+\sqrt{1-\alpha(t)}\epsilonx(t)=α(t)​x(t)+1−α(t)​ϵ.

其中 x(t)=α(t)x(t)+1−α(t)ϵ{\bm{x}}(t)=\sqrt{\alpha(t)}{\bm{x}}(t)+\sqrt{1-\alpha(t)}\epsilonx(t)=α(t)​x(t)+1−α(t)​ϵ。

ODE form for VE-SDE

Define pt(xˉ)p_{t}(\bar{{\bm{x}}})pt​(xˉ) as the data distribution perturbed with σ2(t)\sigma^{2}(t)σ2(t) variance Gaussian noise. The probability flow for VE-SDE is defined as Song et al. 2020:

VE-SDE 的 ODE 形式

定义 pt(xˉ)p_{t}(\bar{{\bm{x}}})pt​(xˉ) 为被方差 σ2(t)\sigma^{2}(t)σ2(t) 的高斯噪声扰动的数据分布。VE-SDE 的概率流按 Song et al. 2020 定义为:

dxˉ=−12g(t)2∇xˉlog⁡pt(xˉ)dt(47)\displaystyle\mathrm{d}\bar{{\bm{x}}}=-\frac{1}{2}g(t)^{2}\nabla_{\bar{{\bm{x}}}}\log p_{t}(\bar{{\bm{x}}})\mathrm{d}t \tag{47}dxˉ=−21​g(t)2∇xˉ​logpt​(xˉ)dt(47)

where g(t)=dσ2(t)dtg(t)=\sqrt{\frac{\mathrm{d}\sigma^{2}(t)}{\mathrm{d}t}}g(t)=dtdσ2(t)​​ is the diffusion coefficient, and ∇xˉlog⁡pt(xˉ)\nabla_{\bar{{\bm{x}}}}\log p_{t}(\bar{{\bm{x}}})∇xˉ​logpt​(xˉ) is the score of ptp_{t}pt​.

其中 g(t)=dσ2(t)dtg(t)=\sqrt{\frac{\mathrm{d}\sigma^{2}(t)}{\mathrm{d}t}}g(t)=dtdσ2(t)​​ 是扩散系数,∇xˉlog⁡pt(xˉ)\nabla_{\bar{{\bm{x}}}}\log p_{t}(\bar{{\bm{x}}})∇xˉ​logpt​(xˉ) 是 ptp_{t}pt​ 的分数。

The σ(t)\sigma(t)σ(t)-perturbed score function ∇xˉlog⁡pt(xˉ)\nabla_{\bar{{\bm{x}}}}\log p_{t}(\bar{{\bm{x}}})∇xˉ​logpt​(xˉ) is also a minimizer (from denoising score matching (Vincent 2011)):

σ(t)\sigma(t)σ(t)-扰动分数函数 ∇xˉlog⁡pt(xˉ)\nabla_{\bar{{\bm{x}}}}\log p_{t}(\bar{{\bm{x}}})∇xˉ​logpt​(xˉ) 也是最小化者(来自去噪分数匹配 (Vincent 2011)):

∇xˉlog⁡pt=arg min⁡gtEx(0)∼q(x),ϵ∼N(0,I)[∥gt(xˉ)+ϵ/σ(t)∥22](48)\displaystyle\nabla_{\bar{{\bm{x}}}}\log p_{t}=\argmin_{g_{t}}{\mathbb{E}}_{{\bm{x}}(0)\sim q({\bm{x}}),\epsilon\sim{\mathcal{N}}(0,{\bm{I}})}[{\lVert{g_{t}(\bar{{\bm{x}}})+\epsilon/\sigma(t)}\rVert}_{2}^{2}] \tag{48}∇xˉ​logpt​=gt​argmin​Ex(0)∼q(x),ϵ∼N(0,I)​[∥gt​(xˉ)+ϵ/σ(t)∥22​](48)

where xˉ(t)=xˉ(t)+σ(t)ϵ\bar{{\bm{x}}}(t)=\bar{{\bm{x}}}(t)+\sigma(t)\epsilonxˉ(t)=xˉ(t)+σ(t)ϵ.

其中 xˉ(t)=xˉ(t)+σ(t)ϵ\bar{{\bm{x}}}(t)=\bar{{\bm{x}}}(t)+\sigma(t)\epsilonxˉ(t)=xˉ(t)+σ(t)ϵ。

Since there is an equivalence between x(t){\bm{x}}(t)x(t) and xˉ(t)\bar{{\bm{x}}}(t)xˉ(t), we have the following relationship:

由于 x(t){\bm{x}}(t)x(t) 与 xˉ(t)\bar{{\bm{x}}}(t)xˉ(t) 存在等价,我们有如下关系:

∇xˉlog⁡pt(xˉ)=−ϵθ(t)(xˉ(t)σ2(t)+1)σ(t)(49)\displaystyle\nabla_{\bar{{\bm{x}}}}\log p_{t}(\bar{{\bm{x}}})=-\frac{\epsilon_{\theta}^{(t)}\left(\frac{\bar{{\bm{x}}}(t)}{\sqrt{\sigma^{2}(t)+1}}\right)}{\sigma(t)} \tag{49}∇xˉ​logpt​(xˉ)=−σ(t)ϵθ(t)​(σ2(t)+1​xˉ(t)​)​(49)

from Equation (46) and Equation (48). Plug Equation (49) and definition of g(t)g(t)g(t) in Equation (47), we have:

来自式 (46) 与式 (48)。把式 (49) 与 g(t)g(t)g(t) 的定义代入式 (47),得到:

dxˉ(t)=12dσ2(t)dtϵθ(t)(xˉ(t)σ2(t)+1)σ(t)dt,(50)\displaystyle\mathrm{d}\bar{{\bm{x}}}(t)=\frac{1}{2}\frac{\mathrm{d}\sigma^{2}(t)}{\mathrm{d}t}\frac{\epsilon_{\theta}^{(t)}\left(\frac{\bar{{\bm{x}}}(t)}{\sqrt{\sigma^{2}(t)+1}}\right)}{\sigma(t)}\mathrm{d}t, \tag{50}dxˉ(t)=21​dtdσ2(t)​σ(t)ϵθ(t)​(σ2(t)+1​xˉ(t)​)​dt,(50)

and we have the following by rearranging terms:

整理各项后有:

dxˉ(t)dt=dσ(t)dtϵθ(t)(xˉ(t)σ2(t)+1)(51)\displaystyle\frac{\mathrm{d}\bar{{\bm{x}}}(t)}{\mathrm{d}t}=\frac{\mathrm{d}\sigma(t)}{\mathrm{d}t}\epsilon_{\theta}^{(t)}\left(\frac{\bar{{\bm{x}}}(t)}{\sqrt{\sigma^{2}(t)+1}}\right) \tag{51}dtdxˉ(t)​=dtdσ(t)​ϵθ(t)​(σ2(t)+1​xˉ(t)​)(51)

which is equivalent to Equation (45). In both cases the initial conditions are xˉ(T)∼N(0,σ2(T)I)\bar{{\bm{x}}}(T)\sim{\mathcal{N}}({\bm{0}},\sigma^{2}(T){\bm{I}})xˉ(T)∼N(0,σ2(T)I), so the resulting ODEs are identical. ∎

这与式 (45) 等价。两种情形初值都是 xˉ(T)∼N(0,σ2(T)I)\bar{{\bm{x}}}(T)\sim{\mathcal{N}}({\bm{0}},\sigma^{2}(T){\bm{I}})xˉ(T)∼N(0,σ2(T)I),因而所得 ODE 相同。∎

Appendix C Additional Derivations

附录 C 补充推导

C.1 Accelerated sampling processes

C.1 加速采样过程

In the accelerated case, we can consider the inference process to be factored as:

在加速情形下,可把推断过程分解为:

qσ,τ(x1:T∣x0)=qσ,τ(xτS∣x0)∏i=1Sqσ,τ(xτi−1∣xτi,x0)∏t∈τˉqσ,τ(xt∣x0)(52)\displaystyle q_{\sigma,\tau}({\bm{x}}_{1:T}|{\bm{x}}_{0})=q_{\sigma,\tau}({\bm{x}}_{\tau_{S}}|{\bm{x}}_{0})\prod_{i=1}^{S}q_{\sigma,\tau}({\bm{x}}_{\tau_{i-1}}|{\bm{x}}_{\tau_{i}},{\bm{x}}_{0})\prod_{t\in\bar{\tau}}q_{\sigma,\tau}({\bm{x}}_{t}|{\bm{x}}_{0}) \tag{52}qσ,τ​(x1:T​∣x0​)=qσ,τ​(xτS​​∣x0​)i=1∏S​qσ,τ​(xτi−1​​∣xτi​​,x0​)t∈τˉ∏​qσ,τ​(xt​∣x0​)(52)

where τ\tauτ is a sub-sequence of [1,…,T][1,\ldots,T][1,…,T] of length SSS with τS=T\tau_{S}=TτS​=T, and let τˉ:={1,…,T}∖τ\bar{\tau}:=\{1,\ldots,T\}\setminus\tauτˉ:={1,…,T}∖τ be its complement. Intuitively, the graphical model of {xτi}i=1S\{{\bm{x}}_{\tau_{i}}\}_{i=1}^{S}{xτi​​}i=1S​ and x0{\bm{x}}_{0}x0​ form a chain, whereas the graphical model of {xt}t∈τˉ\{{\bm{x}}_{t}\}_{t\in\bar{\tau}}{xt​}t∈τˉ​ and x0{\bm{x}}_{0}x0​ forms a star graph. We define:

其中 τ\tauτ 是 [1,…,T][1,\ldots,T][1,…,T] 中长度为 SSS 且 τS=T\tau_{S}=TτS​=T 的子序列,记 τˉ:={1,…,T}∖τ\bar{\tau}:=\{1,\ldots,T\}\setminus\tauτˉ:={1,…,T}∖τ 为其补集。直观上,{xτi}i=1S\{{\bm{x}}_{\tau_{i}}\}_{i=1}^{S}{xτi​​}i=1S​ 与 x0{\bm{x}}_{0}x0​ 的图模型形成链,而 {xt}t∈τˉ\{{\bm{x}}_{t}\}_{t\in\bar{\tau}}{xt​}t∈τˉ​ 与 x0{\bm{x}}_{0}x0​ 的图模型形成星图。我们定义:

qσ,τ(xt∣x0)=N(αtx0,(1−αt)I)∀t∈τˉ∪{T}qσ,τ(xτi−1∣xτi,x0)=N(ατi−1x0+1−ατi−1−στi2⋅xτi−ατix01−ατi,στi2I) ∀i∈[S](53)\displaystyle q_{\sigma,\tau}({\bm{x}}_{t}|{\bm{x}}_{0})={\mathcal{N}}(\sqrt{\alpha_{t}}{\bm{x}}_{0},(1-\alpha_{t}){\bm{I}})\quad\forall t\in\bar{\tau}\cup\{T\} \\ \displaystyle q_{\sigma,\tau}({\bm{x}}_{\tau_{i-1}}|{\bm{x}}_{\tau_{i}},{\bm{x}}_{0})={\mathcal{N}}\left(\sqrt{\alpha_{\tau_{i-1}}}{\bm{x}}_{0}+\sqrt{1-\alpha_{\tau_{i-1}}-\sigma^{2}_{\tau_{i}}}\cdot{\frac{{\bm{x}}_{\tau_{i}}-\sqrt{\alpha_{\tau_{i}}}{\bm{x}}_{0}}{\sqrt{1-\alpha_{\tau_{i}}}}},\sigma_{{\tau_{i}}}^{2}{\bm{I}}\right)\ \forall i\in[S] \tag{53}qσ,τ​(xt​∣x0​)=N(αt​​x0​,(1−αt​)I)∀t∈τˉ∪{T}qσ,τ​(xτi−1​​∣xτi​​,x0​)=N(ατi−1​​​x0​+1−ατi−1​​−στi​2​​⋅1−ατi​​​xτi​​−ατi​​​x0​​,στi​2​I) ∀i∈[S](53)

where the coefficients are chosen such that:

其中系数的选取使得:

qσ,τ(xτi∣x0)=N(ατix0,(1−ατi)I)∀i∈[S](54)\displaystyle q_{\sigma,\tau}({\bm{x}}_{\tau_{i}}|{\bm{x}}_{0})={\mathcal{N}}(\sqrt{\alpha_{\tau_{i}}}{\bm{x}}_{0},(1-\alpha_{\tau_{i}}){\bm{I}})\quad\forall i\in[S] \tag{54}qσ,τ​(xτi​​∣x0​)=N(ατi​​​x0​,(1−ατi​​)I)∀i∈[S](54)

i.e., the “marginals” match.

亦即「边缘」匹配。

The corresponding “generative process” is defined as:

相应的「生成过程」定义为:

pθ(x0:T):=pθ(xT)∏i=1Spθ(τi)(xτi−1∣xτi)⏟use to produce samples×∏t∈τˉpθ(t)(x0∣xt)⏟in variational objective(55)\displaystyle p_{\theta}({\bm{x}}_{0:T}):=\underbrace{p_{\theta}({\bm{x}}_{T})\prod_{i=1}^{S}p^{(\tau_{i})}_{\theta}({\bm{x}}_{\tau_{i-1}}|{\bm{x}}_{\tau_{i}})}_{\text{use to produce samples}}\times\underbrace{\prod_{t\in\bar{\tau}}p_{\theta}^{(t)}({\bm{x}}_{0}|{\bm{x}}_{t})}_{\text{in variational objective}} \tag{55}pθ​(x0:T​):=use to produce samplespθ​(xT​)i=1∏S​pθ(τi​)​(xτi−1​​∣xτi​​)​​×in variational objectivet∈τˉ∏​pθ(t)​(x0​∣xt​)​​(55)

where only part of the models are actually being used to produce samples. The conditionals are:

其中实际用于产出样本的只是部分模型。条件分布为:

pθ(τi)(xτi−1∣xτi)=qσ,τ(xτi−1∣xτi,fθ(τi)(xτi−1))if i∈[S],i>1pθ(t)(x0∣xt)=N(fθ(t)(xt),σt2I)otherwise,(56)\displaystyle p_{\theta}^{(\tau_{i})}({\bm{x}}_{\tau_{i-1}}|{\bm{x}}_{\tau_{i}})=q_{\sigma,\tau}({\bm{x}}_{\tau_{i-1}}|{\bm{x}}_{\tau_{i}},f_{\theta}^{(\tau_{i})}({\bm{x}}_{\tau_{i-1}}))\quad\text{if}\ i\in[S],i>1 \\ \displaystyle p_{\theta}^{(t)}({\bm{x}}_{0}|{\bm{x}}_{t})={\mathcal{N}}(f_{\theta}^{(t)}({\bm{x}}_{t}),\sigma_{t}^{2}{\bm{I}})\quad\text{otherwise,} \tag{56}pθ(τi​)​(xτi−1​​∣xτi​​)=qσ,τ​(xτi−1​​∣xτi​​,fθ(τi​)​(xτi−1​​))if i∈[S],i>1pθ(t)​(x0​∣xt​)=N(fθ(t)​(xt​),σt2​I)otherwise,(56)

where we leverage qσ,τ(xτi−1∣xτi,x0)q_{\sigma,\tau}({\bm{x}}_{\tau_{i-1}}|{\bm{x}}_{\tau_{i}},{\bm{x}}_{0})qσ,τ​(xτi−1​​∣xτi​​,x0​) as part of the inference process (similar to what we have done in Section 3). The resulting variational objective becomes (define xτL+1=∅{\bm{x}}_{\tau_{L+1}}=\varnothingxτL+1​​=∅ for conciseness):

其中我们把 qσ,τ(xτi−1∣xτi,x0)q_{\sigma,\tau}({\bm{x}}_{\tau_{i-1}}|{\bm{x}}_{\tau_{i}},{\bm{x}}_{0})qσ,τ​(xτi−1​​∣xτi​​,x0​) 作为推断过程的一部分(类似第 3 节)。所得变分目标变为(为简洁定义 xτL+1=∅{\bm{x}}_{\tau_{L+1}}=\varnothingxτL+1​​=∅):

J(ϵθ)=Ex0:T∼qσ,τ(x0:T)[log⁡qσ,τ(x1:T∣x0)−log⁡pθ(x0:T)]=Ex0:T∼qσ,τ(x0:T)[∑t∈τˉDKL(qσ,τ(xt∣x0)∥pθ(t)(x0∣xt)+∑i=1LDKL(qσ,τ(xτi−1∣xτi,x0)∥pθ(τi)(xτi−1∣xτi)))](58)\displaystyle J(\epsilon_{\theta}) \\ \displaystyle={\mathbb{E}}_{{\bm{x}}_{0:T}\sim q_{\sigma,\tau}({\bm{x}}_{0:T})}[\log q_{\sigma,\tau}({\bm{x}}_{1:T}|{\bm{x}}_{0})-\log p_{\theta}({\bm{x}}_{0:T})] \\ \displaystyle={\mathbb{E}}_{{\bm{x}}_{0:T}\sim q_{\sigma,\tau}({\bm{x}}_{0:T})}\Bigg[\sum_{t\in\bar{\tau}}D_{\mathrm{KL}}(q_{\sigma,\tau}({\bm{x}}_{t}|{\bm{x}}_{0})\|p_{\theta}^{(t)}({\bm{x}}_{0}|{\bm{x}}_{t}) \\ \displaystyle\qquad\qquad\qquad\qquad+\sum_{i=1}^{L}D_{\mathrm{KL}}(q_{\sigma,\tau}({\bm{x}}_{\tau_{i-1}}|{\bm{x}}_{\tau_{i}},{\bm{x}}_{0})\|p_{\theta}^{(\tau_{i})}({\bm{x}}_{\tau_{i-1}}|{\bm{x}}_{\tau_{i}})))\Bigg] \tag{58}J(ϵθ​)=Ex0:T​∼qσ,τ​(x0:T​)​[logqσ,τ​(x1:T​∣x0​)−logpθ​(x0:T​)]=Ex0:T​∼qσ,τ​(x0:T​)​[t∈τˉ∑​DKL​(qσ,τ​(xt​∣x0​)∥pθ(t)​(x0​∣xt​)+i=1∑L​DKL​(qσ,τ​(xτi−1​​∣xτi​​,x0​)∥pθ(τi​)​(xτi−1​​∣xτi​​)))](58)

where each KL divergence is between two Gaussians with variance independent of θ\thetaθ. A similar argument to the proof used in Theorem 1 can show that the variational objective JJJ can also be converted to an objective of the form LγL_{\gamma}Lγ​.

其中每个 KL 散度是方差不依赖 θ\thetaθ 的两个高斯之间的散度。与定理 1 证明类似的论证可表明:变分目标 JJJ 也可转换成 LγL_{\gamma}Lγ​ 形式的目标。

C.2 Derivation of denoising objectives for DDPMs

C.2 DDPM 去噪目标的推导

We note that in Ho et al. 2020, a diffusion hyperparameter βt\beta_{t}βt​[^9] is first introduced, and then relevant variables αt:=1−βt\alpha_{t}:=1-\beta_{t}αt​:=1−βt​ and αˉt=∏t=1Tαt\bar{\alpha}_{t}=\prod_{t=1}^{T}\alpha_{t}αˉt​=∏t=1T​αt​ are defined. In this paper, we have used the notation αt\alpha_{t}αt​ to represent the variable αˉt\bar{\alpha}_{t}αˉt​ in Ho et al. 2020 for three reasons. First, it makes it more clear that we only need to choose one set of hyperparameters, reducing possible cross-references of the derived variables. Second, it allows us to introduce the generalization as well as the acceleration case easier, because the inference process is no longer motivated by a diffusion. Third, there exists an isomorphism between α1:T\alpha_{1:T}α1:T​ and 1,…,T1,\ldots,T1,…,T, which is not the case for βt\beta_{t}βt​.

我们指出:Ho et al. 2020 先引入扩散超参数 βt\beta_{t}βt​[^9],再定义相关变量 αt:=1−βt\alpha_{t}:=1-\beta_{t}αt​:=1−βt​ 与 αˉt=∏t=1Tαt\bar{\alpha}_{t}=\prod_{t=1}^{T}\alpha_{t}αˉt​=∏t=1T​αt​。本文用记号 αt\alpha_{t}αt​ 表示 Ho et al. 2020 中的 αˉt\bar{\alpha}_{t}αˉt​,原因有三。第一,这样更清楚我们只需选择一组超参数,减少派生变量的交叉引用。第二,许多表达式更简洁。第三,它强调真正进入边缘 q(xt∣x0)q({\bm{x}}_{t}|{\bm{x}}_{0})q(xt​∣x0​) 的是累积乘积。下文在需要与 Ho et al. 2020 的推导对齐时,会使用 βt\beta_{t}βt​ 与他们的 αt\alpha_{t}αt​。

In this section, we use βt\beta_{t}βt​ and αt\alpha_{t}αt​ to be more consistent with the derivation in Ho et al. 2020, where

本节使用 βt\beta_{t}βt​ 与 αt\alpha_{t}αt​,以便与 Ho et al. 2020 的推导更一致,其中

\displaystyle{\color[rgb]{0,0.5,0.5}\alpha_{t}}=\frac{\alpha_{t}}{\alpha_{t-1}} \\ \displaystyle{\color[rgb]{0,0.5,0.5}\beta_{t}}=1-\frac{\alpha_{t}}{\alpha_{t-1}} \tag{60}

can be uniquely determined from αt\alpha_{t}αt​ (i.e. αˉt\bar{\alpha}_{t}αˉt​).

可由 αt\alpha_{t}αt​(即 αˉt\bar{\alpha}_{t}αˉt​)唯一确定。

First, from the diffusion forward process:

首先,由扩散前向过程:

\displaystyle q({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})={\mathcal{N}}\Bigg(\underbrace{\frac{\sqrt{\alpha_{t-1}}{\color[rgb]{0,0.5,0.5}\beta_{t}}}{1-\alpha_{t}}{\bm{x}}_{0}+\frac{\sqrt{{\color[rgb]{0,0.5,0.5}\alpha_{t}}}(1-\alpha_{t-1})}{1-\alpha_{t}}{\bm{x}}_{t}}_{\color[rgb]{0,0.5,0.5}\tilde{\mu}({\bm{x}}_{t},{\bm{x}}_{0})},\frac{1-\alpha_{t-1}}{1-\alpha_{t}}{\color[rgb]{0,0.5,0.5}\beta_{t}}{\bm{I}}\Bigg)

Ho et al. 2020 considered a specific type of pθ(t)(xt−1∣xt)p_{\theta}^{(t)}({\bm{x}}_{t-1}|{\bm{x}}_{t})pθ(t)​(xt−1​∣xt​):

Ho et al. 2020 考虑了特定类型的 pθ(t)(xt−1∣xt)p_{\theta}^{(t)}({\bm{x}}_{t-1}|{\bm{x}}_{t})pθ(t)​(xt−1​∣xt​):

\displaystyle p_{\theta}^{(t)}({\bm{x}}_{t-1}|{\bm{x}}_{t})={\mathcal{N}}\left({\color[rgb]{0,0.5,0.5}\mu_{\theta}({\bm{x}}_{t},t)},\sigma_{t}{\bm{I}}\right) \tag{62}

which leads to the following variational objective:

从而得到如下变分目标:

\displaystyle{\color[rgb]{0,0.5,0.5}L} \\ \displaystyle:={\mathbb{E}}_{{\bm{x}}_{0:T}\sim q({\bm{x}}_{0:T})}\left[q({\bm{x}}_{T}|{\bm{x}}_{0})+\sum_{t=2}^{T}\log q({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0})-\sum_{t=1}^{T}\log p_{\theta}^{(t)}({\bm{x}}_{t-1}|{\bm{x}}_{t})\right] \\ \displaystyle\equiv{\mathbb{E}}_{{\bm{x}}_{0:T}\sim q({\bm{x}}_{0:T})}\left[\sum_{t=2}^{T}\underbrace{D_{\mathrm{KL}}(q({\bm{x}}_{t-1}|{\bm{x}}_{t},{\bm{x}}_{0}))\|p_{\theta}^{(t)}({\bm{x}}_{t-1}|{\bm{x}}_{t}))}_{\color[rgb]{0,0.5,0.5}L_{t-1}}-\log p_{\theta}^{(1)}({\bm{x}}_{0}|{\bm{x}}_{1})\right] \tag{63}

One can write:

可以写出:

\displaystyle{\color[rgb]{0,0.5,0.5}L_{t-1}}={\mathbb{E}}_{q}\left[\frac{1}{2\sigma_{t}^{2}}{\lVert{{\color[rgb]{0,0.5,0.5}\mu_{\theta}({\bm{x}}_{t},t)}-{\color[rgb]{0,0.5,0.5}\tilde{\mu}({\bm{x}}_{t},{\bm{x}}_{0})}}\rVert}_{2}^{2}\right] \tag{64}

Ho et al. 2020 chose the parametrization

Ho et al. 2020 选择参数化

\displaystyle{\color[rgb]{0,0.5,0.5}\mu_{\theta}({\bm{x}}_{t},t)}=\frac{1}{\sqrt{{\color[rgb]{0,0.5,0.5}\alpha_{t}}}}\left({\bm{x}}_{t}-\frac{{\color[rgb]{0,0.5,0.5}\beta_{t}}}{\sqrt{1-\alpha_{t}}}{\color[rgb]{0,0.5,0.5}\epsilon_{\theta}({\bm{x}}_{t},t)}\right) \tag{65}

which can be simplified to:

可简化为:

\displaystyle{\color[rgb]{0,0.5,0.5}L_{t-1}}={\mathbb{E}}_{{\bm{x}}_{0},\epsilon}\left[\frac{{\color[rgb]{0,0.5,0.5}\beta_{t}}^{2}}{2\sigma_{t}^{2}(1-\alpha_{t}){\color[rgb]{0,0.5,0.5}\alpha_{t}}}{\lVert{\epsilon-{\color[rgb]{0,0.5,0.5}\epsilon_{\theta}(\sqrt{\alpha_{t}}{\bm{x}}_{0}+\sqrt{1-\alpha_{t}}\epsilon,t)}}\rVert}_{2}^{2}\right] \tag{66}

Appendix D Experimental Details

附录 D 实验细节

D.1 Datasets and architectures

D.1 数据集与架构

We consider 4 image datasets with various resolutions: CIFAR10 (32×3232\times 3232×32, unconditional), CelebA (64×6464\times 6464×64), LSUN Bedroom (256×256256\times 256256×256) and LSUN Church (256×256256\times 256256×256). For all datasets, we set the hyperparameters α\alphaα according to the heuristic in (Ho et al. 2020) to make the results directly comparable. We use the same model for each dataset, and only compare the performance of different generative processes. For CIFAR10, Bedroom and Church, we obtain the pretrained checkpoints from the original DDPM implementation; for CelebA, we trained our own model using the denoising objective L1L_{\bm{1}}L1​.

我们考虑四个不同分辨率的图像数据集:CIFAR10(32×3232\times 3232×32,无条件)、CelebA(64×6464\times 6464×64)、LSUN Bedroom(256×256256\times 256256×256)与 LSUN Church(256×256256\times 256256×256)。对全部数据集,按 (Ho et al. 2020) 的启发式设定超参数 α\alphaα,以便结果可直接比较。每个数据集使用同一模型,只比较不同生成过程的表现。对 CIFAR10、Bedroom 与 Church,我们取自原始 DDPM 实现的预训练检查点;对 CelebA,用去噪目标 L1L_{\bm{1}}L1​ 自行训练模型。

Our architecture for ϵθ(t)(xt)\epsilon_{\theta}^{(t)}({\bm{x}}_{t})ϵθ(t)​(xt​) follows that in Ho et al. 2020, which is a U-Net (Ronneberger et al. 2015) based on a Wide ResNet (Zagoruyko & Komodakis 2016). We use the pretrained models from Ho et al. 2020 for CIFAR10, Bedroom and Church, and train our own model for the CelebA 64×6464\times 6464×64 model (since a pretrained model is not provided). Our CelebA model has five feature map resolutions from 64×6464\times 6464×64 to 4×44\times 44×4, and we use the original CelebA dataset (not CelebA-HQ) using the pre-processing technique from the StyleGAN (Karras et al. 2018) repository.

我们对 ϵθ(t)(xt)\epsilon_{\theta}^{(t)}({\bm{x}}_{t})ϵθ(t)​(xt​) 的结构沿用 Ho et al. 2020:基于 Wide ResNet (Zagoruyko & Komodakis 2016) 的 U-Net (Ronneberger et al. 2015)。CIFAR10、Bedroom 与 Church 使用 Ho et al. 2020 的预训练模型;CelebA 64×6464\times 6464×64 模型因未提供预训练而自行训练。我们的 CelebA 模型有从 64×6464\times 6464×64 到 4×44\times 44×4 的五个特征图分辨率,并使用原始 CelebA 数据集(非 CelebA-HQ),预处理采用 StyleGAN (Karras et al. 2018) 仓库的技术。

Bedroom (256×256256\times 256256×256) Church (256×256256\times 256256×256)
dim⁡(τ)\dim(\tau)dim(τ) 10 20 50 100 10 20 50 100
DDIM (η=0.0\eta=0.0η=0.0) 16.95 8.89 6.75 6.62 19.45 12.47 10.84 10.58
DDPM (η=1.0\eta=1.0η=1.0) 42.78 22.77 10.81 6.81 51.56 23.37 11.16 8.27

Table 3: LSUN Bedroom and Church image generation results, measured in FID. For 1000 steps DDPM, the FIDs are 6.36 for Bedroom and 7.89 for Church.

Bedroom (256×256256\times 256256×256) Church (256×256256\times 256256×256)
dim⁡(τ)\dim(\tau)dim(τ) 10 20 50 100 10 20 50 100
DDIM (η=0.0\eta=0.0η=0.0) 16.95 8.89 6.75 6.62 19.45 12.47 10.84 10.58
DDPM (η=1.0\eta=1.0η=1.0) 42.78 22.77 10.81 6.81 51.56 23.37 11.16 8.27

表 3:LSUN Bedroom 与 Church 图像生成结果(FID)。1000 步 DDPM 的 FID 为 Bedroom 6.36、Church 7.89。

D.2 Reverse process sub-sequence selection

D.2 反向过程子序列选择

We consider two types of selection procedure for τ\tauτ given the desired dim⁡(τ)<T\dim(\tau)<Tdim(τ)<T:

在给定所需 dim⁡(τ)<T\dim(\tau)<Tdim(τ)<T 时,我们考虑两类 τ\tauτ 选择程序:

  • • Linear: we select the timesteps such that τi=⌊ci⌋\tau_{i}=\lfloor ci\rfloorτi​=⌊ci⌋ for some ccc;
  • • 线性:选取时间步使 τi=⌊ci⌋\tau_{i}=\lfloor ci\rfloorτi​=⌊ci⌋,其中 ccc 为某常数;
  • • Quadratic: we select the timesteps such that τi=⌊ci2⌋\tau_{i}=\lfloor ci^{2}\rfloorτi​=⌊ci2⌋ for some ccc.
  • • 二次:选取时间步使 τi=⌊ci2⌋\tau_{i}=\lfloor ci^{2}\rfloorτi​=⌊ci2⌋,其中 ccc 为某常数。

The constant value ccc is selected such that τ−1\tau_{-1}τ−1​ is close to TTT. We used quadratic for CIFAR10 and linear for the remaining datasets. These choices achieve slightly better FID than their alternatives in the respective datasets.

常数 ccc 的选取使 τ−1\tau_{-1}τ−1​ 接近 TTT。CIFAR10 用二次,其余数据集用线性。这些选择在各自数据集上比替代方案取得略好的 FID。

D.3 Closed form equations for each sampling step

D.3 每步采样的闭式方程

From the general sampling equation in Eq. (12), we have the following update equation:

由式 (12) 的一般采样方程,有如下更新方程:

xτi−1(η)=ατi−1(xτi−1−ατiϵθ(τi)(xτi)ατi)+1−ατi−1−στi(η)2⋅ϵθ(τi)(xτi)+στi(η)ϵ\displaystyle{\bm{x}}_{\tau_{i-1}}(\eta)=\sqrt{\alpha_{\tau_{i-1}}}\left(\frac{{\bm{x}}_{\tau_{i}}-\sqrt{1-\alpha_{\tau_{i}}}\epsilon_{\theta}^{(\tau_{i})}({\bm{x}}_{\tau_{i}})}{\sqrt{\alpha_{\tau_{i}}}}\right)+\sqrt{1-\alpha_{\tau_{i-1}}-\sigma_{\tau_{i}}(\eta)^{2}}\cdot\epsilon_{\theta}^{(\tau_{i})}({\bm{x}}_{\tau_{i}})+\sigma_{\tau_{i}}(\eta)\epsilonxτi−1​​(η)=ατi−1​​​(ατi​​​xτi​​−1−ατi​​​ϵθ(τi​)​(xτi​​)​)+1−ατi−1​​−στi​​(η)2​⋅ϵθ(τi​)​(xτi​​)+στi​​(η)ϵ

where

其中

στi(η)=η1−ατi−11−ατi1−ατiατi−1\sigma_{\tau_{i}}(\eta)=\eta\sqrt{\frac{1-\alpha_{\tau_{i-1}}}{1-\alpha_{\tau_{i}}}}\sqrt{1-\frac{\alpha_{\tau_{i}}}{\alpha_{\tau_{i-1}}}}στi​​(η)=η1−ατi​​1−ατi−1​​​​1−ατi−1​​ατi​​​​

For the case of σ^\hat{\sigma}σ^ (DDPM with a larger variance), the update equation becomes:

对 σ^\hat{\sigma}σ^(方差更大的 DDPM)情形,更新方程变为:

xτi−1=ατi−1(xτi−1−ατiϵθ(τi)(xτi)ατi)+1−ατi−1−στi(1)2⋅ϵθ(τi)(xτi)+σ^τiϵ\displaystyle{\bm{x}}_{\tau_{i-1}}=\sqrt{\alpha_{\tau_{i-1}}}\left(\frac{{\bm{x}}_{\tau_{i}}-\sqrt{1-\alpha_{\tau_{i}}}\epsilon_{\theta}^{(\tau_{i})}({\bm{x}}_{\tau_{i}})}{\sqrt{\alpha_{\tau_{i}}}}\right)+\sqrt{1-\alpha_{\tau_{i-1}}-\sigma_{\tau_{i}}(1)^{2}}\cdot\epsilon_{\theta}^{(\tau_{i})}({\bm{x}}_{\tau_{i}})+\hat{\sigma}_{\tau_{i}}\epsilonxτi−1​​=ατi−1​​​(ατi​​​xτi​​−1−ατi​​​ϵθ(τi​)​(xτi​​)​)+1−ατi−1​​−στi​​(1)2​⋅ϵθ(τi​)​(xτi​​)+σ^τi​​ϵ

which uses a different coefficient for ϵ\epsilonϵ compared with the update for η=1\eta=1η=1, but uses the same coefficient for the non-stochastic parts. This update is more stochastic than the update for η=1\eta=1η=1, which explains why it achieves worse performance when dim⁡(τ)\dim(\tau)dim(τ) is small.

相对 η=1\eta=1η=1 的更新,它对 ϵ\epsilonϵ 使用不同系数,但对非随机部分使用相同系数。该更新比 η=1\eta=1η=1 的更新更随机,这解释了为何在 dim⁡(τ)\dim(\tau)dim(τ) 较小时表现更差。

D.4 Samples and Consistency

D.4 样本与一致性

We show more samples in Figure 7 (CIFAR10), Figure 8 (CelebA), Figure 10 (Church) and consistency results of DDIM in Figure 9 (CelebA).

我们在图 7(CIFAR10)、图 8(CelebA)、图 10(Church)展示更多样本,并在图 9(CelebA)展示 DDIM 的一致性结果。

Figure 7: CIFAR10 samples from 1000 step DDPM, 1000 step DDIM and 100 step DDIM.

图 7:1000 步 DDPM、1000 步 DDIM 与 100 步 DDIM 的 CIFAR10 样本。

Figure 8: CelebA samples from 1000 step DDPM, 1000 step DDIM and 100 step DDIM.

图 8:1000 步 DDPM、1000 步 DDIM 与 100 步 DDIM 的 CelebA 样本。

Figure 9: CelebA samples from DDIM with the same random xT{\bm{x}}_{T}xT​ and different number of steps.

图 9:同一随机 xT{\bm{x}}_{T}xT​、不同步数下的 CelebA DDIM 样本。

Figure 10: Church samples from 100 step DDPM and 100 step DDIM.

图 10:100 步 DDPM 与 100 步 DDIM 的 Church 样本。

D.5 Interpolation

D.5 插值

To generate interpolations on a line, we randomly sample two initial xT{\bm{x}}_{T}xT​ values from the standard Gaussian, interpolate them with spherical linear interpolation (Shoemake 1985), and then use the DDIM to obtain x0{\bm{x}}_{0}x0​ samples.

为生成直线上的插值,我们从标准高斯随机采两个初始 xT{\bm{x}}_{T}xT​,用球面线性插值(Shoemake 1985)插值它们,再用 DDIM 得到 x0{\bm{x}}_{0}x0​ 样本。

xT(α)=sin⁡((1−α)θ)sin⁡(θ)xT(0)+sin⁡(αθ)sin⁡(θ)xT(1)(67)\displaystyle{\bm{x}}_{T}^{(\alpha)}=\frac{\sin((1-\alpha)\theta)}{\sin(\theta)}{\bm{x}}_{T}^{(0)}+\frac{\sin(\alpha\theta)}{\sin(\theta)}{\bm{x}}_{T}^{(1)} \tag{67}xT(α)​=sin(θ)sin((1−α)θ)​xT(0)​+sin(θ)sin(αθ)​xT(1)​(67)

where θ=arccos⁡((xT(0))⊤xT(1)∥xT(0)∥∥xT(1)∥)\theta=\arccos\left(\frac{({\bm{x}}_{T}^{(0)})^{\top}{\bm{x}}_{T}^{(1)}}{{\lVert{{\bm{x}}_{T}^{(0)}}\rVert}{\lVert{{\bm{x}}_{T}^{(1)}}\rVert}}\right)θ=arccos(∥xT(0)​∥∥xT(1)​∥(xT(0)​)⊤xT(1)​​). These values are used to produce DDIM samples.

其中 θ=arccos⁡((xT(0))⊤xT(1)∥xT(0)∥∥xT(1)∥)\theta=\arccos\left(\frac{({\bm{x}}_{T}^{(0)})^{\top}{\bm{x}}_{T}^{(1)}}{{\lVert{{\bm{x}}_{T}^{(0)}}\rVert}{\lVert{{\bm{x}}_{T}^{(1)}}\rVert}}\right)θ=arccos(∥xT(0)​∥∥xT(1)​∥(xT(0)​)⊤xT(1)​​)。这些值用于产出 DDIM 样本。

To generate interpolations on a grid, we sample four latent variables and separate them in to two pairs; then we use slerp with the pairs under the same α\alphaα, and use slerp over the interpolated samples across the pairs (under an independently chosen interpolation coefficient). We show more grid interpolation results in Figure 11 (CelebA), Figure 12 (Bedroom), and Figure 13 (Church).

为生成网格上的插值,我们采样四个潜变量并分成两对;先在相同 α\alphaα 下对两对分别做 slerp,再在两对的插值结果之间做 slerp(插值系数独立选取)。更多网格插值结果见图 11(CelebA)、图 12(Bedroom)与图 13(Church)。

Figure 11: More interpolations from the CelebA DDIM with dim⁡(τ)=50\dim(\tau)=50dim(τ)=50.

图 11:dim⁡(τ)=50\dim(\tau)=50dim(τ)=50 时 CelebA DDIM 的更多插值。

Figure 12: More interpolations from the Bedroom DDIM with dim⁡(τ)=50\dim(\tau)=50dim(τ)=50.

图 12:dim⁡(τ)=50\dim(\tau)=50dim(τ)=50 时 Bedroom DDIM 的更多插值。

Figure 13: More interpolations from the Church DDIM with dim⁡(τ)=50\dim(\tau)=50dim(τ)=50.

图 13:dim⁡(τ)=50\dim(\tau)=50dim(τ)=50 时 Church DDIM 的更多插值。