Cs236 Lecture16

JInwoo·2025년 2월 17일

cs236

목록 보기
14/15

Diffusion Models

Iterative Noising Process

x0\mathbf{x}_0 부터 xT\mathbf{x}_T 까지 점차 noise를 더해간다. x0\mathbf{x}_0는 perturbed 되지 않은 density를 가지며 pdata(x0)p_{data}(\mathbf{x_0}) 와 같다. xT\mathbf{x}_T는 pure noise density를 가지며 π(xT)\pi(\mathbf{x}_T)와 같다. 아래 그림의 qq는 noise를 더하는 kernel 정도로 생각할 수 있다.

time step tt는 이전 step에 의해서만 영향을 받으며 다음과 같은 관계식을 같는다.

  • q(xtxt1)=N(xt;1βt0xt1,βtI)q(\mathbf{x_t|x_{t-1}})=\mathcal{N}(\mathbf{x}_t;\sqrt{1-\beta_t}0\mathbf{x}_{t-1},\beta_tI), βt\beta_t는 rescale term.

위 관계에 따라 joint distribution은 q(x1:Tx0)=Tt=1q(xtxt1)q(\mathbf{x_{1:T}|x_0})=\underset{t=1}{\overset{T}{\prod}}q(\mathbf{x_t|x_{t-1}}) 로 정의 된다.

각 step tt의 transition들은 모두 Gaussian 이다. 따라서 아무 step tt에 대해 closed form으로 distribution을 구할 수 있다.

  • q(xtx0)=N(xt;αtˉx0,(1αtˉ)I)q(\mathbf{x_t|x_0})=\mathcal{N}(\mathbf{x_t};\sqrt{\bar{\alpha_t}}\mathbf{x_0}, (1-\bar{\alpha_t})I), αtˉ=ts=1(1βs)\bar{\alpha_t}=\underset{s=1}{\overset{t}{\prod}}(1-\beta_s)

따라서 특정 step tt 에 대한 perturbed distribution을 얻기 위해 모든 noising process를 거치지 않아도 왼다.

Iterative Denosing


Denosing process는 noising process의 정확히 반대로 수행된다. xT\mathbf{x_T}π(xT)\pi(\mathbf{x_T)}로 부터 sampling 하여 반복적으로 q(xt1xt)q(\mathbf{x_{t-1}|x_t}) 를 수행한다. 이때 문제는 q(xt1xt)q(\mathbf{x_{t-1}|x_t}) 가 unknown이라는 것이다. 따라서 이 문제를 해결하기 위해 q(xt1xt)q(\mathbf{x_{t-1}|x_t}) 에 대한 variational approximation을 수행한다.

q(xt1xt)pθ(xt1xt)q(\mathbf{x_{t-1}|x_t})\approx p_\theta(\mathbf{x_{t-1}|x_t})를 modeling 한다. pθ(xt1xt)=N(xt1;μθ(xt,t)0,σ2I)p_\theta(\mathbf{x_{t-1}|x_t})=\mathcal{N}(\mathbf{x_{t-1};\mu_\theta(x_t},t)0,\sigma^2I)를 만족하며, pθp_\theta로 부터 sampling을 반복한다. joint distribution은 pθ(x0:T)=p(xT)Tt=1pθ(xt1xt)p_\theta(\mathbf{x_{0:T}})=p(\mathbf{x_T})\underset{t=1}{\overset{T}{\prod}}p_\theta(\mathbf{x_{t-1}|x_t})로 정의 된다.

Diffusion Model as a Hierarchical VAE

Diffusion model을 계층적 구조를 가진 VAE의 연속으로 볼 수 있다. noise를 더하는 과정을 encoder로 보고, de-nosing 과정을 decoder로 보면 VAE 형태가 된다. 이 때, VAE와 달리 encoder는 고정된 형태로 학습이 불가능하다.

  • Encoder(fixed): q(x1:Tx0)=Tt=1q(xtxt1)q(\mathbf{x_{1:T}|\mathbf{x_0})=\underset{t=1}{\overset{T}{\prod}}}q(\mathbf{x_t|\mathbf{x}_{t-1})}
  • Decoder(learnable): pθ(x0:T)=p(xT)Tt=1pθ(xt1xt)p_\theta(\mathbf{x_{0:T}})=p(\mathbf{x_T)\underset{t=1}{\overset{T}{\prod}}}p_\theta(\mathbf{x_{t-1}|x_t)}

VAE 처럼 negative ELBO를 training loss로 사용하여 학습을 진행할 수 있다. 이에 대한 loss function은 다음과 같다.

이는 이전에 살펴본 denoising score matching의 loss fucntion과 일치한다.

Reference

cs236 Lecture 16

profile
Jr. AI Engineer

0개의 댓글