VAE 계열 모델의 ELBO(Evidence Lower Bound) 분석
- -
RecVAE 모델을 분석하기 위해 논문을 읽으면서 VAE에 관해 모르거나 잘못 알고 있던 내용이 많다는 걸 알게 되어 이를 정리하고자 한다. 특히 ELBO 부분이 그전에는 잘 이해가 안 갔는데, 이번에 붙잡고 공부하면서 좀 더 명확히 이해할 수 있게 되었다. 그리고 VAE의 ELBO 유도 과정을 완전히 잘못 알고 있어서 복습하면서 정정했다.
VAE(Varational AutoEncoder) 한번에 이해하기


위의 노트 필기의 흐름을 따라가보면 VAE의 ELBO가 왜 loss function에서 나오는 건지와 그 학습 방법을 이해할 수 있다.
VAE 계열 모델의 ELBO 분석
VAE(Variational Autoencoders)
[출처] https://commons.wikimedia.org/wiki/File:VAE_Basic.png, EugenioTL
VAE(Variational Autoencoder)는 데이터를 Encoder에 넣어서 input보다 차원이 작은 latent space에서의 확률 분포에 관한 모수를 구하고, 이 latent space에서 앞서 구한 확률 분포로 샘플링하여 Decoder에 통해 새로운 이미지를 reconstruction 하는 비지도학습 모델이다. 이에 관한 자세한 내용은 이전 포스팅에서 다룬 바 있다.
[출처] https://arxiv.org/pdf/1802.05814.pdf, Variational Autoencoders for Collaborative Filtering
https://glanceyes.tistory.com/entry/Deep-Learning-Generative-Model
생성 모델(Generative Model)과 VAE, 그리고 GAN
2022년 2월 7일(월)부터 11일(금)까지 네이버 부스트캠프(boostcamp) AI Tech 강의를 들으면서 개인적으로 중요하다고 생각되거나 짚고 넘어가야 할 핵심 내용들만 간단하게 메모한 내용입니다. 틀리거
glanceyes.tistory.com
종종 VAE에서는 marginal likelihood function을 latent variable인
https://m.blog.naver.com/sw4r/221380395720
[수리통계학] Marginal Likelihood 란? (빈도주의VS. 베이지안 관점 비교)
Marginal Likelihood (or Integrated Likelihood)에 대해서 알아보겠다. 항상 그랬듯이 먼저 위키 정의...
blog.naver.com
정리하자면, 베이즈 이론에서 Evidence에 해당되는
들어가기에 앞서 우리는 VAE를 사용하고자 하는 목적부터 생각해봐야 한다.
우리는 VAE에서 사후 확률 분포(posterior distribution)인
우리의 최종 목적은
ELBO(Evidence Lower Bound)
이를 위해 marginal likelihood function인
우리의 최종 목적을 달성하려면 뒤에 있는 항이 줄어들어야 하는 것이고, 이는 앞에 있는 ELBO(Evidence Lower Bound)를 증가시키면 된다.
사족이지만 처음에는 ELBO에서 왜 Evidence가 앞에 붙는지 이해를 못 했는데, marginal likelihood function이 결국 Evidence와 연관이 있다는 사실을 뒤늦게 깨달았다.
앞에 있는 ELBO를 정리하면 다음과 같다.
결국 ELBO는 두 개의 항으로 유도가 가능한데, 이는 Reconstruction Term과 Prior Fitting Term이다.
Reconstruction term은 encoder를 통해서 input을 latent space로 보내고 다시 decoder로 돌아오는 reconstruction loss을 줄이는 역할을 한다.
Latent space는 input 대상을 잘 설명할 수 있는 공간이며, input의 feature 중 일부는 다른 feature의 조합으로 표현 가능해서 불필요할 수 있으므로 latent space는 일반적으로 실제 space보다 작다.
Prior fitting term은 input을 latent space로 올렸을 때 이루는 latent distribution이자 앞에서 정한 근사 사후 확률 분포(variational approximation of the posterior distribution)를 prior distribution과 유사하도록 강화해주는 것이며, KL Divergence를 활용한다.
Amortized Inference
위에서 구한 ELBO와 marginal likelihood의 관계를 파악하여 논문에서 정리한 식에 맞게 정리하면 다음과 같다.
요약하면, 앞서 정리한 내용을 토대로 marginal likelihood는 최소한 ELBO보다는 크거나 같다는 것을 뜻한다.
이러한 테크닉을 Amortized Inference라고 하며, 이를 통해 추가적인 정규화를 할 수 있고 variational parameters를 close form function으로 구할 수 있다. 또한 Encoder의 input인 서로 다른
[출처] https://arxiv.org/pdf/1711.05597.pdf, Advances in Variational Inference
Amortized Inference에 관해 잘 정리된 글이 있어서 이를 참조했다.
https://ricoshin.tistory.com/3
Amortized Inference란?
https://www.quora.com/What-is-amortized-variational-inference What is amortized variational inference? Answer: Let me briefly describe the setting first, as the best way to understand amortized vari..
ricoshin.tistory.com
-VAE(Beta-Variational Autoencoder)
VAE는 생성 모델이기도 하지만 representation을 학습할 수 있기도 하다.
DVAE(Denoising Variational Autoencoders)
DVAE(Denoising Variational Autoencoders)는 DAE(Denoising Autoencoders)와 유사하게 input에 noise를 추가하여 재건될 수 있도록 하는 모델이며, 이때의 ELBO는 다음과 같이 정의할 수 있다.
여기서는 VAE와 달리 input인
이에 관한 자세한 내용은 아래 논문을 통해서 볼 수 있다.
https://arxiv.org/abs/1511.06406
Denoising Criterion for Variational Auto-Encoding Framework
Denoising autoencoders (DAE) are trained to reconstruct their clean inputs with noise injected at the input level, while variational autoencoders (VAE) are trained with noise injected in their stochastic hidden layer, with a regularizer that encourages thi
arxiv.org
CVAE(Conditional Variational Autoencoder)
CVAE(Conditional Variational Autoencoder)는 좀 더 복잡한 조건부 확률을 학습하기 위해 구현한 VAE의 연장선으로 볼 수 있다. ELBO 식을 정의하면 다음과 같다.
모든 확률 분포가
VAEAC(VAE with Arbitrary Conditioning)
[출처] https://arxiv.org/pdf/1806.02382.pdf, Variational Autoencoder with Arbitrary Conditioning
VAEAC(VAE with Arbitrary Conditioning)는 여기서 더 나아가 missing feature를 위한 imputation problem을 해결하기 위해 제안되었으며, 많은 부분에 있어서 Collaborative Filtering과 비슷하다.
VAEAC의 ELBO는 Binary mask인
중요한 점은 mask
업데이트
1. 'VAE 한번에 이해하기' 항목을 추가하고 노트필기 이미지를 첨부했습니다. (2023. 03. 19)
2. 'VAE 한번에 이해하기' 항목의 잘못된 내용을 수정했습니다. (2023. 05. 23)
소중한 공감 감사합니다.