논문 구현

참고 영상

1. Introduction

Deep generative model은 최근 다양한 데이터에서 높은 퀄리티의 샘플을 만들고 있다. Generative Adversarial Network (GAN), Variational AutoEncoder (VAE) 등은 이미지와 오디오 샘플을 합성하여 좋은 결과물을 만들었으며, energy-based modeling과 score matching 분야에서도 GAN과 유사한 이미지를 생성하는 놀라운 발전이 이루어졌다.

본 논문에서는 diffusion probabilistic model에 대해 소개하고 있다. Diffusion model은 유한한 시간 후에 원본 데이터와 일치하는 샘플을 생성하기 위해 variational inference를 사용하여 학습된 parametrized Markov chain이다. Markov chain은 diffusion process를 역으로 수행할 수 있도록 학습되는데, 이때 diffusion process는 데이터에 조금씩 noise를 추가하는 Markov chain을 의미한다. 작은 양의 Gaussian noise로 이루어진 확산일 경우 chain transition를 conditional Gaussian으로 설정하는 것으로 충분하며, 이는 간단한 neural network parametrization을 가능케 한다.

2. Background

Untitled

우리의 궁극적인 목적은 diffusion process에 대한 $q$의 정보가 주어졌을 때 그 역방향인 reverse process를 나타내는 $p$를 구하는 것으로, 이 $p$를 근사한 것이 $p_\theta$가 된다.

Diffusion model은 $p_\theta (\mathbf{x}0) := \int p\theta(\mathbf{x}{0:T})d \mathbf{x}{1:T}$의 형태로 표현되는 latent variable model이고, 이때 $\mathbf{x}_1, \cdots, \mathbf{x}T$는 data $\mathbf{x}0 \sim q(\mathbf{x}0)$와 같은 dimensionality를 갖는 latent vector이다. Joint distribution $p\theta (\mathbf{x}{0:T})$를 reverse process라 하며, 이 값은 다음과 같이 $p(\mathbf{x}T)=\mathcal{N}(\mathbf{x}T; \mathbf{0}, \mathbf{I})$로부터 시작된 Gaussian transition으로 학습된 Markov chain으로서 정의된다. $\mathbf{x}{t-1}$은 $\mathbf{x}t$의 영향만 받는다고 가정하면, 즉 $p\theta (\mathbf{x}{t-1}|\mathbf{x}t) = p\theta (\mathbf{x}{t-1}|\mathbf{x}t, \mathbf{x}{t+1}, \cdots, \mathbf{x}_T)$라 가정하면 다음의 식이 성립한다.

Untitled

Diffusion model이 다른 latent variable model과 갖는 차별점은 forward process 혹은 diffusion process라 불리는 $q(\mathbf{x}_{1:T}|\mathbf{x}_0)$가 다음과 같이 variance $\beta_1, \cdots, \beta_T$를 갖는 gaussian noise가 점진적으로 추가되는 Markov chain으로 주어진다는 것이다.

Untitled

이처럼 설정하는 목적은 variance를 $\mathbf{I}$로 유지시키기 위함이다. Eq (2)에서 $\epsilon \sim \mathcal{N} (\mathbf{0}, \mathbf{I})$에 대해 $\mathbf{x}t = \sqrt{1- \beta_t} \mathbf{x}{t-1} + \sqrt{\beta_t} \epsilon$로 표현할 수 있고, 처음의 input인 $\mathbf x_0$의 variance가 $\mathbf I$가 되도록 scaling해준 경우 $V(\mathbf{x}t) = (1-\beta_t)V(\mathbf{x}{t-1})+\beta_t V(\epsilon) = (1-\beta_t) \mathbf{I}+\beta_t \mathbf{I}=\mathbf{I}$로 유지된다.

우리는 앞서 언급했듯이 실제 data의 분포인 $p_\theta(\mathbf{x}0)$의 likelihood를 최대화해야 하는데, 이는 $-\log p\theta (\mathbf{x}0)$를 최소화하는 문제와 같다. 이때 $-\log p\theta (\mathbf{x}_0)$의 upper bound를 구하면 다음과 같다.

Untitled

또한 주목할만한 점은 $\mathbf x_0$로부터 $\mathbf{x}_t$를 sampling하는 식을 closed form으로 쓸 수 있다는 점이다. $\alpha_t := 1-\beta_t$, $\overline{\alpha}t:=\Pi{s=1}^t \alpha_s$라 했을 때 다음과 같은 식을 얻을 수 있다.