SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Downloaden Sie, um offline zu lesen
Variational Inference
Deeplearning chapter 19
민다빈
Variational Autoencoder
2
잠재변수 𝑧
데이터 𝑥
우도함수 𝑝(𝑥|𝑧)
𝑧의 사전확률 𝑝(𝑧)
𝑥의 사전확률 𝑝 𝑥
𝑧가 주어진 상황에서 𝑥가 나타날 확률 𝑝 𝑥 𝑧 : 우도
𝑥가 주어진 상황에서 𝑧가 나타날 확률 𝑝 𝑧 𝑥 : 사후확률
사후확률 𝑝(𝑧|𝑥)를 알기 어렵기 때문에 근사하는 간단한
함수를 찾음 𝑞(𝑧) 또는 𝑞(𝑧|𝑥)
Variational inference
흰색: 잠재변수(z)
회색: 관측변수(x)
- 주어진 데이터(𝑥)와 주어지지 않은 잠재변수(𝑧)가 모델에 관여하는 상황.
- 어떤 잠재변수로부터 주어진 데이터를 만들어낼 확률𝑝(𝑥|𝑧)이 가장 높은 모델과, 그때 최적의
잠재변수를 만드는 함수 𝑝(𝑧|𝑥)를 찾아야한다고 생각해보자.
- 이 때, 사후확률 분포 𝑝(𝑧|𝑥) 를 계산하는 것이 불가능에 가까울 정도로 어려운 경우가 많다.
잠재변수간 상호작용 때문에 marginal probability 계산이 힘들다.
Marginal probability: 𝑝(𝑥) = σ 𝑧 𝑝(𝑥, 𝑧)
3
Variational inference
VI란 사후확률(posterior) 분포 𝑝(𝑧|𝑥)를 다루기 쉬운 확률분포 𝑞(𝑧)로 근사(approximation)하는 것
사후확률 분포를 우리가 익히 알고 있는 정규분포로 근사한 경우
4
Variational inference
사후확률 𝑝(𝑧|𝑥)에 근사한 𝑞(𝑧)를 만들기 위해 두 분포의 차이를 줄여야 함.
→ 두 확률분포의 차이를 계산하는 KL-Divergence 개념 활용
사후확률 분포 𝑝(𝑧|𝑥)와 𝑞(𝑧) 사이의 KLD를 계산하고, KLD가 줄어드는 쪽으로 𝑞(𝑧)를 조금
씩 업데이트하는 과정을 반복하면 사후확률을 잘 근사하는 𝑞∗
(𝑧)를 얻게 될 것
→ 이 과정이 Variational Inference
KLD를 줄어들게 하는데 몇가지 방법이 있음.
5
Variational inference
이 KLD를 줄어들게 하는데 몇가지 방법이 있음.
우리가 최소화하고자 하는 KLD를 정리해보면,
6
1. Variational Inference with Monte Carlo
Sampling
몬테카를로 방법(Monte Carlo Method): 랜덤 표본을 뽑아 함수의 값을 확률적으로 계산하는 방법.
이를 이용하여 KLD 텀에 대한 근사식을 유도
7
1. Variational Inference with Monte Carlo
Sampling
실제 문제에서는 사후확률 분포𝑝(𝑧|𝑥)에 대해 아무런 정보가 없지만 몬테카를로 방법을
이용하면 𝑞(𝑧)를 어떤 분포로든 설정할 수 있다.
Ex) 사후분포에 대한 정보가 없어서 𝑞(𝑧)를 정규분포로 정해 볼 경우
1. 이 정규분포에서 K개의 z들을 뽑으면 KLD의 근사값을 계산 가능.
2. 정규분포의 파라메터(평균, 분산)를 조금씩 바꿔가면서 KLD 근사값을 최소로 하는
파라메터를 구할 수 있을 것.
3. 구해진 정규분포가 바로 VI의 결과.
≈
8
2. Variational Inference with SGD
KLD를 줄이는 방향으로 𝑞(𝑧)의 파라메터를 업데이트 하여 VI하는 것도 가능
→ Gradient를 계산하기 위해 KLD가 미분가능 해야함
Ex)
𝑞 𝑧 는 정규분포 𝜃 𝑞 = 𝜇 𝑞, 𝜎 𝑞 , 𝑝 𝑧 는 베타분포 𝛼, 𝛽 라고 두고 𝐾𝐿𝐷 식을 𝜃 𝑞에 대해 미분해 보자.
(적절한 𝜃 𝑞를 추론하려 하는것)
이때, z가 𝜃 𝑞를 파라메터로 갖는 𝑞에 의해 랜덤 샘플링되기 때문에 𝜃 𝑞 에 대한 미분이 불가능
→ z대신 노이즈를 샘플링해서 z를 계산하는 reparameterization trick 사용
9
2. Variational Inference with SGD
여기서도 몬테카를로 샘플링을 이용하여 KLD의 gradient 근사값을 계산.
→ Gradient 이용하여 𝜃 𝑞를 수정함으로써 사후확률 분포 𝑝(𝑧|𝑥)에 근사하는 𝑞(𝑧)를 찾을 수 있다.
10
Vatiational EM algorithm
- 지금까지는 사전확률함수 𝑝 𝑧 와 우도함수 𝑝 𝑥 𝑧 를 이미 알고 있다는 전제 하에 𝑝 𝑧 𝑥
에근사하는 𝑞 𝑧 를 찾는 𝑉𝐼 과정을 설명하였음.
- 하지만 실제 문제에서는 사전호가률과 우도함수의 파라메터 또한 알고 있지 못하는 경우가 많다.
우도함수를 모르는 상황에서 VI를 하기 위해선?
1. 사전확률 𝑝 𝑧 는 상수로 고정하여도 됨
2. 사후확률 𝑝(𝑧|𝑥)에 근사한 𝑞(𝑧)의 파라메터를 찾는 것과 동시에, 우도함수 𝑝(𝑥|𝑧)의 파라메터 또
한 추정해야 함
3. But, 이 둘을 동시에 찾는 것은 불가능.
→ 한 파라메터를 고정하고 나머지 파라메터를 최적화하는 것을 반복하는 EM algorithm 사용
11
Vatiational EM algorithm
𝑞(𝑧)의 파라메터를 𝜃 𝑞, 우도함수𝑝(𝑥|𝑧)의 파라메터를 𝜃𝑙라고 둘 때
EM algorithm은 다음과 같은 과정을 수렴할 때까지 반복함
E-step에서는 KLD를 줄이기 위해 q만을 업데이트하므로 이 과정에서 𝑝(𝑥) 는 변하지 않음.
KLD를 줄이기 위해선 M-step을 통해 𝑝(𝑥)또한 줄여야 한다.
log 𝑝(𝑥)에 대해 정리하면,
- Expectation: 우도함수 𝑝 𝑥 𝑧 의 파라메터 𝜃𝑙을 고정한 상태에서 𝐷 𝐾𝐿(𝑞(𝑧)||𝑝 𝑧 𝑥 )를
줄이는 q의파라메터 𝜃 𝑞를 찾는다.(앞에 소개한 방법 이용)
- Maximization: E-step에서 찾은 𝜃 𝑞를 고정한 상태에서 evidence 𝑝 𝑥 를 최대화하
는 우도함수 𝑝(𝑥|𝑧)의 파라메터 𝜃𝑙를 찾는다.
12
Vatiational EM algorithm
이 때, KLD는 항상 양수이므로
우변이 Evidence인 𝑝(𝑥)의 하한을 나타내므로 Evidence Lower Bound(ELBO)라고 부름
양수
M-step 설명중임
13
Vatiational EM algorithm
ELBO 두 분포의 차이
(줄이고자 하는것)
ELBO를 최대화 시킨다면?
→ 등호를 만족시키기 위해서 KLD가 최소화 될 것.
𝜃 𝑞가 고정된 상태에서 우도함수𝑝(𝑥|𝑧)의 파라메터 𝜃𝑙
를 KLD가 최소화되는 방향으로 업데이트 하는 것임
이 또한 reparameterization trick을 이용한 SGD를
사용하면 된다.(참고: http://edwardlib.org/tutorials/klqp)
Prior, 상수취급
M-step 설명중임
14

Weitere ähnliche Inhalte

Was ist angesagt?

Approximate Inference (Chapter 10, PRML Reading)
Approximate Inference (Chapter 10, PRML Reading)Approximate Inference (Chapter 10, PRML Reading)
Approximate Inference (Chapter 10, PRML Reading)Ha Phuong
 
Overview on Optimization algorithms in Deep Learning
Overview on Optimization algorithms in Deep LearningOverview on Optimization algorithms in Deep Learning
Overview on Optimization algorithms in Deep LearningKhang Pham
 
Metropolis-Hastings MCMC Short Tutorial
Metropolis-Hastings MCMC Short TutorialMetropolis-Hastings MCMC Short Tutorial
Metropolis-Hastings MCMC Short TutorialRalph Schlosser
 
Wasserstein GAN 수학 이해하기 I
Wasserstein GAN 수학 이해하기 IWasserstein GAN 수학 이해하기 I
Wasserstein GAN 수학 이해하기 ISungbin Lim
 
Chapter 6 Deep feedforward networks - 1
Chapter 6 Deep feedforward networks - 1Chapter 6 Deep feedforward networks - 1
Chapter 6 Deep feedforward networks - 1KyeongUkJang
 
PRML輪読#9
PRML輪読#9PRML輪読#9
PRML輪読#9matsuolab
 
Deep generative model.pdf
Deep generative model.pdfDeep generative model.pdf
Deep generative model.pdfHyungjoo Cho
 
Variational Inference
Variational InferenceVariational Inference
Variational InferenceTushar Tank
 
Feature Engineering
Feature EngineeringFeature Engineering
Feature EngineeringHJ van Veen
 
알기쉬운 Variational autoencoder
알기쉬운 Variational autoencoder알기쉬운 Variational autoencoder
알기쉬운 Variational autoencoder홍배 김
 
An overview of gradient descent optimization algorithms
An overview of gradient descent optimization algorithms An overview of gradient descent optimization algorithms
An overview of gradient descent optimization algorithms Hakky St
 
PRML Chapter 11
PRML Chapter 11PRML Chapter 11
PRML Chapter 11Sunwoo Kim
 
Meta-learning and the ELBO
Meta-learning and the ELBOMeta-learning and the ELBO
Meta-learning and the ELBOYoonho Lee
 
오토인코더의 모든 것
오토인코더의 모든 것오토인코더의 모든 것
오토인코더의 모든 것NAVER Engineering
 
LLaMA-Adapter: Efficient Fine-tuning of Language Models with Zero-init Attent...
LLaMA-Adapter: Efficient Fine-tuning of Language Models with Zero-init Attent...LLaMA-Adapter: Efficient Fine-tuning of Language Models with Zero-init Attent...
LLaMA-Adapter: Efficient Fine-tuning of Language Models with Zero-init Attent...Po-Chuan Chen
 
Gradient descent optimizer
Gradient descent optimizerGradient descent optimizer
Gradient descent optimizerHojin Yang
 
가깝고도 먼 Trpo
가깝고도 먼 Trpo가깝고도 먼 Trpo
가깝고도 먼 TrpoWoong won Lee
 
Control as Inference.pptx
Control as Inference.pptxControl as Inference.pptx
Control as Inference.pptxssuserbd1647
 

Was ist angesagt? (20)

Approximate Inference (Chapter 10, PRML Reading)
Approximate Inference (Chapter 10, PRML Reading)Approximate Inference (Chapter 10, PRML Reading)
Approximate Inference (Chapter 10, PRML Reading)
 
Overview on Optimization algorithms in Deep Learning
Overview on Optimization algorithms in Deep LearningOverview on Optimization algorithms in Deep Learning
Overview on Optimization algorithms in Deep Learning
 
Metropolis-Hastings MCMC Short Tutorial
Metropolis-Hastings MCMC Short TutorialMetropolis-Hastings MCMC Short Tutorial
Metropolis-Hastings MCMC Short Tutorial
 
Wasserstein GAN 수학 이해하기 I
Wasserstein GAN 수학 이해하기 IWasserstein GAN 수학 이해하기 I
Wasserstein GAN 수학 이해하기 I
 
Xgboost
XgboostXgboost
Xgboost
 
Chapter 6 Deep feedforward networks - 1
Chapter 6 Deep feedforward networks - 1Chapter 6 Deep feedforward networks - 1
Chapter 6 Deep feedforward networks - 1
 
PRML輪読#9
PRML輪読#9PRML輪読#9
PRML輪読#9
 
Deep generative model.pdf
Deep generative model.pdfDeep generative model.pdf
Deep generative model.pdf
 
Variational Inference
Variational InferenceVariational Inference
Variational Inference
 
Feature Engineering
Feature EngineeringFeature Engineering
Feature Engineering
 
알기쉬운 Variational autoencoder
알기쉬운 Variational autoencoder알기쉬운 Variational autoencoder
알기쉬운 Variational autoencoder
 
An overview of gradient descent optimization algorithms
An overview of gradient descent optimization algorithms An overview of gradient descent optimization algorithms
An overview of gradient descent optimization algorithms
 
PRML Chapter 11
PRML Chapter 11PRML Chapter 11
PRML Chapter 11
 
Meta-learning and the ELBO
Meta-learning and the ELBOMeta-learning and the ELBO
Meta-learning and the ELBO
 
오토인코더의 모든 것
오토인코더의 모든 것오토인코더의 모든 것
오토인코더의 모든 것
 
Stochastic Optimization
Stochastic OptimizationStochastic Optimization
Stochastic Optimization
 
LLaMA-Adapter: Efficient Fine-tuning of Language Models with Zero-init Attent...
LLaMA-Adapter: Efficient Fine-tuning of Language Models with Zero-init Attent...LLaMA-Adapter: Efficient Fine-tuning of Language Models with Zero-init Attent...
LLaMA-Adapter: Efficient Fine-tuning of Language Models with Zero-init Attent...
 
Gradient descent optimizer
Gradient descent optimizerGradient descent optimizer
Gradient descent optimizer
 
가깝고도 먼 Trpo
가깝고도 먼 Trpo가깝고도 먼 Trpo
가깝고도 먼 Trpo
 
Control as Inference.pptx
Control as Inference.pptxControl as Inference.pptx
Control as Inference.pptx
 

Ähnlich wie Chapter 19 Variational Inference

Deep Learning from scratch 5장 : backpropagation
 Deep Learning from scratch 5장 : backpropagation Deep Learning from scratch 5장 : backpropagation
Deep Learning from scratch 5장 : backpropagationJinSooKim80
 
Variational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial ModelVariational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial ModelSEMINARGROOT
 
Auto-Encoders and Variational Auto-Encoders
Auto-Encoders and Variational Auto-EncodersAuto-Encoders and Variational Auto-Encoders
Auto-Encoders and Variational Auto-EncodersJinho Lee
 
Neural network (perceptron)
Neural network (perceptron)Neural network (perceptron)
Neural network (perceptron)Jeonghun Yoon
 
Gaussian Mixture Model
Gaussian Mixture ModelGaussian Mixture Model
Gaussian Mixture ModelKyeongUkJang
 
Eigendecomposition and pca
Eigendecomposition and pcaEigendecomposition and pca
Eigendecomposition and pcaJinhwan Suk
 
Deep Learning from scratch 4장 : neural network learning
Deep Learning from scratch 4장 : neural network learningDeep Learning from scratch 4장 : neural network learning
Deep Learning from scratch 4장 : neural network learningJinSooKim80
 
04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )Jeonghun Yoon
 
