Generative Modeling by Estimating Gradients of the Data Distribution阅读笔记
创始人
2024-04-23 12:27:00
0

目录

  • 概述
  • 传统score-based generative modeling介绍
    • score matching
    • Langevin dynamics
  • 传统score-based generative modeling存在的问题
    • 流型假设上的问题
    • 低密度区域的问题
  • Noise Conditional Score Network
    • 噪声条件分数网络(Noise Conditional Score Networks)
    • annealed Langevin dynamics
  • 参考

概述

论文提出了一种生成模型,并将其用于图像生成任务。
论文先介绍了传统score-based generative modeling方法,然后分析传统score-based generative modeling存在的问题,最后提出解决问题的算法noise conditional score network。

传统score-based generative modeling介绍

假设数据集中的数据服从pdata(x)p_{data}(\mathbf{x})pdata​(x)分布。
generative modeling的目标是学习一个生成模型来生成服从pdata(x)p_{data}(\mathbf{x})pdata​(x)分布的新样本。
定义score function为对概率密度函数p(x)p(\mathbf{x})p(x)求导∇xlog⁡p(x)\nabla_\mathbf{x}\log p(\mathbf{x})∇x​logp(x)。
定义score network是一个参数为θ\thetaθ的神经网络sθs_\thetasθ​,其试图近似score function。
score-based generative modeling通过学习score function,加上Langevin dynamics采样,来生成符合分布的新样本,步骤如下图所示:
在这里插入图片描述

score matching

使用score matching算法,我们可以直接训练一个分数网络sθ(x)s_\theta(\mathbf{x})sθ​(x)来估计∇xlog⁡pdata(x)\nabla_\mathbf{x}\log p_{data}(\mathbf{x})∇x​logpdata​(x)而无需训练模型估计pdata(x)p_{data}(\mathbf{x})pdata​(x)。好处是可以避免概率密度函数中的归一化常数,详见score matching算法介绍。
score matching算法的优化目标如下:
12Epdata[∥sθ(x)−∇xlog⁡pdata(x)∥22]\frac{1}{2}\mathbb{E}_{p_{data}}[\|\mathbf{s}_\theta(\mathbf{x})-\nabla_\mathbf{x}\log p_{data}(\mathbf{x})\|^2_2] 21​Epdata​​[∥sθ​(x)−∇x​logpdata​(x)∥22​]上面的公式需要计算∇xlog⁡pdata(x)\nabla_\mathbf{x}\log p_{data}(\mathbf{x})∇x​logpdata​(x),这是一个非参数估计问题,并不好计算。值得高兴的是,上面的公式在相差常数上等价为Epdata[tr(∇xsθ(x))+12∥sθ(x)∥22]\mathbb{E}_{p_{data}}[\text{tr}(\nabla_\mathbf{x}\mathbf{s}_\theta(\mathbf{x}))+\frac{1}{2}\|\mathbf{s}_\theta(\mathbf{x})\|^2_2] Epdata​​[tr(∇x​sθ​(x))+21​∥sθ​(x)∥22​]最小化上面的公式可以求出sθ(x)\mathbf{s}_\theta(\mathbf{x})sθ​(x)。在现实中,期望可以用样本的平均代替。
但是,高维数据计算tr(∇xsθ(x))\text{tr}(\nabla_\mathbf{x}\mathbf{s}_\theta(\mathbf{x}))tr(∇x​sθ​(x))复杂度很高。Denoising score matching和Sliced score matching是针对高维大数据的两种常用的改进方法。

Langevin dynamics

Langevin dynamics是一种只需要score function∇xlog⁡p(x)\nabla_\mathbf{x}\log p(\mathbf{x})∇x​logp(x)就可以从概率密度函数pdata(x)p_{data}(\mathbf{x})pdata​(x)中采样的方法,它是一种Markov chain Monte Carlo (MCMC)方法。
给一个初始分布x~0∼π(x)\tilde{\mathbf{x}}_0\sim \pi(\mathbf{x})x~0​∼π(x),和固定的步长ϵ>0\epsilon>0ϵ>0,Langevin方法循环地重复下面的步骤:
x~t=x~t−1+ϵ2∇xlog⁡p(x~t−1)+ϵzt\tilde{\mathbf{x}}_t=\tilde{\mathbf{x}}_{t-1}+\frac{\epsilon}{2}\nabla_\mathbf{x}\log p(\tilde{\mathbf{x}}_{t-1})+\sqrt{\epsilon}\mathbf{z}_t x~t​=x~t−1​+2ϵ​∇x​logp(x~t−1​)+ϵ​zt​其中zt∼N(0,I)\mathbf{z}_t\sim\mathcal{N}(0,\mathbf{I})zt​∼N(0,I)。当ϵ→0\epsilon\rightarrow0ϵ→0,T→∞T\rightarrow\infinT→∞时,x~T\tilde{\mathbf{x}}_Tx~T​的分布是pdata(x)p_{data}(\mathbf{x})pdata​(x)。

传统score-based generative modeling存在的问题

流型假设上的问题

流型假设指出,现实世界中的数据倾向于集中在嵌入高维空间(也称为环境空间)中的低维流形上。

The manifold hypothesis states that data in the real world tend to concentrate on low dimensional manifolds embedded in a high dimensional space (a.k.a., the ambient space).

在流型假设下,score-based generative models存在两个问题:

  1. ∇xlog⁡pdata(x)\nabla_\mathbf{x}\log p_{data}(\mathbf{x})∇x​logpdata​(x)在低维流型上没有定义。
  2. 只有在数据分布是整个空间时,score估计量才具有一致性(consistent)。

低密度区域的问题

