深度学习(生成式模型)—— Consistency Models

文章介绍了ConsistencyModels,一种改进的扩散模型,能够在单次推断或少量多次推断下生成高质量图像。它利用SDE和ODE的理论,通过一致性训练和一致性蒸馏策略提高生成效率,实验结果显示ConsistencyDistillation效果优于ConsistencyTraining。
摘要由CSDN通过智能技术生成

前言

Diffusion model需要多次推断才能生成最终的图像,这将耗费大量的计算资源。前几篇博客我们已经介绍了加速Diffusion model生成图像速率的DDIM和Stable Diffusion,本节将介绍最近大火的Consistency Models(代表模型:Dalle-3),其允许Diffusion model仅经过一次推断就生成最终的图像,同时也允许少量多次推断来生成最终的图像。

预备知识:SDE与ODE

yang song博士在《Score-Based Generative Modeling Through Stochastic Differential Equations》一文中提出可以使用SDE(随机微分方程)来刻画Diffusion model的前向过程,并且用SDE统一了Score-based Model (NCSN)和DDPM的前向过程反向过程。此外,SDE对应了多个前向过程,即从一张图到某个噪声点的加噪方式有多种,但其中存在一个ODE(常微分方程)形式的前向过程,即不存在随机变量的确定性的前向过程。

具体可查看前一篇博客score-based generative modeling through stochastic differential equations

Method

在这里插入图片描述
Consistency Models的核心可总结为上图,在一条ODE轨迹上(可以简单理解为从一个图像到某个噪声点,每一个步骤加的噪声都是特定的,比如第一步加的噪声为0.1,第二步加的噪声为0.2,一旦图像确定了,则对应的噪声点也会被确定,反之亦然),训练一个模型 f θ ( x t , t ) f_\theta(x_t,t) fθ(xt,t),其满足对于任意的 t 、 t ′ t、t' tt,模型的输出都一致,即
f θ ( x t , t ) = f θ ( x t ′ , t ′ ) (1.0) f_\theta(x_t,t)=f_\theta(x_{t'},{t'})\tag{1.0} fθ(xt,t)=fθ(xt,t)(1.0)

模型 f θ ( x t , t ) f_\theta(x_t,t) fθ(xt,t)即为Consistency Models,这里有个关键点,即训练Consistency Models时,必须是在ODE轨迹上。如果是在SDE轨迹,如下图所示,则有一个x对应多个y的情况出现,从同一个点出发,第一次迭代对应的轨迹是黑线,第二次迭代对应的轨迹是红线,模型将很难收敛。

在这里插入图片描述

为了实现式1.0,则只需要采样ODE轨迹上的两个点 x t x_t xt x t ′ x_{t'} xt,在套用一个L2 或L1 loss即可。
我们可以使用一系列的ODE solver(即在反向过程中不会引入随机性噪声的Diffusion model,例如DDIM)来帮助我们确定ODE轨迹上的两个点。

注意到式1.0也是自监督学习的优化目标,因此也会有收敛到奔溃解的情况,比如模型所有参数都为0,因此作者选用了自监督学习中的MoCo解决此类问题。

上述思路总结出的训练策略为Consistency Distillation,一个训练范式如下图
在这里插入图片描述
如下图,作者也给出了上述算法一些理论上的性质,个人觉得不是本算法的核心,故不总结
在这里插入图片描述

此外,作者也提出了Consistency Training的训练策略,即通过往一张图像里持续添加一个固定的噪声来获得一个ODE轨迹

在这里插入图片描述
个人猜测特,当 t n t_n tn取值为0时,则会将 f θ − ( x ) f_{\theta^-}(x) fθ(x)替换为 x 0 x_0 x0,即原图,此时模型拟合完毕后,则有

f θ ( x T , T ) = f θ ( x T − 1 , T − 1 ) = . . . = f θ ( x 1 , 1 ) = x 0 f_\theta(x_T,T)=f_\theta(x_{T-1},T-1)=...=f_\theta(x_1,1)=x_0 fθ(xT,T)=fθ(xT1,T1)=...=fθ(x1,1)=x0

此时我们只需要进行一次采样,即可得到原图。由此可见,Consistency Models其实是在直接预测 x 0 x_0 x0,但是在训练时把预测 x 0 x_0 x0拆分成了多步。

如下图所示,Consistency Models也支持进行多步采样,即Consistency Models生成的图像经过一次前向过程,得到一张新图,在输入到Consistency Models中,个人认为前向过程的加噪方式应该与训练时的ODE轨迹一致。直接从噪声生成图像容易导致图像细节缺失,这种多步迭代有助于补足图像细节

在这里插入图片描述

实验结果

CD表示训练策略为Consistency Distillation,CT表示训练策略为Consistency Training,整体表现上CD优于CT,Dalle3也是使用CD训练的。NFE表示反向过程迭代次数

在这里插入图片描述

可以看到Consistency Distillation的策略整体优于Consistency Training,看起来采用什么ODE轨迹也会影响到Consistency Models的性能

  • 23
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Consistency models are used in distributed computing systems to define the level of consistency that is maintained across different copies of the same data. These models determine how updates to the data are propagated to other copies and how conflicts are resolved when multiple copies are updated simultaneously. There are several consistency models, including: 1. Strong consistency: In this model, all copies of the data are updated synchronously and all updates are visible to all nodes at the same time. This model guarantees that all nodes see the same version of the data at the same time. 2. Weak consistency: In this model, updates are not propagated synchronously and different nodes may have different views of the data at any given time. This model allows for faster updates but may result in temporary inconsistencies. 3. Eventual consistency: In this model, updates are propagated asynchronously and nodes eventually converge to a consistent view of the data. This model allows for high availability and scalability but may result in temporary inconsistencies. 4. Causal consistency: In this model, updates are propagated in a causally consistent manner, meaning that updates that are causally related are propagated in the same order to all nodes. This model provides a compromise between strong and eventual consistency. 5. Read-your-writes consistency: In this model, a node always reads its own writes. This model guarantees that a node will always see its own writes, but may not see the writes of other nodes immediately. Each consistency model has its own trade-offs between performance, availability, and consistency. The choice of consistency model depends on the specific requirements of the application and the underlying distributed system.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值