03. linear regression
03. linear regression03. linear regression
03. linear regressionJeonghun Yoon
 
[Probability for machine learning]
[Probability for machine learning][Probability for machine learning]
[Probability for machine learning]강민국 강민국
 
Crash Course on Graphical models
Crash Course on Graphical modelsCrash Course on Graphical models
Crash Course on Graphical modelsJong Wook Kim
 
Multinomial classification and application of ML
Multinomial classification and application of MLMultinomial classification and application of ML
Multinomial classification and application of ML희수 박
 
개념 이해가 쉬운 Variational Autoencoder (VAE)
개념 이해가 쉬운 Variational Autoencoder (VAE)개념 이해가 쉬운 Variational Autoencoder (VAE)
개념 이해가 쉬운 Variational Autoencoder (VAE)jaypi Ko
 
8. Logistic Regression
8. Logistic Regression8. Logistic Regression
8. Logistic RegressionJungkyu Lee
 
Coursera Machine Learning (by Andrew Ng)_강의정리
Coursera Machine Learning (by Andrew Ng)_강의정리Coursera Machine Learning (by Andrew Ng)_강의정리
Coursera Machine Learning (by Andrew Ng)_강의정리SANG WON PARK
 
Probability with MLE, MAP
Probability with MLE, MAPProbability with MLE, MAP
Probability with MLE, MAPJunho Lee
 