在这里插入图片描述

  1. 在数据的低密度区域,并没有足够的数据样本去准确地学习score function。
  2. 当数据分布的两个峰(mode)被低密度区域分隔时,Langevin dynamics将无法在合理的时间内正确恢复这两个峰的相对权重,并且可能不会收敛到真实分布。例如,假设pdata(x)=πp1(x)+(1−π)p2(x)p_{data}(\mathbf{x})=\pi p_{1}(\mathbf{x})+(1-\pi)p_{2}(\mathbf{x})pdata​(x)=πp1​(x)+(1−π)p2​(x),并且p1p_{1}p1​和p2p_{2}p2​没有相交的支撑集,在求导后,权重π\piπ将不会影响score function。

Noise Conditional Score Network

为了解决上面的问题,作者对传统score-based generative modeling进行了改进。
作者提出通过 1) 使用各种噪声水平来扰动数据;2)用一个条件分数网络(conditional score network)同时估计所有噪声水平对应的分数。
在条件分数网络训练结束后,使用Langevin dynamics来生成样本时,最开始使用高噪声对应的分数,然后逐渐降低噪音。 这有助于将高噪声的好处平稳地转移到低噪声。而低噪声干扰的数据与原始数据几乎无法区分。

噪声条件分数网络(Noise Conditional Score Networks)

{σi}i=1L\{\sigma_i\}_{i=1}^L{σi​}i=1L​是一系列噪声水平,满足条件σ1σ2=⋯=σL−1σL>1\frac{\sigma_{1}}{\sigma_{2}}=\cdots=\frac{\sigma_{L-1}}{\sigma_{L}}>1σ2​σ1​​=⋯=σL​σL−1​​>1,qσ(x)q_\sigma(\mathbf{x})qσ​(x)是噪声扰动后的数据分布。我们要学习一个噪声条件分数网络sθ(x,σ)s_\theta(\mathbf{x},\sigma)sθ​(x,σ)来估计噪声数据的分数,也就是sθ(x,σ)≈∇xlog⁡qσ(x)s_\theta(\mathbf{x},\sigma)\approx\nabla_\mathbf{x}\log q_\sigma(\mathbf{x})sθ​(x,σ)≈∇x​logqσ​(x)。注意这里的分数网络是条件分数网络,输入相较于传统的sθ(x)s_\theta(\mathbf{x})sθ​(x)多了一个σ\sigmaσ。
作者考虑的是图像生成的问题,所以sθ(x,σ)s_\theta(\mathbf{x},\sigma)sθ​(x,σ)的结构作者选择的是U-Net。

对于噪声条件分数网络的训练,作者选择的噪声分布是qσ(x~∣x)=N(x~∣x,σ2I)q_\sigma( \tilde {x} |x)=\mathcal{N}( \tilde{x} |x, \sigma^{2}\mathbf{I})qσ​(x~∣x)=N(x~∣x,σ2I)。
对于一个给定的噪声σ\sigmaσ,优化的目标是:
l(θ,σ)=12EpdataEx~∼N(x,σ2I)[∥sθ(x~,σ)+x~−xσ2∥22]\mathcal{l}(\theta,\sigma)=\frac{1}{2}\mathbb{E}_{p_{data}}\mathbb{E}_{\tilde\mathbf{x} \sim \mathcal{N}(x, \sigma^{2}\mathbf{I})}[\| s_\theta(\tilde\mathbf{x},\sigma) + \frac{\tilde\mathbf{x}-\mathbf{x}}{\sigma^2} \|_2^2]l(θ,σ)=21​Epdata​​Ex~∼N(x,σ2I)​[∥sθ​(x~,σ)+σ2x~−x​∥22​]将所有的噪声融合在一个式子中有:
L(θ;{σi}i=1L)≜1L∑i=1Lλ(σi)l(θ,σi)\mathcal{L}(\theta;\{\sigma_i\}_{i=1}^L)\triangleq\frac{1}{L}\sum_{i=1}^L\lambda(\sigma_i)\mathcal{l}(\theta,\sigma_i)L(θ;{σi​}i=1L​)≜L1​i=1∑L​λ(σi​)l(θ,σi​)

annealed Langevin dynamics

在噪声条件分数网络sθ(x;σ)s_\theta(\mathbf{x};\sigma)sθ​(x;σ)训练完成之后,作者提出annealed Langevin dynamics算法来生成样本, 如算法1所示。
在这里插入图片描述

参考

Yang Song’s blog《Generative Modeling by Estimating Gradients of the Data Distribution》
NIPS 2019《Generative Modeling by Estimating Gradients of the Data Distribution》

相关内容

热门资讯

监控摄像头接入GB28181平... 流程简介将监控摄像头的视频在网站和APP中直播,要解决的几个问题是:1&...
Windows10添加群晖磁盘... 在使用群晖NAS时,我们需要通过本地映射的方式把NAS映射成本地的一块磁盘使用。 通过...
protocol buffer... 目录 目录 什么是protocol buffer 1.protobuf 1.1安装  1.2使用...
在Word、WPS中插入AxM... 引言 我最近需要写一些文章,在排版时发现AxMath插入的公式竟然会导致行间距异常&#...
【PdgCntEditor】解... 一、问题背景 大部分的图书对应的PDF,目录中的页码并非PDF中直接索引的页码...
Fluent中创建监测点 1 概述某些仿真问题,需要创建监测点,用于获取空间定点的数据࿰...
educoder数据结构与算法...                                                   ...
MySQL下载和安装(Wind... 前言:刚换了一台电脑,里面所有东西都需要重新配置,习惯了所...
修复 爱普生 EPSON L4... L4151 L4153 L4156 L4158 L4163 L4165 L4166 L4168 L4...
MFC文件操作  MFC提供了一个文件操作的基类CFile,这个类提供了一个没有缓存的二进制格式的磁盘...