ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 6. Generative Models
    AI/2주차 2021. 8. 13. 15:22

    만약 강아지들의 이미지가 주어지고, 그로부터 probability p(x)를 학습한다면

    • Generation: $ x_{new}  $ ~ $  p(x), x_{new} $ 는 강아지 같아야 한다(sampling)
    • Density Estimation(anomaly detection): x가 강아지 처럼 생겼다면 p(x)가 크고, 강아지처럼 생기지 않았다면 작아야한다. 
    • Unsupervised representation learning: 강아지들이 공통적으로 가지는 특징에 대해 배운다 (feature learning), e.g., ears, tail, etc

    p(x)는 어떻게 만드는가?? 

    만약 RGB distribution을 만든다고 해보자. 하나의 픽셀의 색은 256 * 256 * 256 가지의 색을 만들 수 있다. 그러므로 총 n-1개의 파라미터인 256 * 256 *  256 - 1개의 파라미터가 필요하다. 

    만약 각각의 픽셀이 binary 인 경우라면? $ 2^n - 1$ 개의 파라미터가 필요하다.

    => 너무 많은 파라미터가 필요하다. 따라서 n개의 파라미터가 독립 (independence assumption) 이라고 가정. $ 2^n $ -> $ n $ 개의 파리미터로 바뀐다. 

     

    Conditional Independence

    • Chain Rule: $ 2^n - 1 $개의 파라미터를 가진다.

    • Baye's Rule

    • Conditional Independence (가정): z라는 random variable이 주어지면 x, y가 independent 하다. x라는 random variable은 z가 주어지면 x와 y의 independence 때문에 y를 고려할 필요가 없다 => Chain Rule과 잘 섞어서 fully dependent와 fully independent 사이의 모델을 생성(auto regressive model)

    Markov Assumption: i단계는 i-1단계에만 dependent 하다. 이를 이용할 경우 2n - 1개의 파라미터 필요. 파라미터 개수의 Exponentail Reduction이 가능하다. 

    Auto-regressive Model:

    Chain Rule을 사용하여 joint distribution을 factoring. Markov Assumption을 써서 i를 계산할 때 i-1만 고려할수도 있고, 그 전의 n 단계도 고려할 수 있다. 

     

    NADE: Neural Autoregressive Density Estimator. Explicit Model. 확률을 계산할 때 전의 모든 단계를 고려. 주어진 input의 density도 계산 가능하다. Continous Random Variable을 모델링 하는 경우 Gaussian Mixture Model을 사용

    Explicit methods calculate the state of a system at a later time from the state of the system at the current time, while  implicit methods find a solution by solving an equation involving both the current state of the system and the later one
    https://en.wikipedia.org/wiki/Explicit_and_implicit_methods
     

    Explicit and implicit methods - Wikipedia

    From Wikipedia, the free encyclopedia Jump to navigation Jump to search Approaches for approximating solutions to differential equations Explicit and implicit methods are approaches used in numerical analysis for obtaining numerical approximations to the s

    en.wikipedia.org

    Pixel RNN: n x n RGB 이미지 생성. RNN을 통해 Generate을 한다. Ordering 방식에 따라 이름을 붙인다.

    • Row LSTM: R 번째 pixel을 만들 때 위쪽에 있는 정보를 활용
    • Diagonal BiLSTM: Bidirectional LSTM을 활용하되 자기 이전 정보를 모두 활용

     


    https://www.youtube.com/watch?v=odpjk7_tGY0&t=69s&ab_channel=naverd2 

    Latent Variable Models

    Autoencoder는 Generative model인가? No. VAE가 generative model이 될 수 있는 이유를 아는것이 중요하다. 

     

    Variational Auto-Encoder

    • Variational Inference(VI): posterior distribution을 가장 만족하는 variational distribution을 찾는 것. Observation이 주어졌을 때 관심있어하는 variable의 확률 분포. 
    • KL divergence를 최소화 하는 variational distribution을 찾는다. 

    Variational Distribution을 어떻게 찾는가??

    ELBO (Evidence Lower BOund) Trick을 이용한다. ELBO를 maximize하는 방식으로 objective를 줄인다. 

    VAE는 어떤 입력이 주어지고, 이를 latent space로 보낸 다음 무언가를 찾고 이를 다시 reconstruction 하는 term으로 만들어진다. Generative Model이 되기 위해서는 latent space에 대한 prior distribution으로 z를 샘플링 하고, 이를 decoder에 입력하여 나오는 output들이 "Generation" 된 output이기 때문에 이를 generative model로 볼 수 있다. 

     

    Key limitations

    • Explicit 한 모델이 아니다. 어떤 모델이 주어졌을 때 likelihood를 평가하기 어렵다 (intractable).
    • prior fitting term은 반드시 미분 가능해야한다. ELBO는 reconstruction term과 prior fitting term으로 나뉘는데, prior fitting term에 해당하는 KL divergence는 정규분포를 제외하면 closed form 형태로 나오는 경우가 잘 없다. KL Divergence 자체에 적분이 들어가 있기 때문에 closed form으로 나오지 않으면 계산이 불가능하여 주로 가우시안 분포를 활용한다. 
    • Isotropic Gaussian을 주로 활용한다. 

    Gaussian을 사용하기 싫으면 어떻게 해야하는가 => Adversarial Auto-encoder 사용! 

    KL divergence의 prior fitting term을 GAN objective로 변경. 샘플링 가능한 분포가 존재하면 Latent distribution을 이와 맞출 수 있다.

     

    GAN

    Generator와 Discriminator를 이용하여 Generator는 Discriminator를 더 잘 속이려고하고, Discriminator는 Generator의 결과를 더 잘 분별하려고 한다. 

    Two player minimax game between generator and discriminator

     

    • Discriminator Objective

    • Optimal Discriminator

    • Generator Objective

    위 수식에 optimal discriminator를 대입하면 True data distribution과 내가 학습한 distribution 사이의 Jenson-Shannon Divergence를 최소화하게 된다 => 이론적으로는 말이 되지만, 현실적으로는 쉽지 않다


    다양한 종류의 GAN

     

    DCGAN

    GAN이 잘 동작하기 위한 방법론들 제시 (deconvolution, Leaky ReLU ...)

     

    Info-GAN

    Random한 class를 입력으로 넣어주어 특정 모드에 집중할 수 있게 만들어줌.

     

    Text2Image

    Puzzle-GAN

    이미지 안의 subpatch를 이용하여 원래 이미지를 복원

     

    CycleGAN

    Cycle-consistency loss를 이용하여 이미지간의 도메인을 변경. 매우 중요한 concept. 

     

    Star-GAN

    이미지를 단순히 다른 도메인으로 바꾸는 것이 아닌, 특징을 control 할 수 있음.

    Progressive-GAN

    고차원의 이미지를 잘 생성. 이미지를 점점 고해상도로 train 시킴

    'AI > 2주차' 카테고리의 다른 글

    5. RNN  (0) 2021.08.12
    4. Convolution  (0) 2021.08.11
    3. Optimization  (0) 2021.08.10
    2. 딥러닝 Basic & MLP  (0) 2021.08.09
    1. 데이터 시각화  (0) 2021.08.09

    댓글

Designed by Tistory.