0228 2 sample_distribution
0228 2 sample_distribution0228 2 sample_distribution
0228 2 sample_distributionJeonghun Yoon
 
3 sat with randomization
3 sat with randomization3 sat with randomization
3 sat with randomizationChangki Yun
 

Ähnlich wie Chapter 19 Variational Inference (20)

Deep Learning from scratch 5장 : backpropagation
 Deep Learning from scratch 5장 : backpropagation Deep Learning from scratch 5장 : backpropagation
Deep Learning from scratch 5장 : backpropagation
 
Variational AutoEncoder(VAE)
Variational AutoEncoder(VAE)Variational AutoEncoder(VAE)
Variational AutoEncoder(VAE)
 
Variational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial ModelVariational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial Model
 
Auto-Encoders and Variational Auto-Encoders
Auto-Encoders and Variational Auto-EncodersAuto-Encoders and Variational Auto-Encoders
Auto-Encoders and Variational Auto-Encoders
 
Neural network (perceptron)
Neural network (perceptron)Neural network (perceptron)
Neural network (perceptron)
 
Gaussian Mixture Model
Gaussian Mixture ModelGaussian Mixture Model
Gaussian Mixture Model
 
Eigendecomposition and pca
Eigendecomposition and pcaEigendecomposition and pca
Eigendecomposition and pca
 
