SlideShare a Scribd company logo
1 of 30
Download to read offline
In this chapter, we will discuss about
• What is Autoencoder
- neural networks whose dimension of input and output are same
- if the autoencoder use only linear activations and the cost
function is MES, then it is same to PCA
- the architecture of a stacked autoencoder is typically symmetrical
Contents
• Autoencoders
• Denoising Autoencoders
• Variational Autoencoders
Auto-Encoders
Introduction
• Autoencoder 는 encoder 와 decoder 로 나뉜다.
오른쪽 diagram 에서 𝑓 가 encoder 이고,
𝑔 가 decoder 이다.
• cost function 은 reconstruction error 를 사용한다:
𝐿(𝑥, 𝑔 𝑓 𝑥 = 𝑥 − 𝑔 𝑓 𝑥 2
• hidden layer 가 2개 이상인 AE를 stacked Autoencoder 라고 한다.
• e.g. linear activation 만 사용하고, cost function 으로 MSE 를 사용
한 Autoencoder 는 PCA 이다.
𝑥
ℎ
𝑟
𝑓 𝑔
Introduction
• 보통 hidden layer 개수는 홀수이며 AE의 정의에 의해
center layer(=coding layer)를 기준으로 양쪽의 unit 개수가 같다.
Coding layer
Encoder Decoder
Introduction
∙ 아래의 그림처럼 symmetric 하지 않는 Autoencoder 도 있다.
∙ 보통은 encoder 부분의 마지막 layer 의 unit 의 개수는 input layer의
dimension 보다 작다. 이런 Autoencoder 를 undercomplete 라고 하고
반대의 경우를 overcomplete 라고 한다.
* overcomplete 이면 inclusion + projection 으로 loss 를 0 으로 만들 수 있음
Cost function
• [VLBM, p.2] An autoencoder takes an input vector 𝑥 ∈ 0,1 𝑑
, and first
maps it to a hidden representation y ∈ 0,1 𝑑′
through a deterministic
mapping 𝑦 = 𝑓𝜃 𝑥 = 𝑠(𝑊𝑥 + 𝑏), parameterized by 𝜃 = {𝑊, 𝑏}.
𝑊 is a 𝑑 × 𝑑′
weight matrix and 𝒃 is a bias vector. The resulting latent
representation 𝑦 is then mapped back to a “reconstructed” vector
z ∈ 0,1 𝑑 in input space 𝑧 = 𝑔 𝜃′ 𝑦 = 𝑠 𝑊′ 𝑦 + 𝑏′ with 𝜃′ = {𝑊′, 𝑏′}.
The weight matrix 𝑊′ of the reverse mapping may optionally be
constrained by 𝑊′ = 𝑊 𝑇, in which case the autoencoder is said to
have tied weights.
• The parameters of this model are optimized to minimize
the average reconstruction error:
𝜃∗
, 𝜃′∗
= arg min
𝜃,𝜃′
1
𝑛
𝑖=1
𝑛
𝐿(𝑥 𝑖
, 𝑧 𝑖
)
= arg min
𝜃,𝜃′
1
𝑛 𝑖=1
𝑛
𝐿(𝑥 𝑖
, 𝑔 𝜃′(𝑓𝜃 𝑥 𝑖
) (1)
where 𝐿 𝑥 − 𝑧 = 𝑥 − 𝑧 2.
Cost function
• [VLBM,p.2] An alternative loss, suggested by the interpretation of 𝑥
and 𝑧 as either bit vectors or vectors of bit probabilities (Bernoullis) is
the reconstruction cross-entropy:
𝐿 𝐻 𝑥, 𝑧 = 𝐻(𝐵𝑥||𝐵𝑧)
= − 𝑘=1
𝑑
[𝑥 𝑘 log 𝑧 𝑘 + log 1 − 𝑥 𝑘 log(1 − 𝑧 𝑘)]
where 𝐵𝜇 𝑥 = (𝐵𝜇1
𝑥 , ⋯ , 𝐵𝜇 𝑑
𝑥 ) is a Bernoulli distribution.
• [VLBM,p.2] Equation (1) with 𝐿 = 𝐿 𝐻 can be written
𝜃∗, 𝜃′∗ = arg min
𝜃,𝜃′
𝐸 𝑞0 [𝐿 𝐻(𝑋, 𝑔 𝜃′(𝑓𝜃 𝑋 ))]
where 𝑞0(𝑋) denotes the empirical distribution associated to our 𝑛
training inputs.
Denoising Auto-Encoders
Denoising Autoencoders
• [VLBM,p.3] corrupted input 를 넣어 repaired input 을 찾는 training
을 한다. 좀 더 정확하게 말하면 input data의 dimension 이 𝑑 라고
할 때 ‘desired proportion 𝜈 of destruction’ 을 정하여 𝜈𝑑 만큼의
input 을 0 으로 수정하는 방식으로 destruction 한다. 여기서 𝜈𝑑 개
components 는 random 으로 정한다. 이후 reconstruction error 를
체크하여 destruction 전의 input 으로 복구하는 cost function
이용하여 학습을 하는 Autoencoder 가 Denoising Autoencoder 이다.
여기서 𝑥 에서 destroyed version 인 𝑥 를 얻는 과정은 stochastic
mapping 𝑥 ~ 𝑞 𝐷( 𝑥|x) 를 따른다.
Denoising Autoencoders
• [VLBM,p.3] Let us define the joint distribution
𝑞0
𝑋, 𝑋, 𝑌 = 𝑞0
𝑋 𝑞 𝐷 𝑋 𝑋 𝛿𝑓 𝜃 𝑋
(𝑌))
where 𝛿 𝑢(𝑣) is the Kronecker delta. Thus 𝑌 is a deterministic
function of 𝑋. 𝑞0(𝑋, 𝑋, 𝑌) is parameterized by 𝜃. The objective
function minimized by stochastic gradient descent becomes:
𝑎𝑟𝑔 𝑚𝑖𝑛
𝜃,𝜃′
𝐸 𝑞0 𝑥, 𝑥 [𝐿 𝐻(𝑥, 𝑔 𝜃′(𝑓𝜃( 𝑥))])
Corrupted 𝑥 를 입력하고 𝑥 를 찾는 방법으로 학습!
Other Autoencoders
• [DL book, 14.2.1] A sparse autoencoder is simply an autoencoder
whose training criterion involves a sparsity penalty Ω ℎ on the
code layer h, in addition to the reconstruction error:
𝐿(𝑥, 𝑔 𝑓 𝑥 ) + Ω(ℎ),
where 𝑔 ℎ is the decoder output and typically we have ℎ = 𝑓(𝑥),
the encoder output.
• [DL book, 14.2.3] Another strategy for regularizing an autoencoder
is to use a penalty Ω as in sparse autoencoders,
𝐿 𝑥, 𝑔 𝑓 𝑥 ) + Ω(ℎ, 𝑥 ,
but with a different form of Ω:
Ω ℎ, 𝑥 = 𝜆
𝑖
𝛻𝑥ℎ𝑖
2
Variational Auto-Encoders
Reference
• Reference. Auto-Encoding Variational Bayes, Diederik P Kingma,
Max Welling, 2013
• [논문의 가정] We will restrict ourselves here to the common case
where we have an i.i.d. dataset with latent variables per datapoint,
and where we like to perform maximum likelihood (ML) or
maximum a posteriori (MAP) inference on the (global) parameters,
and variational inference on the latent variables.
Definition
• Generative Model 의 목표
- 𝑋 = {𝑥𝑖} 를 생성하는 집합 𝑍 = {𝑧𝑗} 와 함수 𝜃 를
찾는 것이 목표이다.
i.e. Finding arg min
𝑍,𝜃
𝑑(𝑥, 𝜃(𝑧)) where 𝑑 is a metric
• VAE 도 generative model 이므로 집합 𝑍 와
함수 𝜃 가 유기적으로 동작하여 좋은 모델을
만들게 되는데 VAE는 Latent variable 𝑧 가
parametrized distribution(by 𝜙) 에서 나온다
고 가정하고 𝑥 를 잘 생성하는 parameter 𝜃
를 학습하게 된다.
Figure 1
z
𝑥
𝜃
Problem scenario
• Dataset 𝑋 = 𝑥 𝑖
𝑖=1
𝑁
는 i.i.d 인 continuous(또는 discrete) variable 𝑥
의 sample 이다. 𝑋 는 unobserved continuous variable 𝑧 의 some
random process 로 생성되었다고 가정하자. 여기서 random process
는 두 개의 step 으로 구성되어있다:
(1) 𝑧(𝑖)
is generated from some prior distribution 𝑝 𝜃∗(𝑧)
(2) 𝑥(𝑖)
is generated from some conditional distribution 𝑝 𝜃∗(𝑥|𝑧)
• Prior 𝑝 𝜃∗ 𝑧 와 likelihood 𝑝 𝜃∗(𝑥|𝑧) 는 differentiable almost
everywhere w.r.t 𝜃 and 𝑧 인 parametric families of distributions
𝑝 𝜃(𝑧)와 𝑝 𝜃(𝑥|𝑧) 들의 에서 온 것으로 가정하자.
• 아쉽게도 true parameter 𝜃∗
와 latent variables 𝑧(𝑖)
의 값을 알 수
없어서 cost function 을 정하고 그것의 lower bound 를 구하는
방향으로 전개될 예정이다.
Intractibility and Variational Inference
• 𝑝 𝜃 𝑥 = 𝑝 𝜃 𝑥 𝑝 𝜃 𝑥 𝑧 𝑑𝑧 is intractable(계산 불가능)
∵ 𝑝 𝜃 𝑧 𝑥 = 𝑝 𝜃 𝑥 𝑧 𝑝 𝜃(𝑧)/𝑝 𝜃(𝑥) is intractable
• 𝑝 𝜃 𝑧 𝑥 를 알 수 없으니 우리가 아는 함수라고 가정하자.
이런 방법을 variational inference 라고 한다. 즉, 잘 아는 함수
𝑞 𝜙(𝑧|𝑥) 를 𝑝 𝜃 𝑧 𝑥 대신 사용하는 방법을 variational inference
라고 한다.
• Idea : prior 𝑝 𝜃 𝑧 𝑥 를 𝑞 𝜙(𝑧|𝑥) 로 사용해도 되는 이유는 주어진
input 𝑧 가 𝑥 에 근사하게 학습이 된다.
Then variational bound
• 우리는 𝑋 = 𝑥 𝑖
𝑖=1
𝑁
가 i.i.d 를 만족한다고 가정했으므로
log 𝑝 𝜃(𝑥 1
, ⋯ , 𝑥(𝑁)
) = 𝑖=1
𝑁
log 𝑝 𝜃(𝑥 𝑖
) 이다.
• 각각의 𝑥 ∈ 𝑋에 대해 아래 식을 얻을 수 있다:
log 𝑝 𝜃 𝑥 = 𝑧
𝑞 𝜙 𝑧 𝑥 log 𝑝 𝜃(𝑥) 𝑑𝑧
= 𝑧
𝑞 𝜙 𝑧 𝑥 log
𝑝 𝜃 𝑧,𝑥
𝑝 𝜃(𝑧|𝑥)
𝑑𝑧
= 𝑧
𝑞 𝜙 𝑧 𝑥 log
𝑝 𝜃 𝑧,𝑥
𝑞 𝜙 𝑧 𝑥
𝑞 𝜙 𝑧 𝑥
𝑝 𝜃 𝑧 𝑥
𝑑𝑧
= 𝑧
𝑞 𝜙 𝑧 𝑥 log
𝑝 𝜃 𝑧,𝑥
𝑞 𝜙 𝑧 𝑥
𝑑𝑧 + 𝑧
𝑞 𝜙 𝑧 𝑥
𝑞 𝜙 𝑧 𝑥
𝑝 𝜃 𝑧 𝑥
𝑑𝑧
= 𝓛 𝜃, 𝜙; 𝑥 + 𝐷 𝐾𝐿(𝑞 𝜃(𝑧|𝑥)||𝑝 𝜃 𝑧 𝑥 ) (1)
≥ 𝓛 𝜃, 𝜙; 𝑥
언제나 𝐾𝐿 divergence 는
0 이상이므로
𝑧
𝑞 𝜙 𝑧 𝑥 log
𝑝 𝜃 𝑧,𝑥
𝑞 𝜙 𝑧 𝑥
𝑑𝑧 는
lower bound 가 된다. 이것
을 𝓛 𝜃, 𝜙; 𝑥 라고 놓자.
Cost function
• (Eq.3) 𝓛 𝜃, 𝜙; 𝑥 = −𝐷 𝐾𝐿(𝑞 𝜙(𝑧|𝑥)||𝑝 𝜃 𝑥 ) + 𝐸 𝑞 𝜙 𝑧 𝑥 [log 𝑝 𝜃(𝑥|𝑧)]
<Proof>
𝓛 𝜃, 𝜙; 𝑥 = 𝑧
𝑞 𝜙 𝑧 𝑥 log
𝑝 𝜃(𝑧,𝑥)
𝑞 𝜙(𝑧|𝑥)
𝑑𝑧
= 𝑧
𝑞 𝜙 𝑧 𝑥 log
𝑝 𝜃 𝑧)𝑝 𝜃(𝑥|𝑧
𝑞 𝜙 (𝑧|𝑥)
𝑑𝑧
= 𝑧
𝑞 𝜙 𝑧 𝑥 log
𝑝 𝜃(𝑧)
𝑞 𝜙 (𝑧|𝑥)
𝑑𝑧 + 𝑧
𝑞 𝜙 𝑧 𝑥 log 𝑝 𝜃 𝑥 𝑧 𝑑𝑧
= −𝐷 𝐾𝐿(𝑞 𝜙(𝑧|𝑥)| 𝑝 𝜃(𝑧) + 𝐸 𝑞 𝜙 𝑧 𝑥 [log 𝑝 𝜃(𝑥|𝑧)]
𝑞 𝜙와 𝑝 𝜃가 normal 이면 계산 가능!
Reconstruction error
Cost function
• Lemma. If 𝑝 𝑥 ~𝑁 𝜇1, 𝜎1
2
and 𝑞 𝑥 ~𝑁 𝜇2, 𝜎2
2
, then
𝐾𝐿(𝑝(𝑥)||𝑞 𝑥 ) = ln
𝜎2
𝜎1
+
𝜎1
2
+ 𝜇1 − 𝜇2
2
2𝜎2
2 −
1
2
• Corollary. 𝑞 𝜙 𝑧 𝑥 ~ 𝑁(𝜇𝑖, 𝜎𝑖
2
𝐼) 이고 𝑝 𝑧 ~𝑁 0,1 이면
𝐾𝐿 𝑞 𝜙 𝑧 𝑥𝑖 𝑝 𝑧 =
1
2
(𝑡𝑟 𝜎𝑖
2
𝐼 + 𝜇𝑖 𝑖
𝑇𝜇 − 𝐽 + ln
1
𝑗=𝑖
𝐽
𝜎𝑖,𝑗
2
)
= (Σ𝑗=1
𝐽
𝜎𝑖,𝑗
2
+ Σ𝑗=1
𝐽
𝜇𝑖,𝑗
2
− 𝐽 − Σ𝑗=1
𝐽
ln(𝜎𝑖,𝑗
2
))
=
1
2
Σ𝑗=1
𝐽
(𝜇𝑖,𝑗
2
+ 𝜎𝑖,𝑗
2
− 1 − ln 𝜎𝑖,𝑗
2
)
• 즉, 𝑞 𝜙 𝑧 𝑥 ~ 𝑁(𝜇𝑖, 𝜎𝑖
2
𝐼) 이고 𝑝 𝑧 ~𝑁 0,1 이면 Eq.3 는 아래와 같다.
𝓛 𝜃, 𝜙; 𝑥 =
1
2
Σ𝑗=1
𝐽
𝜇𝑖,𝑗
2
+ 𝜎𝑖,𝑗
2
− 1 − ln 𝜎𝑖,𝑗
2
+ 𝐸 𝑞 𝜙 𝑧 𝑥 [log 𝑝 𝜃(𝑥|𝑧)]
Reconstruction error 학습 방법
• 𝐸 𝑞 𝜙 𝑧 𝑥 [log 𝑝 𝜃(𝑥|𝑧)]는 sampling 을 통해 Monte-carlo estimation 한다.
즉, 𝑥𝑖 ∈ X 마다 𝑧 𝑖,1
, ⋯ , 𝑧 𝑖 𝐿 를 sampling 하여 log likelihood 의 mean으로
근사시킨다. 보통 𝐿 = 1 을 많이 사용한다.
𝐸 𝑞 𝜙 𝑧 𝑥 [log 𝑝 𝜃(𝑥|𝑧)] ∼
1
𝐿
Σ𝑙=1
𝐿
log(𝑝 𝜃 𝑥𝑖 𝑧 𝑖,𝑙 )
• 이렇게 sampling 을 하면 backpropagation 을 할 수 없다. 그래서 사용
되는 방법이 reparametrization trick 이다.
𝑞 𝜙 𝑥 𝑧 𝑝 𝜃 𝑥 𝑧
Reparametrization trick
• Reparametrization trick : sampling 에서 생기는 backpropagation
불가능 문제를 해결하기 위한 방법.
𝑧~𝑁 𝜇, 𝜎2
⇒ 𝑧 = 𝜇 + 𝜎𝜖 where 𝜖~𝑁(0,1)
Log Likelihood
• 앞에서 reconstruction error 를 계산할 때 하나씩 sampling 을 하면
𝐸 𝑞 𝜙 𝑧 𝑥 [log 𝑝 𝜃(𝑥|𝑧)] ∼
1
𝐿
Σ𝑙=1
𝐿
log 𝑝 𝜃 𝑥𝑖 𝑧 𝑖,𝑙
= log(𝑝 𝜃(𝑥𝑖|𝑧 𝑖
)
가 된다. 여기서 𝑝 𝜃 𝑥𝑖 𝑧 𝑖
의 분포가 Bernoulli 인 경우에 아래의 식을
얻을 수 있다.
출처 : https://github.com/hwalsuklee/tensorflow-mnist-VAE
Log Likelihood
• 𝑝 𝜃 𝑥𝑖 𝑧 𝑖 의 분포가 normal 인 경우에 아래의 식을 얻을 수 있다.
출처 : https://github.com/hwalsuklee/tensorflow-mnist-VAE
Structures
출처 : https://github.com/hwalsuklee/tensorflow-mnist-VAE
Structures
출처 : https://github.com/hwalsuklee/tensorflow-mnist-VAE
Examples of VAE
출처 : https://github.com/hwalsuklee/tensorflow-mnist-VAE
Examples of DAE
출처 : https://github.com/hwalsuklee/tensorflow-mnist-VAE
References
• [VLBM] Extracting and composing robust features with denoising
autoencoders, Vincent, Larochelle, Bengio, Manzagol, 2008
• [KW] Auto-Encoding Variational Bayes, Diederik P Kingma, Max
Welling, 2013
• [D] Tutorial on Variational Autoencoders - Carl Doersch, 2016
• PR-010: Auto-Encoding Variational Bayes, ICLR 2014, 차준범
• 오토인코더의 모든 것, 이활석
https://github.com/hwalsuklee/tensorflow-mnist-VAE

More Related Content

What's hot

Focal loss의 응용(Detection & Classification)
Focal loss의 응용(Detection & Classification)Focal loss의 응용(Detection & Classification)
Focal loss의 응용(Detection & Classification)홍배 김
 
딥러닝기본-신경망기초
딥러닝기본-신경망기초딥러닝기본-신경망기초
딥러닝기본-신경망기초jaypi Ko
 
내가 이해하는 SVM(왜, 어떻게를 중심으로)
내가 이해하는 SVM(왜, 어떻게를 중심으로)내가 이해하는 SVM(왜, 어떻게를 중심으로)
내가 이해하는 SVM(왜, 어떻게를 중심으로)SANG WON PARK
 
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
 
Unsupervised anomaly detection with generative model
Unsupervised anomaly detection with generative modelUnsupervised anomaly detection with generative model
Unsupervised anomaly detection with generative modelTaeKang Woo
 
[신경망기초] 멀티레이어퍼셉트론
[신경망기초] 멀티레이어퍼셉트론[신경망기초] 멀티레이어퍼셉트론
[신경망기초] 멀티레이어퍼셉트론jaypi Ko
 
Variational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial ModelVariational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial ModelSEMINARGROOT
 
[신경망기초] 오류역전파알고리즘
[신경망기초] 오류역전파알고리즘[신경망기초] 오류역전파알고리즘
[신경망기초] 오류역전파알고리즘jaypi Ko
 
Chapter 7 Regularization for deep learning - 2
Chapter 7 Regularization for deep learning - 2Chapter 7 Regularization for deep learning - 2
Chapter 7 Regularization for deep learning - 2KyeongUkJang
 
neural network 기초
neural network 기초neural network 기초
neural network 기초Dea-hwan Ki
 
Lecture 3: Unsupervised Learning
Lecture 3: Unsupervised LearningLecture 3: Unsupervised Learning
Lecture 3: Unsupervised LearningSang Jun Lee
 
Lecture 2: Supervised Learning
Lecture 2: Supervised LearningLecture 2: Supervised Learning
Lecture 2: Supervised LearningSang Jun Lee
 
03.12 cnn backpropagation
03.12 cnn backpropagation03.12 cnn backpropagation
03.12 cnn backpropagationDea-hwan Ki
 
코드와 실습으로 이해하는 인공지능
코드와 실습으로 이해하는 인공지능코드와 실습으로 이해하는 인공지능
코드와 실습으로 이해하는 인공지능도형 임
 
Lecture 4: Neural Networks I
Lecture 4: Neural Networks ILecture 4: Neural Networks I
Lecture 4: Neural Networks ISang Jun Lee
 
딥 러닝 자연어 처리 학습을 위한 PPT! (Deep Learning for Natural Language Processing)
딥 러닝 자연어 처리 학습을 위한 PPT! (Deep Learning for Natural Language Processing)딥 러닝 자연어 처리 학습을 위한 PPT! (Deep Learning for Natural Language Processing)
딥 러닝 자연어 처리 학습을 위한 PPT! (Deep Learning for Natural Language Processing)WON JOON YOO
 
[신경망기초] 선형회귀분석
[신경망기초] 선형회귀분석[신경망기초] 선형회귀분석
[신경망기초] 선형회귀분석jaypi Ko
 
Deep Learning from scratch 5장 : backpropagation
 Deep Learning from scratch 5장 : backpropagation Deep Learning from scratch 5장 : backpropagation
Deep Learning from scratch 5장 : backpropagationJinSooKim80
 
차원축소 훑어보기 (PCA, SVD, NMF)
차원축소 훑어보기 (PCA, SVD, NMF)차원축소 훑어보기 (PCA, SVD, NMF)
차원축소 훑어보기 (PCA, SVD, NMF)beom kyun choi
 
Chapter 8 - optimization for training deep models
Chapter 8 - optimization for training deep modelsChapter 8 - optimization for training deep models
Chapter 8 - optimization for training deep modelsKyeongUkJang
 

What's hot (20)

Focal loss의 응용(Detection & Classification)
Focal loss의 응용(Detection & Classification)Focal loss의 응용(Detection & Classification)
Focal loss의 응용(Detection & Classification)
 
딥러닝기본-신경망기초
딥러닝기본-신경망기초딥러닝기본-신경망기초
딥러닝기본-신경망기초
 
내가 이해하는 SVM(왜, 어떻게를 중심으로)
내가 이해하는 SVM(왜, 어떻게를 중심으로)내가 이해하는 SVM(왜, 어떻게를 중심으로)
내가 이해하는 SVM(왜, 어떻게를 중심으로)
 
Coursera Machine Learning (by Andrew Ng)_강의정리
Coursera Machine Learning (by Andrew Ng)_강의정리Coursera Machine Learning (by Andrew Ng)_강의정리
Coursera Machine Learning (by Andrew Ng)_강의정리
 
Unsupervised anomaly detection with generative model
Unsupervised anomaly detection with generative modelUnsupervised anomaly detection with generative model
Unsupervised anomaly detection with generative model
 
[신경망기초] 멀티레이어퍼셉트론
[신경망기초] 멀티레이어퍼셉트론[신경망기초] 멀티레이어퍼셉트론
[신경망기초] 멀티레이어퍼셉트론
 
Variational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial ModelVariational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial Model
 
[신경망기초] 오류역전파알고리즘
[신경망기초] 오류역전파알고리즘[신경망기초] 오류역전파알고리즘
[신경망기초] 오류역전파알고리즘
 
Chapter 7 Regularization for deep learning - 2
Chapter 7 Regularization for deep learning - 2Chapter 7 Regularization for deep learning - 2
Chapter 7 Regularization for deep learning - 2
 
neural network 기초
neural network 기초neural network 기초
neural network 기초
 
Lecture 3: Unsupervised Learning
Lecture 3: Unsupervised LearningLecture 3: Unsupervised Learning
Lecture 3: Unsupervised Learning
 
Lecture 2: Supervised Learning
Lecture 2: Supervised LearningLecture 2: Supervised Learning
Lecture 2: Supervised Learning
 
03.12 cnn backpropagation
03.12 cnn backpropagation03.12 cnn backpropagation
03.12 cnn backpropagation
 
코드와 실습으로 이해하는 인공지능
코드와 실습으로 이해하는 인공지능코드와 실습으로 이해하는 인공지능
코드와 실습으로 이해하는 인공지능
 
Lecture 4: Neural Networks I
Lecture 4: Neural Networks ILecture 4: Neural Networks I
Lecture 4: Neural Networks I
 
딥 러닝 자연어 처리 학습을 위한 PPT! (Deep Learning for Natural Language Processing)
딥 러닝 자연어 처리 학습을 위한 PPT! (Deep Learning for Natural Language Processing)딥 러닝 자연어 처리 학습을 위한 PPT! (Deep Learning for Natural Language Processing)
딥 러닝 자연어 처리 학습을 위한 PPT! (Deep Learning for Natural Language Processing)
 
[신경망기초] 선형회귀분석
[신경망기초] 선형회귀분석[신경망기초] 선형회귀분석
[신경망기초] 선형회귀분석
 
Deep Learning from scratch 5장 : backpropagation
 Deep Learning from scratch 5장 : backpropagation Deep Learning from scratch 5장 : backpropagation
Deep Learning from scratch 5장 : backpropagation
 
차원축소 훑어보기 (PCA, SVD, NMF)
차원축소 훑어보기 (PCA, SVD, NMF)차원축소 훑어보기 (PCA, SVD, NMF)
차원축소 훑어보기 (PCA, SVD, NMF)
 
Chapter 8 - optimization for training deep models
Chapter 8 - optimization for training deep modelsChapter 8 - optimization for training deep models
Chapter 8 - optimization for training deep models
 

Similar to Auto-Encoders and Variational Auto-Encoders

Neural network (perceptron)
Neural network (perceptron)Neural network (perceptron)
Neural network (perceptron)Jeonghun Yoon
 
개념 이해가 쉬운 Variational Autoencoder (VAE)
개념 이해가 쉬운 Variational Autoencoder (VAE)개념 이해가 쉬운 Variational Autoencoder (VAE)
개념 이해가 쉬운 Variational Autoencoder (VAE)jaypi Ko
 
Chapter 19 Variational Inference
Chapter 19 Variational InferenceChapter 19 Variational Inference
Chapter 19 Variational InferenceKyeongUkJang
 
선형대수 08. 선형 변환 (Linear Transformation)
선형대수 08. 선형 변환 (Linear Transformation)선형대수 08. 선형 변환 (Linear Transformation)
선형대수 08. 선형 변환 (Linear Transformation)AHRA CHO
 
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
 
[Probability for machine learning]
[Probability for machine learning][Probability for machine learning]
[Probability for machine learning]강민국 강민국
 
Eigendecomposition and pca
Eigendecomposition and pcaEigendecomposition and pca
Eigendecomposition and pcaJinhwan Suk
 
03. linear regression
03. linear regression03. linear regression
03. linear regressionJeonghun Yoon
 
04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )Jeonghun Yoon
 
선형대수 12강 Gram-Schmidt Orthogonalization
선형대수 12강 Gram-Schmidt Orthogonalization선형대수 12강 Gram-Schmidt Orthogonalization
선형대수 12강 Gram-Schmidt OrthogonalizationAHRA CHO
 
CVPR 2022 Tutorial에 대한 쉽고 상세한 Diffusion Probabilistic Model
CVPR 2022 Tutorial에 대한 쉽고 상세한 Diffusion Probabilistic ModelCVPR 2022 Tutorial에 대한 쉽고 상세한 Diffusion Probabilistic Model
CVPR 2022 Tutorial에 대한 쉽고 상세한 Diffusion Probabilistic Modeljaypi Ko
 
Multinomial classification and application of ML
Multinomial classification and application of MLMultinomial classification and application of ML
Multinomial classification and application of ML희수 박
 
Ray-triangle intersection
Ray-triangle intersectionRay-triangle intersection
Ray-triangle intersection동환 김
 
Rnn개념정리
Rnn개념정리Rnn개념정리
Rnn개념정리종현 최
 
3.neural networks
3.neural networks3.neural networks
3.neural networksHaesun Park
 
0124 1 linear_algebra_basic_vector
0124 1 linear_algebra_basic_vector0124 1 linear_algebra_basic_vector
0124 1 linear_algebra_basic_vectorJeonghun Yoon
 
강화 학습 기초 Reinforcement Learning an introduction
강화 학습 기초 Reinforcement Learning an introduction강화 학습 기초 Reinforcement Learning an introduction
강화 학습 기초 Reinforcement Learning an introductionTaehoon Kim
 

Similar to Auto-Encoders and Variational Auto-Encoders (20)

Neural network (perceptron)
Neural network (perceptron)Neural network (perceptron)
Neural network (perceptron)
 
Vae
VaeVae
Vae
 
개념 이해가 쉬운 Variational Autoencoder (VAE)
개념 이해가 쉬운 Variational Autoencoder (VAE)개념 이해가 쉬운 Variational Autoencoder (VAE)
개념 이해가 쉬운 Variational Autoencoder (VAE)
 
Chapter 19 Variational Inference
Chapter 19 Variational InferenceChapter 19 Variational Inference
Chapter 19 Variational Inference
 
선형대수 08. 선형 변환 (Linear Transformation)
선형대수 08. 선형 변환 (Linear Transformation)선형대수 08. 선형 변환 (Linear Transformation)
선형대수 08. 선형 변환 (Linear Transformation)
 
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
 
[Probability for machine learning]
[Probability for machine learning][Probability for machine learning]
[Probability for machine learning]
 
Eigendecomposition and pca
Eigendecomposition and pcaEigendecomposition and pca
Eigendecomposition and pca
 
03. linear regression
03. linear regression03. linear regression
03. linear regression
 
SVM
SVMSVM
SVM
 
04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )
 
선형대수 12강 Gram-Schmidt Orthogonalization
선형대수 12강 Gram-Schmidt Orthogonalization선형대수 12강 Gram-Schmidt Orthogonalization
선형대수 12강 Gram-Schmidt Orthogonalization
 
CVPR 2022 Tutorial에 대한 쉽고 상세한 Diffusion Probabilistic Model
CVPR 2022 Tutorial에 대한 쉽고 상세한 Diffusion Probabilistic ModelCVPR 2022 Tutorial에 대한 쉽고 상세한 Diffusion Probabilistic Model
CVPR 2022 Tutorial에 대한 쉽고 상세한 Diffusion Probabilistic Model
 
Multinomial classification and application of ML
Multinomial classification and application of MLMultinomial classification and application of ML
Multinomial classification and application of ML
 
Ray-triangle intersection
Ray-triangle intersectionRay-triangle intersection
Ray-triangle intersection
 
Rnn개념정리
Rnn개념정리Rnn개념정리
Rnn개념정리
 
06. graph mining
06. graph mining06. graph mining
06. graph mining
 
3.neural networks
3.neural networks3.neural networks
3.neural networks
 
0124 1 linear_algebra_basic_vector
0124 1 linear_algebra_basic_vector0124 1 linear_algebra_basic_vector
0124 1 linear_algebra_basic_vector
 
강화 학습 기초 Reinforcement Learning an introduction
강화 학습 기초 Reinforcement Learning an introduction강화 학습 기초 Reinforcement Learning an introduction
강화 학습 기초 Reinforcement Learning an introduction
 

More from Jinho Lee

Quantum computing and quantum information 1.2, 1.3
Quantum computing and quantum information 1.2, 1.3Quantum computing and quantum information 1.2, 1.3
Quantum computing and quantum information 1.2, 1.3Jinho Lee
 
Effective active learning strategy for multi label learning
Effective active learning strategy for multi label learningEffective active learning strategy for multi label learning
Effective active learning strategy for multi label learningJinho Lee
 
Wasserstein GAN
Wasserstein GANWasserstein GAN
Wasserstein GANJinho Lee
 
Generative Adversarial Nets
Generative Adversarial NetsGenerative Adversarial Nets
Generative Adversarial NetsJinho Lee
 
Support vector machines
Support vector machinesSupport vector machines
Support vector machinesJinho Lee
 
Wasserstein gan
Wasserstein ganWasserstein gan
Wasserstein ganJinho Lee
 
Ch.5 machine learning basics
Ch.5  machine learning basicsCh.5  machine learning basics
Ch.5 machine learning basicsJinho Lee
 
Ch.4 numerical computation
Ch.4  numerical computationCh.4  numerical computation
Ch.4 numerical computationJinho Lee
 
Ch.3 Probability and Information Theory
Ch.3  Probability and Information TheoryCh.3  Probability and Information Theory
Ch.3 Probability and Information TheoryJinho Lee
 
Ch.2 Linear Algebra
Ch.2  Linear AlgebraCh.2  Linear Algebra
Ch.2 Linear AlgebraJinho Lee
 

More from Jinho Lee (10)

Quantum computing and quantum information 1.2, 1.3
Quantum computing and quantum information 1.2, 1.3Quantum computing and quantum information 1.2, 1.3
Quantum computing and quantum information 1.2, 1.3
 
Effective active learning strategy for multi label learning
Effective active learning strategy for multi label learningEffective active learning strategy for multi label learning
Effective active learning strategy for multi label learning
 
Wasserstein GAN
Wasserstein GANWasserstein GAN
Wasserstein GAN
 
Generative Adversarial Nets
Generative Adversarial NetsGenerative Adversarial Nets
Generative Adversarial Nets
 
Support vector machines
Support vector machinesSupport vector machines
Support vector machines
 
Wasserstein gan
Wasserstein ganWasserstein gan
Wasserstein gan
 
Ch.5 machine learning basics
Ch.5  machine learning basicsCh.5  machine learning basics
Ch.5 machine learning basics
 
Ch.4 numerical computation
Ch.4  numerical computationCh.4  numerical computation
Ch.4 numerical computation
 
Ch.3 Probability and Information Theory
Ch.3  Probability and Information TheoryCh.3  Probability and Information Theory
Ch.3 Probability and Information Theory
 
Ch.2 Linear Algebra
Ch.2  Linear AlgebraCh.2  Linear Algebra
Ch.2 Linear Algebra
 

Auto-Encoders and Variational Auto-Encoders

  • 1.
  • 2. In this chapter, we will discuss about • What is Autoencoder - neural networks whose dimension of input and output are same - if the autoencoder use only linear activations and the cost function is MES, then it is same to PCA - the architecture of a stacked autoencoder is typically symmetrical
  • 3. Contents • Autoencoders • Denoising Autoencoders • Variational Autoencoders
  • 5. Introduction • Autoencoder 는 encoder 와 decoder 로 나뉜다. 오른쪽 diagram 에서 𝑓 가 encoder 이고, 𝑔 가 decoder 이다. • cost function 은 reconstruction error 를 사용한다: 𝐿(𝑥, 𝑔 𝑓 𝑥 = 𝑥 − 𝑔 𝑓 𝑥 2 • hidden layer 가 2개 이상인 AE를 stacked Autoencoder 라고 한다. • e.g. linear activation 만 사용하고, cost function 으로 MSE 를 사용 한 Autoencoder 는 PCA 이다. 𝑥 ℎ 𝑟 𝑓 𝑔
  • 6. Introduction • 보통 hidden layer 개수는 홀수이며 AE의 정의에 의해 center layer(=coding layer)를 기준으로 양쪽의 unit 개수가 같다. Coding layer Encoder Decoder
  • 7. Introduction ∙ 아래의 그림처럼 symmetric 하지 않는 Autoencoder 도 있다. ∙ 보통은 encoder 부분의 마지막 layer 의 unit 의 개수는 input layer의 dimension 보다 작다. 이런 Autoencoder 를 undercomplete 라고 하고 반대의 경우를 overcomplete 라고 한다. * overcomplete 이면 inclusion + projection 으로 loss 를 0 으로 만들 수 있음
  • 8. Cost function • [VLBM, p.2] An autoencoder takes an input vector 𝑥 ∈ 0,1 𝑑 , and first maps it to a hidden representation y ∈ 0,1 𝑑′ through a deterministic mapping 𝑦 = 𝑓𝜃 𝑥 = 𝑠(𝑊𝑥 + 𝑏), parameterized by 𝜃 = {𝑊, 𝑏}. 𝑊 is a 𝑑 × 𝑑′ weight matrix and 𝒃 is a bias vector. The resulting latent representation 𝑦 is then mapped back to a “reconstructed” vector z ∈ 0,1 𝑑 in input space 𝑧 = 𝑔 𝜃′ 𝑦 = 𝑠 𝑊′ 𝑦 + 𝑏′ with 𝜃′ = {𝑊′, 𝑏′}. The weight matrix 𝑊′ of the reverse mapping may optionally be constrained by 𝑊′ = 𝑊 𝑇, in which case the autoencoder is said to have tied weights. • The parameters of this model are optimized to minimize the average reconstruction error: 𝜃∗ , 𝜃′∗ = arg min 𝜃,𝜃′ 1 𝑛 𝑖=1 𝑛 𝐿(𝑥 𝑖 , 𝑧 𝑖 ) = arg min 𝜃,𝜃′ 1 𝑛 𝑖=1 𝑛 𝐿(𝑥 𝑖 , 𝑔 𝜃′(𝑓𝜃 𝑥 𝑖 ) (1) where 𝐿 𝑥 − 𝑧 = 𝑥 − 𝑧 2.
  • 9. Cost function • [VLBM,p.2] An alternative loss, suggested by the interpretation of 𝑥 and 𝑧 as either bit vectors or vectors of bit probabilities (Bernoullis) is the reconstruction cross-entropy: 𝐿 𝐻 𝑥, 𝑧 = 𝐻(𝐵𝑥||𝐵𝑧) = − 𝑘=1 𝑑 [𝑥 𝑘 log 𝑧 𝑘 + log 1 − 𝑥 𝑘 log(1 − 𝑧 𝑘)] where 𝐵𝜇 𝑥 = (𝐵𝜇1 𝑥 , ⋯ , 𝐵𝜇 𝑑 𝑥 ) is a Bernoulli distribution. • [VLBM,p.2] Equation (1) with 𝐿 = 𝐿 𝐻 can be written 𝜃∗, 𝜃′∗ = arg min 𝜃,𝜃′ 𝐸 𝑞0 [𝐿 𝐻(𝑋, 𝑔 𝜃′(𝑓𝜃 𝑋 ))] where 𝑞0(𝑋) denotes the empirical distribution associated to our 𝑛 training inputs.
  • 11. Denoising Autoencoders • [VLBM,p.3] corrupted input 를 넣어 repaired input 을 찾는 training 을 한다. 좀 더 정확하게 말하면 input data의 dimension 이 𝑑 라고 할 때 ‘desired proportion 𝜈 of destruction’ 을 정하여 𝜈𝑑 만큼의 input 을 0 으로 수정하는 방식으로 destruction 한다. 여기서 𝜈𝑑 개 components 는 random 으로 정한다. 이후 reconstruction error 를 체크하여 destruction 전의 input 으로 복구하는 cost function 이용하여 학습을 하는 Autoencoder 가 Denoising Autoencoder 이다. 여기서 𝑥 에서 destroyed version 인 𝑥 를 얻는 과정은 stochastic mapping 𝑥 ~ 𝑞 𝐷( 𝑥|x) 를 따른다.
  • 12. Denoising Autoencoders • [VLBM,p.3] Let us define the joint distribution 𝑞0 𝑋, 𝑋, 𝑌 = 𝑞0 𝑋 𝑞 𝐷 𝑋 𝑋 𝛿𝑓 𝜃 𝑋 (𝑌)) where 𝛿 𝑢(𝑣) is the Kronecker delta. Thus 𝑌 is a deterministic function of 𝑋. 𝑞0(𝑋, 𝑋, 𝑌) is parameterized by 𝜃. The objective function minimized by stochastic gradient descent becomes: 𝑎𝑟𝑔 𝑚𝑖𝑛 𝜃,𝜃′ 𝐸 𝑞0 𝑥, 𝑥 [𝐿 𝐻(𝑥, 𝑔 𝜃′(𝑓𝜃( 𝑥))]) Corrupted 𝑥 를 입력하고 𝑥 를 찾는 방법으로 학습!
  • 13. Other Autoencoders • [DL book, 14.2.1] A sparse autoencoder is simply an autoencoder whose training criterion involves a sparsity penalty Ω ℎ on the code layer h, in addition to the reconstruction error: 𝐿(𝑥, 𝑔 𝑓 𝑥 ) + Ω(ℎ), where 𝑔 ℎ is the decoder output and typically we have ℎ = 𝑓(𝑥), the encoder output. • [DL book, 14.2.3] Another strategy for regularizing an autoencoder is to use a penalty Ω as in sparse autoencoders, 𝐿 𝑥, 𝑔 𝑓 𝑥 ) + Ω(ℎ, 𝑥 , but with a different form of Ω: Ω ℎ, 𝑥 = 𝜆 𝑖 𝛻𝑥ℎ𝑖 2
  • 15. Reference • Reference. Auto-Encoding Variational Bayes, Diederik P Kingma, Max Welling, 2013 • [논문의 가정] We will restrict ourselves here to the common case where we have an i.i.d. dataset with latent variables per datapoint, and where we like to perform maximum likelihood (ML) or maximum a posteriori (MAP) inference on the (global) parameters, and variational inference on the latent variables.
  • 16. Definition • Generative Model 의 목표 - 𝑋 = {𝑥𝑖} 를 생성하는 집합 𝑍 = {𝑧𝑗} 와 함수 𝜃 를 찾는 것이 목표이다. i.e. Finding arg min 𝑍,𝜃 𝑑(𝑥, 𝜃(𝑧)) where 𝑑 is a metric • VAE 도 generative model 이므로 집합 𝑍 와 함수 𝜃 가 유기적으로 동작하여 좋은 모델을 만들게 되는데 VAE는 Latent variable 𝑧 가 parametrized distribution(by 𝜙) 에서 나온다 고 가정하고 𝑥 를 잘 생성하는 parameter 𝜃 를 학습하게 된다. Figure 1 z 𝑥 𝜃
  • 17. Problem scenario • Dataset 𝑋 = 𝑥 𝑖 𝑖=1 𝑁 는 i.i.d 인 continuous(또는 discrete) variable 𝑥 의 sample 이다. 𝑋 는 unobserved continuous variable 𝑧 의 some random process 로 생성되었다고 가정하자. 여기서 random process 는 두 개의 step 으로 구성되어있다: (1) 𝑧(𝑖) is generated from some prior distribution 𝑝 𝜃∗(𝑧) (2) 𝑥(𝑖) is generated from some conditional distribution 𝑝 𝜃∗(𝑥|𝑧) • Prior 𝑝 𝜃∗ 𝑧 와 likelihood 𝑝 𝜃∗(𝑥|𝑧) 는 differentiable almost everywhere w.r.t 𝜃 and 𝑧 인 parametric families of distributions 𝑝 𝜃(𝑧)와 𝑝 𝜃(𝑥|𝑧) 들의 에서 온 것으로 가정하자. • 아쉽게도 true parameter 𝜃∗ 와 latent variables 𝑧(𝑖) 의 값을 알 수 없어서 cost function 을 정하고 그것의 lower bound 를 구하는 방향으로 전개될 예정이다.
  • 18. Intractibility and Variational Inference • 𝑝 𝜃 𝑥 = 𝑝 𝜃 𝑥 𝑝 𝜃 𝑥 𝑧 𝑑𝑧 is intractable(계산 불가능) ∵ 𝑝 𝜃 𝑧 𝑥 = 𝑝 𝜃 𝑥 𝑧 𝑝 𝜃(𝑧)/𝑝 𝜃(𝑥) is intractable • 𝑝 𝜃 𝑧 𝑥 를 알 수 없으니 우리가 아는 함수라고 가정하자. 이런 방법을 variational inference 라고 한다. 즉, 잘 아는 함수 𝑞 𝜙(𝑧|𝑥) 를 𝑝 𝜃 𝑧 𝑥 대신 사용하는 방법을 variational inference 라고 한다. • Idea : prior 𝑝 𝜃 𝑧 𝑥 를 𝑞 𝜙(𝑧|𝑥) 로 사용해도 되는 이유는 주어진 input 𝑧 가 𝑥 에 근사하게 학습이 된다.
  • 19. Then variational bound • 우리는 𝑋 = 𝑥 𝑖 𝑖=1 𝑁 가 i.i.d 를 만족한다고 가정했으므로 log 𝑝 𝜃(𝑥 1 , ⋯ , 𝑥(𝑁) ) = 𝑖=1 𝑁 log 𝑝 𝜃(𝑥 𝑖 ) 이다. • 각각의 𝑥 ∈ 𝑋에 대해 아래 식을 얻을 수 있다: log 𝑝 𝜃 𝑥 = 𝑧 𝑞 𝜙 𝑧 𝑥 log 𝑝 𝜃(𝑥) 𝑑𝑧 = 𝑧 𝑞 𝜙 𝑧 𝑥 log 𝑝 𝜃 𝑧,𝑥 𝑝 𝜃(𝑧|𝑥) 𝑑𝑧 = 𝑧 𝑞 𝜙 𝑧 𝑥 log 𝑝 𝜃 𝑧,𝑥 𝑞 𝜙 𝑧 𝑥 𝑞 𝜙 𝑧 𝑥 𝑝 𝜃 𝑧 𝑥 𝑑𝑧 = 𝑧 𝑞 𝜙 𝑧 𝑥 log 𝑝 𝜃 𝑧,𝑥 𝑞 𝜙 𝑧 𝑥 𝑑𝑧 + 𝑧 𝑞 𝜙 𝑧 𝑥 𝑞 𝜙 𝑧 𝑥 𝑝 𝜃 𝑧 𝑥 𝑑𝑧 = 𝓛 𝜃, 𝜙; 𝑥 + 𝐷 𝐾𝐿(𝑞 𝜃(𝑧|𝑥)||𝑝 𝜃 𝑧 𝑥 ) (1) ≥ 𝓛 𝜃, 𝜙; 𝑥 언제나 𝐾𝐿 divergence 는 0 이상이므로 𝑧 𝑞 𝜙 𝑧 𝑥 log 𝑝 𝜃 𝑧,𝑥 𝑞 𝜙 𝑧 𝑥 𝑑𝑧 는 lower bound 가 된다. 이것 을 𝓛 𝜃, 𝜙; 𝑥 라고 놓자.
  • 20. Cost function • (Eq.3) 𝓛 𝜃, 𝜙; 𝑥 = −𝐷 𝐾𝐿(𝑞 𝜙(𝑧|𝑥)||𝑝 𝜃 𝑥 ) + 𝐸 𝑞 𝜙 𝑧 𝑥 [log 𝑝 𝜃(𝑥|𝑧)] <Proof> 𝓛 𝜃, 𝜙; 𝑥 = 𝑧 𝑞 𝜙 𝑧 𝑥 log 𝑝 𝜃(𝑧,𝑥) 𝑞 𝜙(𝑧|𝑥) 𝑑𝑧 = 𝑧 𝑞 𝜙 𝑧 𝑥 log 𝑝 𝜃 𝑧)𝑝 𝜃(𝑥|𝑧 𝑞 𝜙 (𝑧|𝑥) 𝑑𝑧 = 𝑧 𝑞 𝜙 𝑧 𝑥 log 𝑝 𝜃(𝑧) 𝑞 𝜙 (𝑧|𝑥) 𝑑𝑧 + 𝑧 𝑞 𝜙 𝑧 𝑥 log 𝑝 𝜃 𝑥 𝑧 𝑑𝑧 = −𝐷 𝐾𝐿(𝑞 𝜙(𝑧|𝑥)| 𝑝 𝜃(𝑧) + 𝐸 𝑞 𝜙 𝑧 𝑥 [log 𝑝 𝜃(𝑥|𝑧)] 𝑞 𝜙와 𝑝 𝜃가 normal 이면 계산 가능! Reconstruction error
  • 21. Cost function • Lemma. If 𝑝 𝑥 ~𝑁 𝜇1, 𝜎1 2 and 𝑞 𝑥 ~𝑁 𝜇2, 𝜎2 2 , then 𝐾𝐿(𝑝(𝑥)||𝑞 𝑥 ) = ln 𝜎2 𝜎1 + 𝜎1 2 + 𝜇1 − 𝜇2 2 2𝜎2 2 − 1 2 • Corollary. 𝑞 𝜙 𝑧 𝑥 ~ 𝑁(𝜇𝑖, 𝜎𝑖 2 𝐼) 이고 𝑝 𝑧 ~𝑁 0,1 이면 𝐾𝐿 𝑞 𝜙 𝑧 𝑥𝑖 𝑝 𝑧 = 1 2 (𝑡𝑟 𝜎𝑖 2 𝐼 + 𝜇𝑖 𝑖 𝑇𝜇 − 𝐽 + ln 1 𝑗=𝑖 𝐽 𝜎𝑖,𝑗 2 ) = (Σ𝑗=1 𝐽 𝜎𝑖,𝑗 2 + Σ𝑗=1 𝐽 𝜇𝑖,𝑗 2 − 𝐽 − Σ𝑗=1 𝐽 ln(𝜎𝑖,𝑗 2 )) = 1 2 Σ𝑗=1 𝐽 (𝜇𝑖,𝑗 2 + 𝜎𝑖,𝑗 2 − 1 − ln 𝜎𝑖,𝑗 2 ) • 즉, 𝑞 𝜙 𝑧 𝑥 ~ 𝑁(𝜇𝑖, 𝜎𝑖 2 𝐼) 이고 𝑝 𝑧 ~𝑁 0,1 이면 Eq.3 는 아래와 같다. 𝓛 𝜃, 𝜙; 𝑥 = 1 2 Σ𝑗=1 𝐽 𝜇𝑖,𝑗 2 + 𝜎𝑖,𝑗 2 − 1 − ln 𝜎𝑖,𝑗 2 + 𝐸 𝑞 𝜙 𝑧 𝑥 [log 𝑝 𝜃(𝑥|𝑧)]
  • 22. Reconstruction error 학습 방법 • 𝐸 𝑞 𝜙 𝑧 𝑥 [log 𝑝 𝜃(𝑥|𝑧)]는 sampling 을 통해 Monte-carlo estimation 한다. 즉, 𝑥𝑖 ∈ X 마다 𝑧 𝑖,1 , ⋯ , 𝑧 𝑖 𝐿 를 sampling 하여 log likelihood 의 mean으로 근사시킨다. 보통 𝐿 = 1 을 많이 사용한다. 𝐸 𝑞 𝜙 𝑧 𝑥 [log 𝑝 𝜃(𝑥|𝑧)] ∼ 1 𝐿 Σ𝑙=1 𝐿 log(𝑝 𝜃 𝑥𝑖 𝑧 𝑖,𝑙 ) • 이렇게 sampling 을 하면 backpropagation 을 할 수 없다. 그래서 사용 되는 방법이 reparametrization trick 이다. 𝑞 𝜙 𝑥 𝑧 𝑝 𝜃 𝑥 𝑧
  • 23. Reparametrization trick • Reparametrization trick : sampling 에서 생기는 backpropagation 불가능 문제를 해결하기 위한 방법. 𝑧~𝑁 𝜇, 𝜎2 ⇒ 𝑧 = 𝜇 + 𝜎𝜖 where 𝜖~𝑁(0,1)
  • 24. Log Likelihood • 앞에서 reconstruction error 를 계산할 때 하나씩 sampling 을 하면 𝐸 𝑞 𝜙 𝑧 𝑥 [log 𝑝 𝜃(𝑥|𝑧)] ∼ 1 𝐿 Σ𝑙=1 𝐿 log 𝑝 𝜃 𝑥𝑖 𝑧 𝑖,𝑙 = log(𝑝 𝜃(𝑥𝑖|𝑧 𝑖 ) 가 된다. 여기서 𝑝 𝜃 𝑥𝑖 𝑧 𝑖 의 분포가 Bernoulli 인 경우에 아래의 식을 얻을 수 있다. 출처 : https://github.com/hwalsuklee/tensorflow-mnist-VAE
  • 25. Log Likelihood • 𝑝 𝜃 𝑥𝑖 𝑧 𝑖 의 분포가 normal 인 경우에 아래의 식을 얻을 수 있다. 출처 : https://github.com/hwalsuklee/tensorflow-mnist-VAE
  • 28. Examples of VAE 출처 : https://github.com/hwalsuklee/tensorflow-mnist-VAE
  • 29. Examples of DAE 출처 : https://github.com/hwalsuklee/tensorflow-mnist-VAE
  • 30. References • [VLBM] Extracting and composing robust features with denoising autoencoders, Vincent, Larochelle, Bengio, Manzagol, 2008 • [KW] Auto-Encoding Variational Bayes, Diederik P Kingma, Max Welling, 2013 • [D] Tutorial on Variational Autoencoders - Carl Doersch, 2016 • PR-010: Auto-Encoding Variational Bayes, ICLR 2014, 차준범 • 오토인코더의 모든 것, 이활석 https://github.com/hwalsuklee/tensorflow-mnist-VAE