Generative modeling에서 GAN 이후로 다양한 모델이 나왔는데 현재도 그 모델 안에서 발전 중이다.
나름대로 흐름을 설명하면서 이야기하고 싶어서 조금씩 커버를 하고자 한다.
첫 번째 이야기는 Normalizing flows에 대한 이야기이다. 정확히 이게 뭔지를 알아야 나중에 discrete normalizing flows에서 continuous normalizing flows로 넘어가는 걸 이해할 수 있다. 사실 이전에 Variational autoencoder를 또 이해해야하는 문제인데 그건 나중에 작성해서 여기에 링크를 남길 예정이다.
흐름
normalizing flows (Ordinary differential equation model) (2016) - diffusion models (Stochastic differential equation models) - flow matching (how to train scalable continuous models) (2023)
0. Generative model이란 무엇인가?
Generative model은 sample을 생성하는 machine learning model이다.
Dataset (z_1,\ldots,z_N \sim p_{data})가 주어졌을 때,
$$
z \sim p_{data}
$$
를 생성하는 것이 목표이다.
만약 text prompt와 같은 conditioning variable (y)가 존재한다면,
$$
z \sim p_{data}(\cdot|y)
$$
를 생성하는 conditional generative model이 된다.
Normalizing flow는 “invertible transformation을 이용한 change of variables”로 설명할 수 있다. 그렇다면 왜 variable을 바꾸어야 할까?
생성 모델은 정답이 하나로 정해져 있지 않은 문제와 유사하다. 우리는 다양한 sample들을 생성하고 싶기 때문에, 일반적인 noise distribution으로부터 우리가 원하는 복잡한 data distribution으로 변환하는 과정이 필요하다.
즉, 랜덤하게 sampling한 (x)를 우리가 원하는 데이터 분포를 따르는 (z)로 변환하고 싶은 것이다.
$$
x \sim p_{init}
\quad \rightarrow \quad
\text{(generative model)}
\quad \rightarrow \quad
z \sim p_{data}
$$
우리는 이미 (p_{init})을 알고 있다. 예를 들어 (\mathcal{N}(0,I_d))와 같은 단순한 distribution이며 sampling도 쉽다.
반면, (p_{data})는 매우 복잡한 distribution이고, 우리는 dataset (z_1,\ldots,z_N)와 같은 일부 sample만 알고 있는 상황이다.
따라서 normalizing flow를 학습하여 이러한 distribution을 modeling한다.
2. “Discrete” normalizing flow의 formulation
더 자세한 내용:
Rezende and Mohamed 2016; Dinh, Krueger, and Bengio 2015; Dinh, Sohl-Dickstein, and Bengio 2017
모델은 다음과 같이 주어진다. $x=f_i(z), \quad z=f_i^{-1}(x)$와 같이 변수를 변환하는 mapping $f$가 있다고 하자.
이러한 mapping이 계속 모여서 $f$를 만들 때 이 mapping의 누적으로 만들어지는 확률 분포는 다음과 같다.
$$
p(x)
=p(z)
\left|
\det
\frac{\partial f^{-1}}{\partial x}
\right|
$$
여기서
$$
f = f_K \circ \cdots \circ f_1
$$
이다.
이는 invertible transformation들의 chain이다. 각 layer는 invertible해야 하며 tractable한 Jacobian determinant를 가져야 한다.또한 log-density는 다음과 같이 표현된다.
$$
\log p(x)
= \log p(z_0)
\sum_{k=1}^{K}
\log
\left|
\det J_{f_k}(z_{k-1})
\right|
$$
이 모델은 다음 조건들을 만족해야 한다.
* Input과 output의 dimension이 동일해야 한다.
* Transformation이 invertible해야 한다.
* Jacobian determinant 계산이 efficient하고 differentiable해야 한다.
추가적으로 $x,z$ 변수들이 deterministic하게 정해진다는 것도 특징이다.
3. normalizing flow 예시
(f_k)를 modeling하는 방법은 매우 다양하다. Neural network 기반으로는 다음과 같이 mapping (f)를 modeling할 수 있다.
$$
z_k
= f_{\theta}(z_{k-1})=
z_{k-1}
+
u h\left(
\mathbf{w}^{\top} z_{k-1} + b
\right)
$$
여기서 (u,w,b)는 trainable parameter이다.
이 외에도 다양한 모델링 방법이 있지만 현재 주로 쓰이는 것은 diffusion model과 flow matching이므로 빠르게 넘어가도록 한다.
https://deepgenerativemodels.github.io/notes/flow/
Normalizing Flow Models
If , then the mappings is volume preserving, which means that the transformed distribution will have the same “volume” compared to the original one .
deepgenerativemodels.github.io
'연구 Research > 인공지능 Artificial Intelligent' 카테고리의 다른 글
| [공부] Automatic differentiation forward mode & reverse mode (0) | 2025.03.09 |
|---|---|
| [연구] SciML 분야 라이브러리 기록 (0) | 2024.03.11 |
| [chatGPT] chatGPT 프롬프트 엔지니어링 (0) | 2023.11.28 |
| [JAX] L-BFGS optimizer로 학습하는 예제 코드 (0) | 2023.11.02 |
| [Deep learning] Bayesian Neural Network (1) (0) | 2023.10.23 |