Deep Learning from scratch 4장 : neural network learning
Deep Learning from scratch 4장 : neural network learningDeep Learning from scratch 4장 : neural network learning
Deep Learning from scratch 4장 : neural network learning
 
04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )
 
03. linear regression
03. linear regression03. linear regression
03. linear regression
 
[Probability for machine learning]
[Probability for machine learning][Probability for machine learning]
[Probability for machine learning]
 
Crash Course on Graphical models
Crash Course on Graphical modelsCrash Course on Graphical models
Crash Course on Graphical models
 
Multinomial classification and application of ML
Multinomial classification and application of MLMultinomial classification and application of ML
Multinomial classification and application of ML
 
개념 이해가 쉬운 Variational Autoencoder (VAE)
개념 이해가 쉬운 Variational Autoencoder (VAE)개념 이해가 쉬운 Variational Autoencoder (VAE)
개념 이해가 쉬운 Variational Autoencoder (VAE)
 
8. Logistic Regression
8. Logistic Regression8. Logistic Regression
8. Logistic Regression
 
Coursera Machine Learning (by Andrew Ng)_강의정리
Coursera Machine Learning (by Andrew Ng)_강의정리Coursera Machine Learning (by Andrew Ng)_강의정리
Coursera Machine Learning (by Andrew Ng)_강의정리
 
