본문 바로가기

Deep Learning/Memo or etc.

Diffusion Model 공부 자료

https://lilianweng.github.io/posts/2021-07-11-diffusion-models/ (Diffusion의 바이블)

 

What are Diffusion Models?

[Updated on 2021-09-19: Highly recommend this blog post on score-based generative modeling by Yang Song (author of several key papers in the references)]. So far, I’ve written about three types of generative models, GAN, VAE, and Flow-based models. They

lilianweng.github.io

https://www.youtube.com/watch?v=P-gqrYYZ3a8 (5분짜리)

https://youtu.be/d_x92vpIWFM (45분짜리. 레전드로 알참.)

 

https://www.youtube.com/watch?v=zcEe78I_4TU (더 레전드)

 

확산 모델에서 '모델'이라고 하는 것은 '다음 이미지를 추정'하는 게 아니다.

VAE에서와 같이 매개변수화를 이용해 랜덤 샘플링된 '가우스 노이즈'를 추정하는 것이다.

 

 

추정된 노이즈를 제거함으로써 '다음 이미지'를 추정함.

"""
x = noised images
t = timestep
"""
predicted_noise = model(x, t, training=False)

alpha_t = extract(alpha, t)
alpha_hat_t = extract(alpha_hat, t)
beta_t = extract(beta, t)

alpha_hat_prev_t = extract(alpha_hat_prev, t)
beta_hat_t = beta_t * (1 - alpha_hat_prev_t) / (1 - alpha_hat_t) # similar to beta

noise = tf.random.normal(shape=x.shape)

""" DDPM """
direction_point = 1 / tf.sqrt(alpha_t) * (x - (beta_t / (tf.sqrt(1 - alpha_hat_t))) * predicted_noise) # mu
random_noise = beta_t * noise # stddev

denoised_x = direction_point + random_noise

 

DDIM에서는 랜덤 가우스 노이즈의 표준 편차를 아예 0으로 지정해서 모델을 결정론적으로 만들어 버렸다. 순방향 프로세스가 더 이상 확산이 아님에도 불구하고.라는 센스 있는 멘트는 덤.

DDIM의 장점은

  • 빠르고 고품질의 추론
  • 생성 결과가 일관됨
  • 보간이 가능하다

 

샘플 생성

'Deep Learning > Memo or etc.' 카테고리의 다른 글

Transformer Tutorial  (1) 2024.01.03
수학  (2) 2023.10.06
Flow 자료  (0) 2023.10.06
Language Model 자료 모음  (0) 2023.10.06
메모 - score based model  (0) 2023.01.23