07. PCA
07. PCA07. PCA
07. PCA
 
Probability with MLE, MAP
Probability with MLE, MAPProbability with MLE, MAP
Probability with MLE, MAP
 
0228 2 sample_distribution
0228 2 sample_distribution0228 2 sample_distribution
0228 2 sample_distribution
 
3 sat with randomization
3 sat with randomization3 sat with randomization
3 sat with randomization
 

Mehr von KyeongUkJang

Photo wake up - 3d character animation from a single photo
Photo wake up - 3d character animation from a single photoPhoto wake up - 3d character animation from a single photo
Photo wake up - 3d character animation from a single photoKyeongUkJang
 
GAN - Generative Adversarial Nets
GAN - Generative Adversarial NetsGAN - Generative Adversarial Nets
GAN - Generative Adversarial NetsKyeongUkJang
 
Distilling the knowledge in a neural network
Distilling the knowledge in a neural networkDistilling the knowledge in a neural network
Distilling the knowledge in a neural networkKyeongUkJang
 
Latent Dirichlet Allocation
Latent Dirichlet AllocationLatent Dirichlet Allocation
Latent Dirichlet AllocationKyeongUkJang
 
CNN for sentence classification
CNN for sentence classificationCNN for sentence classification
CNN for sentence classificationKyeongUkJang
 
Visualizing data using t-SNE
Visualizing data using t-SNEVisualizing data using t-SNE
Visualizing data using t-SNEKyeongUkJang
 
Playing atari with deep reinforcement learning
Playing atari with deep reinforcement learningPlaying atari with deep reinforcement learning
Playing atari with deep reinforcement learningKyeongUkJang
 
Chapter 20 Deep generative models
Chapter 20 Deep generative modelsChapter 20 Deep generative models
Chapter 20 Deep generative modelsKyeongUkJang
 
Natural Language Processing(NLP) - basic 2
Natural Language Processing(NLP) - basic 2Natural Language Processing(NLP) - basic 2
Natural Language Processing(NLP) - basic 2KyeongUkJang
 
Natural Language Processing(NLP) - Basic
Natural Language Processing(NLP) - BasicNatural Language Processing(NLP) - Basic
Natural Language Processing(NLP) - BasicKyeongUkJang
 
Chapter 17 monte carlo methods
Chapter 17 monte carlo methodsChapter 17 monte carlo methods
Chapter 17 monte carlo methodsKyeongUkJang
 
Chapter 16 structured probabilistic models for deep learning - 2
Chapter 16 structured probabilistic models for deep learning - 2Chapter 16 structured probabilistic models for deep learning - 2
Chapter 16 structured probabilistic models for deep learning - 2KyeongUkJang
 
Chapter 16 structured probabilistic models for deep learning - 1
Chapter 16 structured probabilistic models for deep learning - 1Chapter 16 structured probabilistic models for deep learning - 1
Chapter 16 structured probabilistic models for deep learning - 1KyeongUkJang
 
Chapter 15 Representation learning - 2
Chapter 15 Representation learning - 2Chapter 15 Representation learning - 2
Chapter 15 Representation learning - 2KyeongUkJang
 
Chapter 15 Representation learning - 1
Chapter 15 Representation learning - 1Chapter 15 Representation learning - 1
Chapter 15 Representation learning - 1KyeongUkJang
 

Mehr von KyeongUkJang (20)

Photo wake up - 3d character animation from a single photo
Photo wake up - 3d character animation from a single photoPhoto wake up - 3d character animation from a single photo
Photo wake up - 3d character animation from a single photo
 
YOLO
YOLOYOLO
YOLO
 
AlphagoZero
AlphagoZeroAlphagoZero
AlphagoZero
 
GoogLenet
GoogLenetGoogLenet
GoogLenet
 
GAN - Generative Adversarial Nets
GAN - Generative Adversarial NetsGAN - Generative Adversarial Nets
GAN - Generative Adversarial Nets
 
Distilling the knowledge in a neural network
Distilling the knowledge in a neural networkDistilling the knowledge in a neural network
Distilling the knowledge in a neural network
 
Latent Dirichlet Allocation
Latent Dirichlet AllocationLatent Dirichlet Allocation
Latent Dirichlet Allocation
 
CNN for sentence classification
CNN for sentence classificationCNN for sentence classification
CNN for sentence classification
 
Visualizing data using t-SNE
Visualizing data using t-SNEVisualizing data using t-SNE
Visualizing data using t-SNE
 
Playing atari with deep reinforcement learning
Playing atari with deep reinforcement learningPlaying atari with deep reinforcement learning
Playing atari with deep reinforcement learning
 
Chapter 20 - GAN
Chapter 20 - GANChapter 20 - GAN
Chapter 20 - GAN
 
Chapter 20 - VAE
Chapter 20 - VAEChapter 20 - VAE
Chapter 20 - VAE
 
Chapter 20 Deep generative models
Chapter 20 Deep generative modelsChapter 20 Deep generative models
Chapter 20 Deep generative models
 
Natural Language Processing(NLP) - basic 2
Natural Language Processing(NLP) - basic 2Natural Language Processing(NLP) - basic 2
Natural Language Processing(NLP) - basic 2
 
Natural Language Processing(NLP) - Basic
Natural Language Processing(NLP) - BasicNatural Language Processing(NLP) - Basic
Natural Language Processing(NLP) - Basic
 
Chapter 17 monte carlo methods
Chapter 17 monte carlo methodsChapter 17 monte carlo methods
Chapter 17 monte carlo methods
 
Chapter 16 structured probabilistic models for deep learning - 2
Chapter 16 structured probabilistic models for deep learning - 2Chapter 16 structured probabilistic models for deep learning - 2
Chapter 16 structured probabilistic models for deep learning - 2
 
Chapter 16 structured probabilistic models for deep learning - 1
Chapter 16 structured probabilistic models for deep learning - 1Chapter 16 structured probabilistic models for deep learning - 1
Chapter 16 structured probabilistic models for deep learning - 1
 
Chapter 15 Representation learning - 2
Chapter 15 Representation learning - 2Chapter 15 Representation learning - 2
Chapter 15 Representation learning - 2
 
Chapter 15 Representation learning - 1
Chapter 15 Representation learning - 1Chapter 15 Representation learning - 1
Chapter 15 Representation learning - 1
 

Kürzlich hochgeladen

Grid Layout (Kitworks Team Study 장현정 발표자료)
Grid Layout (Kitworks Team Study 장현정 발표자료)Grid Layout (Kitworks Team Study 장현정 발표자료)
Grid Layout (Kitworks Team Study 장현정 발표자료)Wonjun Hwang
 
오픈소스 위험 관리 및 공급망 보안 솔루션 'Checkmarx SCA' 소개자료
오픈소스 위험 관리 및 공급망 보안 솔루션 'Checkmarx SCA' 소개자료오픈소스 위험 관리 및 공급망 보안 솔루션 'Checkmarx SCA' 소개자료
오픈소스 위험 관리 및 공급망 보안 솔루션 'Checkmarx SCA' 소개자료Softwide Security
 
도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'
도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'
도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'Hyundai Motor Group
 
[OpenLAB] AWS reInvent를 통해 바라본 글로벌 Cloud 기술동향.pdf
[OpenLAB] AWS reInvent를 통해 바라본 글로벌 Cloud 기술동향.pdf[OpenLAB] AWS reInvent를 통해 바라본 글로벌 Cloud 기술동향.pdf
[OpenLAB] AWS reInvent를 통해 바라본 글로벌 Cloud 기술동향.pdfssuserf8b8bd1
 
파일 업로드(Kitworks Team Study 유현주 발표자료 240510)
파일 업로드(Kitworks Team Study 유현주 발표자료 240510)파일 업로드(Kitworks Team Study 유현주 발표자료 240510)
파일 업로드(Kitworks Team Study 유현주 발표자료 240510)Wonjun Hwang
 
클라우드 애플리케이션 보안 플랫폼 'Checkmarx One' 소개자료
클라우드 애플리케이션 보안 플랫폼 'Checkmarx One' 소개자료클라우드 애플리케이션 보안 플랫폼 'Checkmarx One' 소개자료
클라우드 애플리케이션 보안 플랫폼 'Checkmarx One' 소개자료Softwide Security
 

Kürzlich hochgeladen (6)

Grid Layout (Kitworks Team Study 장현정 발표자료)
Grid Layout (Kitworks Team Study 장현정 발표자료)Grid Layout (Kitworks Team Study 장현정 발표자료)
Grid Layout (Kitworks Team Study 장현정 발표자료)
 
오픈소스 위험 관리 및 공급망 보안 솔루션 'Checkmarx SCA' 소개자료
오픈소스 위험 관리 및 공급망 보안 솔루션 'Checkmarx SCA' 소개자료오픈소스 위험 관리 및 공급망 보안 솔루션 'Checkmarx SCA' 소개자료
오픈소스 위험 관리 및 공급망 보안 솔루션 'Checkmarx SCA' 소개자료
 
도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'
도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'
도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'
 
[OpenLAB] AWS reInvent를 통해 바라본 글로벌 Cloud 기술동향.pdf
[OpenLAB] AWS reInvent를 통해 바라본 글로벌 Cloud 기술동향.pdf[OpenLAB] AWS reInvent를 통해 바라본 글로벌 Cloud 기술동향.pdf
[OpenLAB] AWS reInvent를 통해 바라본 글로벌 Cloud 기술동향.pdf
 
파일 업로드(Kitworks Team Study 유현주 발표자료 240510)
파일 업로드(Kitworks Team Study 유현주 발표자료 240510)파일 업로드(Kitworks Team Study 유현주 발표자료 240510)
파일 업로드(Kitworks Team Study 유현주 발표자료 240510)
 
클라우드 애플리케이션 보안 플랫폼 'Checkmarx One' 소개자료
클라우드 애플리케이션 보안 플랫폼 'Checkmarx One' 소개자료클라우드 애플리케이션 보안 플랫폼 'Checkmarx One' 소개자료
클라우드 애플리케이션 보안 플랫폼 'Checkmarx One' 소개자료
 

Chapter 19 Variational Inference

  • 2. Variational Autoencoder 2 잠재변수 𝑧 데이터 𝑥 우도함수 𝑝(𝑥|𝑧) 𝑧의 사전확률 𝑝(𝑧) 𝑥의 사전확률 𝑝 𝑥 𝑧가 주어진 상황에서 𝑥가 나타날 확률 𝑝 𝑥 𝑧 : 우도 𝑥가 주어진 상황에서 𝑧가 나타날 확률 𝑝 𝑧 𝑥 : 사후확률 사후확률 𝑝(𝑧|𝑥)를 알기 어렵기 때문에 근사하는 간단한 함수를 찾음 𝑞(𝑧) 또는 𝑞(𝑧|𝑥)
  • 3. Variational inference 흰색: 잠재변수(z) 회색: 관측변수(x) - 주어진 데이터(𝑥)와 주어지지 않은 잠재변수(𝑧)가 모델에 관여하는 상황. - 어떤 잠재변수로부터 주어진 데이터를 만들어낼 확률𝑝(𝑥|𝑧)이 가장 높은 모델과, 그때 최적의 잠재변수를 만드는 함수 𝑝(𝑧|𝑥)를 찾아야한다고 생각해보자. - 이 때, 사후확률 분포 𝑝(𝑧|𝑥) 를 계산하는 것이 불가능에 가까울 정도로 어려운 경우가 많다. 잠재변수간 상호작용 때문에 marginal probability 계산이 힘들다. Marginal probability: 𝑝(𝑥) = σ 𝑧 𝑝(𝑥, 𝑧) 3
  • 4. Variational inference VI란 사후확률(posterior) 분포 𝑝(𝑧|𝑥)를 다루기 쉬운 확률분포 𝑞(𝑧)로 근사(approximation)하는 것 사후확률 분포를 우리가 익히 알고 있는 정규분포로 근사한 경우 4
  • 5. Variational inference 사후확률 𝑝(𝑧|𝑥)에 근사한 𝑞(𝑧)를 만들기 위해 두 분포의 차이를 줄여야 함. → 두 확률분포의 차이를 계산하는 KL-Divergence 개념 활용 사후확률 분포 𝑝(𝑧|𝑥)와 𝑞(𝑧) 사이의 KLD를 계산하고, KLD가 줄어드는 쪽으로 𝑞(𝑧)를 조금 씩 업데이트하는 과정을 반복하면 사후확률을 잘 근사하는 𝑞∗ (𝑧)를 얻게 될 것 → 이 과정이 Variational Inference KLD를 줄어들게 하는데 몇가지 방법이 있음. 5
  • 6. Variational inference 이 KLD를 줄어들게 하는데 몇가지 방법이 있음. 우리가 최소화하고자 하는 KLD를 정리해보면, 6
  • 7. 1. Variational Inference with Monte Carlo Sampling 몬테카를로 방법(Monte Carlo Method): 랜덤 표본을 뽑아 함수의 값을 확률적으로 계산하는 방법. 이를 이용하여 KLD 텀에 대한 근사식을 유도 7
  • 8. 1. Variational Inference with Monte Carlo Sampling 실제 문제에서는 사후확률 분포𝑝(𝑧|𝑥)에 대해 아무런 정보가 없지만 몬테카를로 방법을 이용하면 𝑞(𝑧)를 어떤 분포로든 설정할 수 있다. Ex) 사후분포에 대한 정보가 없어서 𝑞(𝑧)를 정규분포로 정해 볼 경우 1. 이 정규분포에서 K개의 z들을 뽑으면 KLD의 근사값을 계산 가능. 2. 정규분포의 파라메터(평균, 분산)를 조금씩 바꿔가면서 KLD 근사값을 최소로 하는 파라메터를 구할 수 있을 것. 3. 구해진 정규분포가 바로 VI의 결과. ≈ 8
  • 9. 2. Variational Inference with SGD KLD를 줄이는 방향으로 𝑞(𝑧)의 파라메터를 업데이트 하여 VI하는 것도 가능 → Gradient를 계산하기 위해 KLD가 미분가능 해야함 Ex) 𝑞 𝑧 는 정규분포 𝜃 𝑞 = 𝜇 𝑞, 𝜎 𝑞 , 𝑝 𝑧 는 베타분포 𝛼, 𝛽 라고 두고 𝐾𝐿𝐷 식을 𝜃 𝑞에 대해 미분해 보자. (적절한 𝜃 𝑞를 추론하려 하는것) 이때, z가 𝜃 𝑞를 파라메터로 갖는 𝑞에 의해 랜덤 샘플링되기 때문에 𝜃 𝑞 에 대한 미분이 불가능 → z대신 노이즈를 샘플링해서 z를 계산하는 reparameterization trick 사용 9
  • 10. 2. Variational Inference with SGD 여기서도 몬테카를로 샘플링을 이용하여 KLD의 gradient 근사값을 계산. → Gradient 이용하여 𝜃 𝑞를 수정함으로써 사후확률 분포 𝑝(𝑧|𝑥)에 근사하는 𝑞(𝑧)를 찾을 수 있다. 10
  • 11. Vatiational EM algorithm - 지금까지는 사전확률함수 𝑝 𝑧 와 우도함수 𝑝 𝑥 𝑧 를 이미 알고 있다는 전제 하에 𝑝 𝑧 𝑥 에근사하는 𝑞 𝑧 를 찾는 𝑉𝐼 과정을 설명하였음. - 하지만 실제 문제에서는 사전호가률과 우도함수의 파라메터 또한 알고 있지 못하는 경우가 많다. 우도함수를 모르는 상황에서 VI를 하기 위해선? 1. 사전확률 𝑝 𝑧 는 상수로 고정하여도 됨 2. 사후확률 𝑝(𝑧|𝑥)에 근사한 𝑞(𝑧)의 파라메터를 찾는 것과 동시에, 우도함수 𝑝(𝑥|𝑧)의 파라메터 또 한 추정해야 함 3. But, 이 둘을 동시에 찾는 것은 불가능. → 한 파라메터를 고정하고 나머지 파라메터를 최적화하는 것을 반복하는 EM algorithm 사용 11
  • 12. Vatiational EM algorithm 𝑞(𝑧)의 파라메터를 𝜃 𝑞, 우도함수𝑝(𝑥|𝑧)의 파라메터를 𝜃𝑙라고 둘 때 EM algorithm은 다음과 같은 과정을 수렴할 때까지 반복함 E-step에서는 KLD를 줄이기 위해 q만을 업데이트하므로 이 과정에서 𝑝(𝑥) 는 변하지 않음. KLD를 줄이기 위해선 M-step을 통해 𝑝(𝑥)또한 줄여야 한다. log 𝑝(𝑥)에 대해 정리하면, - Expectation: 우도함수 𝑝 𝑥 𝑧 의 파라메터 𝜃𝑙을 고정한 상태에서 𝐷 𝐾𝐿(𝑞(𝑧)||𝑝 𝑧 𝑥 )를 줄이는 q의파라메터 𝜃 𝑞를 찾는다.(앞에 소개한 방법 이용) - Maximization: E-step에서 찾은 𝜃 𝑞를 고정한 상태에서 evidence 𝑝 𝑥 를 최대화하 는 우도함수 𝑝(𝑥|𝑧)의 파라메터 𝜃𝑙를 찾는다. 12
  • 13. Vatiational EM algorithm 이 때, KLD는 항상 양수이므로 우변이 Evidence인 𝑝(𝑥)의 하한을 나타내므로 Evidence Lower Bound(ELBO)라고 부름 양수 M-step 설명중임 13
  • 14. Vatiational EM algorithm ELBO 두 분포의 차이 (줄이고자 하는것) ELBO를 최대화 시킨다면? → 등호를 만족시키기 위해서 KLD가 최소화 될 것. 𝜃 𝑞가 고정된 상태에서 우도함수𝑝(𝑥|𝑧)의 파라메터 𝜃𝑙 를 KLD가 최소화되는 방향으로 업데이트 하는 것임 이 또한 reparameterization trick을 이용한 SGD를 사용하면 된다.(참고: http://edwardlib.org/tutorials/klqp) Prior, 상수취급 M-step 설명중임 14