SlideShare una empresa de Scribd logo
1 de 25
Descargar para leer sin conexión
Auto-Encoding Variational Bayes
Diederik P. Kingma, Max Welling, 2014
Motivation – generative model
Trainig samples
Density Estimation
𝑝 𝑥 Ƹ𝑝(𝑥)
Sampling
Problem scenario - Latent Variable Model
𝑧 x
Generator
𝑔 𝜃(∙)
step1 : a value 𝑧(𝑖)
is generated from some prior distribution 𝑝(𝑧) (normal or uniform)
step2 : a value x(𝑖)
is generated from some contional distribution 𝑝(x|𝑔 𝜃∗(𝑧))
• X = x(𝑖)
𝑖=1
𝑁
• x
• 𝑧
• 𝑝(∙)
• 𝑔 𝜃 ∙
𝑔: 𝑍 × Θ → 𝜒
• 𝑔 𝑧; 𝜃 = 𝑔 𝜃 𝑧
• 𝑝 x 𝑔 𝜃 𝑧 = 𝑝 𝜃(x|𝑧)
continuous random variable in space 𝑍
a deterministic function parameterized by 𝜃 in some space Θ
random variable in the space 𝜒
dataset
likelihood
random variable
pdf of 𝑧
, 𝜒 is some space
Goal : maximize 𝑝 X = ‫׬‬ 𝑝 X|𝑔 𝜃 𝑧 𝑝 𝑧 𝑑𝑧 !!!
In VAEs, this output distribution is often istropic gaussian
i.e. 𝑝 X 𝑔 𝜃 𝑧 = 𝑁(X|𝑔 𝜃 𝑧 , 𝜎2 𝐼) (Tutorial on VAEs, 3page)
Problem1 - 𝑝 𝜃 𝑥 𝑧
• 𝑝 x = ‫׬‬ 𝑝 x|𝑔 𝜃 𝑧 𝑝 𝑧 𝑑𝑧 the integral of the marginal likelihood
→ ‫׬‬ 𝑝 x|𝑔 𝜃 𝑧 𝑝 𝑧 𝑑𝑧 is intractable
Solution
• Bad solution
임의의 prior distribution에서 𝑧를 샘플링하여 likelihood가 커지도록 𝜃를 조절하는 방법
→ 원하는 결과를 얻지 못함. 데이터 셋의 분포를 추정하기 어려움
• Good solution
𝑝 z|x 에서 𝑧를 샘플링하여 likelihood가 커지도록 𝜃를 조절하는 방법
→ 𝑝 z|x =
𝑝 x 𝑧 𝑝(𝑧)
𝑝(x)
is intractable
→ Variational Inference 방법을 이용하여 해결
Problem2 - Sampling
• 𝑧를 샘플링 해야한다
𝑧 𝑖~𝑁 𝜇𝑖, 𝜎𝑖
2
𝐼
• 샘플링을 하면 gradient descent 방법을 사용할 수 없다.
• Reparameterization trick
• backpropagation 계산이 가능한 방법으로 대체한다.
𝑧 𝑖 = 𝜇𝑖 + 𝜎𝑖
2
⨀𝜖, 𝜖~𝑁(0, 𝐼)
Solution
Bad Solution – maximum likelihood estimation directly
step1 : 𝑝(𝑧)에서 데이터 𝑛개를 샘플링한다. 𝑧(1)
, ⋯ , 𝑧(2)
step2 : 𝑝(x) ≈ σ𝑖=1
𝑛
𝑝 x 𝑔 𝜃 𝑧(𝑖)
𝑝 𝑧(𝑖)
* 단, 𝑥의 차원이 크면 𝑛도 커야 한다.
step3 : 𝑝 𝑥 𝑔 𝜃 𝑧 를 Isotropic Gaussian(𝑁(𝑥|𝑔 𝜃 𝑧 , 𝜎2
𝐼))으로 가정하면, -log 𝑝 𝑥 𝑔 𝜃 𝑧 는
𝑔 𝜃 𝑧 와 𝑥의 Euclidian distance와 비례관계 * MSE를 목적함수로 학습
문제점
x − 𝑔 𝜃 𝑧(𝑏) 2
< x − 𝑔 𝜃 𝑧(𝑐) 2
→ 𝑝(x|𝑔 𝜃 𝑧(𝑏)
) > 𝑝(x|𝑔 𝜃 𝑧(𝑐)
)
(c)의 샘플로 생성된 이미지가 의미적으로 (a)에 더 비슷하지만,
MSE관점에서는 (b)의 샘플이 𝑝(x)에 기여하는 바가 더 크다. * 올바른 학습이 어려움
Good Solution – Variational inference
• 𝑧를 임의의 정규분포로부터 샘플링하는 것은 Bad Solution
→ x와 의미적으로 유사한 샘플을 얻기 위하여 𝑝(𝑧|x)로 부터 샘플링
→ 𝑝(𝑧|x)를 알 수 없음
→ 해석하기 쉬운 확률 분포 중 하나(𝑞 𝜙(𝑧|𝑥))를 택하고,
𝜙 값을 조정하여 𝑝(𝑧|𝑥)와 유사하게 만들자. * Variational Inference
→ 𝑞 𝜙(𝑧|𝑥) 분포로부터 𝑧를 샘플링
• 요약
1. 데이터 셋과 유사한 이미지를 생성하자
2. 𝑔 𝜃(∙)와 𝑧를 이용해서 생성하자
3. 𝑧는 쉬운 확률 분포(정규분포) 에서 샘플링하자
4. 데이터셋과 의미적으로 유사한 샘플을 얻을 수 있도록 𝑧를 𝑝(𝑧|x)에서 샘플링하자
5. 𝑝(𝑧|x)를 구하기 어렵다
6. 쉬운 확률 분포 𝑞 𝜙(𝑧|x)를 택하고 𝑝(𝑧|x)에 근사하게 파라미터를 조절하자.
7. 𝑞 𝜙(𝑧|x) 분포로부터 𝑧를 샘플링하자
Variational inference – ELBO : Evidence Lower BOund
• Relationship among 𝑝(𝑥), 𝑝(𝑧|𝑥), 𝑞 𝜙(𝑧|𝑥) : Derivation 1
log 𝑝(x)
Jensen’s Ineuqality, log(∙) is concave
= log න 𝑝 x 𝑧
𝑝 𝑧
𝑞 𝜙 𝑧 x
𝑞 𝜙 𝑧 x 𝑑𝑧 ≥ න log 𝑝 x 𝑧
𝑝 𝑧
𝑞 𝜙 𝑧 x
𝑞 𝜙 𝑧 x 𝑑𝑧
= log න 𝑝 x 𝑧 𝑝(𝑧) 𝑑𝑧
log 𝑝(x) ≥ න log 𝑝 x 𝑧 𝑞 𝜙 𝑧 x 𝑑𝑧 − න log
𝑞 𝜙 𝑧 x
𝑝 𝑧
𝑞 𝜙 𝑧 x 𝑑𝑧
= 𝐸 𝑞 𝜙(𝑧|x) log 𝑝(x|𝑧) − 𝐾𝐿(𝑞 𝜙 𝑧 x ∥ 𝑝 𝑧 )
𝐸𝐿𝐵𝑂(𝜙)
Variational inference – ELBO : Evidence Lower BOund
• Relationship among 𝑝(x), 𝑝(𝑧|x), 𝑞 𝜙(𝑧|x) : Derivation 2
log 𝑝(x) = න log 𝑝 x 𝑞 𝜙 𝑧 x 𝑑𝑧
= න log
𝑝 x, 𝑧
𝑝 𝑧 x
𝑞 𝜙(𝑧|x)
= න log
𝑝 x, 𝑧
𝑞 𝜙 𝑧 x
∙
𝑞 𝜙 𝑧 x
𝑝 𝑧 x
𝑞 𝜙 𝑧 x 𝑑𝑧
= න log
𝑝 x, 𝑧
𝑞 𝜙 𝑧 x
𝑞 𝜙 𝑧 x 𝑑𝑧 + න log
𝑞 𝜙 𝑧 x
𝑝 𝑧 x
𝑞 𝜙 𝑧 x 𝑑𝑧
𝐸𝐿𝐵𝑂(𝜙) 𝐾𝐿 𝑞 𝜙 𝑧 x ∥ 𝑝 𝑧 x
𝐾𝐿을 최소화하는 𝑞 𝜙 𝑧 x 의 𝜙값을 구하면 된다.
𝑝 𝑧 x 를 알 수 없기 때문에 𝐾𝐿을 최소화하는 대신 ELBO를 최대화하는 𝜙값을 찾는다.
න 𝑞 𝜙 𝑧 x 𝑑𝑧 = 1
Variational inference – ELBO : Evidence Lower BOund
• Relationship among 𝑝(x), 𝑝(𝑧|x), 𝑞 𝜙(𝑧|x) : Derivation 2
log 𝑝(x) = 𝐸𝐿𝐵𝑂 𝜙 + 𝐾𝐿 𝑞 𝜙 𝑧 x ∥ 𝑝 𝑧 x
Goal : argmax
𝜙
𝐸𝐿𝐵𝑂(𝜙)
𝐸𝐿𝐵𝑂 𝜙 = න log
𝑝 x, 𝑧
𝑞 𝜙 𝑧 x
𝑞 𝜙 𝑧 x 𝑑𝑧
= න log
𝑝 x|𝑧 𝑝(𝑧)
𝑞 𝜙 𝑧 x
𝑞 𝜙 𝑧 x 𝑑𝑧
= න log 𝑝(x|𝑧) 𝑞 𝜙 𝑧 x 𝑑𝑧 − න log
𝑞 𝜙 𝑧 x
𝑝 𝑧
𝑞 𝜙 𝑧 x 𝑑𝑧
= 𝐸 𝑞 𝜙(𝑧|x) log 𝑝(x|𝑧) − 𝐾𝐿(𝑞 𝜙(𝑧|x) ∥ 𝑝(𝑧))
log 𝑝(x) ≥ 𝐸 𝑞 𝜙(𝑧|x) log 𝑝(x|𝑧) − 𝐾𝐿(𝑞 𝜙(𝑧|x) ∥ 𝑝(𝑧))
Loss function
• log 𝑝(x) ≥ 𝐸 𝑞 𝜙(𝑧|x) log 𝑝(x|𝑧) − 𝐾𝐿(𝑞 𝜙(𝑧|x) ∥ 𝑝(𝑧))
• log 𝑝(x|𝑔 𝜃(𝑧)) ≥ 𝐸 𝑞 𝜙(𝑧|x) log 𝑝(x|𝑔 𝜃(𝑧)) − 𝐾𝐿(𝑞 𝜙(𝑧|x) ∥ 𝑝(𝑧))
𝑝 x = න 𝑝 x|𝑔 𝜃 𝑧 𝑝 𝑧 𝑑𝑧
• for data x(𝑖),
𝑳 𝜽, 𝝓; 𝐱 𝒊
= −𝑬
𝒒 𝝓 𝒛 𝐱 𝒊 𝐥𝐨𝐠 𝒑 𝐱 𝒊
𝒈 𝜽(𝒛) + 𝑲𝑳 𝒒 𝝓 𝒛 𝐱(𝒊)
∥ 𝒑 𝒛
Note.
논문의 3번 식과 부호가 다르다.
논문에서의 L은 lower bound의 의미, ppt에서의 L은 loss의 의미.
논문의 lower bound를 최대화하는 것은 ppt의 loss를 최소화하는 것과 동일.
Objective function
𝑧 x
Generator
𝑔 𝜃(∙)
x
Inference
𝑞 𝜙(∙)
~
Sampling
argmin
1
𝑁
σ𝑖=1
𝑁
𝐿 𝜃, 𝜙; x 𝑖 =
1
𝑁
σ𝑖=1
𝑁
−𝐸
𝑞 𝜙 𝑧 x 𝑖 log 𝑝 x 𝑖 𝑔 𝜃 + 𝐾𝐿 𝑞 𝜙 𝑧 x(𝑖) ∥ 𝑝 𝑧
𝜙, 𝜃
Encoder – 𝐾𝐿 divergence
x(𝑖) 𝑞 𝜙(𝑧|x(𝑖))
𝜇𝑖
𝜎𝑖
Assumption 1
Isotropic gaussian distribution
𝑞 𝜙 𝑧 𝑥𝑖 ~ 𝑁(𝜇𝑖, 𝜎𝑖
2
𝐼)
Asuumption 2
Gaussian distribution
𝑝(𝑧) ~ 𝑁 0, 𝐼
𝐾𝐿 𝑞 𝜙 𝑧 x(𝑖) ∥ 𝑝 𝑧 =
1
2
𝑡𝑟 𝜎𝑖
2
𝐼 + 𝜇𝑖
𝑇
𝜇𝑖 − 𝐽 + ln
1
ς 𝑗=1
𝐽
𝜎𝑖,𝑗
2
=
1
2
෍
𝑗=1
𝐽
𝜎𝑖,𝑗
2
+ ෍
𝑗=1
𝐽
𝜇𝑖,𝑗
2
− 𝐽 − ෍
𝑗=1
𝐽
ln 𝜎𝑖,𝑗
2
=
1
2
෍
𝑗=1
𝐽
𝜇𝑖,𝑗
2
+ 𝜎𝑖,𝑗
2
− ln 𝜎𝑖,𝑗
2
− 1
The Kullback-Leibler divergence from 𝑁0(𝜇0, Σ0) to 𝑁1(𝜇1, Σ1)
for non-singular matrices Σ0 and Σ1 is
𝐾𝐿 𝑁0 ∥ 𝑁1 =
1
2
𝑡𝑟 Σ1
−1
Σ0 + 𝜇1 − 𝜇0
𝑇Σ1
−1
𝜇1 − 𝜇0 − 𝑘 + ln
Σ1
Σ0
,
where 𝑘 is the dimension of the vector space
argmin
𝟏
𝑵
σ𝒊=𝟏
𝑵
𝑳 𝜽, 𝝓; 𝐱 𝒊
=
𝟏
𝑵
σ𝒊=𝟏
𝑵
−𝑬
𝒒 𝝓 𝒛 𝐱 𝒊 𝒍𝒐𝒈 𝒑 𝐱 𝒊
𝒈 𝜽 + 𝑲𝑳 𝒒 𝝓 𝒛 𝐱(𝒊)
∥ 𝒑 𝒛
𝝓, 𝜽
𝐷
𝐽
𝐽
Encoder – reparameterised trick
𝐸
𝑞 𝜙 𝑧 x 𝑖 log 𝑝 x 𝑖 |𝑔 𝜃(𝑧) = න log 𝑝 x 𝑖 |𝑔 𝜃(𝑧) 𝑞 𝜙 𝑧 x 𝑖 𝑑𝑧
≈
1
𝐿
σ 𝑧(𝑖,𝑙) log 𝑝 x 𝑖 |𝑔 𝜃(𝑧(𝑖, 𝑙))
monte-carlo technique
𝑧 𝑖, 𝑗~𝑁 𝜇𝑖, 𝜎𝑖
2
𝐼 𝑧 𝑖, 𝑗
= 𝜇𝑖 + 𝜎𝑖
2
⨀𝜖, 𝜖~𝑁(0, 𝐼)
argmin
𝟏
𝑵
σ𝒊=𝟏
𝑵
𝑳 𝜽, 𝝓; 𝐱 𝒊
=
𝟏
𝑵
σ𝒊=𝟏
𝑵
−𝑬
𝒒 𝝓 𝒛 𝐱 𝒊 𝒍𝒐𝒈 𝒑 𝐱 𝒊
𝒈 𝜽 + 𝑲𝑳 𝒒 𝝓 𝒛 𝐱(𝒊)
∥ 𝒑 𝒛
𝝓, 𝜽
x(𝑖) 𝑞 𝜙(𝑧|x(𝑖))
𝜇𝑖
𝜎𝑖
𝐷
𝐽
𝐽
Decoder – likelihood (Bernoulli)
𝐸
𝑞 𝜙 𝑧 x 𝑖 log 𝑝 x 𝑖 |𝑔 𝜃(𝑧) = න log 𝑝 x 𝑖 |𝑔 𝜃(𝑧) 𝑞 𝜙 𝑧 x 𝑖 𝑑𝑧 ≈
1
𝐿
෍
𝑧(𝑖,𝑙)
log 𝑝 x 𝑖 |𝑔 𝜃(𝑧(𝑖, 𝑙)) ≈ log 𝑝 x 𝑖 |𝑔 𝜃(𝑧(𝑖))
monte-carlo technique 𝐿 = 1
log 𝑝 𝜃 x 𝑖
|𝑧 𝑖
= log ෑ
𝑗=1
𝐷
𝑝 𝜃 x 𝑖,𝑗
|𝑧(𝑖)
= ෍
𝑗=1
𝐷
log 𝑝 𝜃 x 𝑖,𝑗
|𝑧(𝑖)
𝑝 𝜃 x(𝑖)|𝑔 𝜃(𝑧(𝑖)) ~𝐵𝑒𝑟𝑛𝑜𝑢𝑙𝑙𝑖(𝑝𝑖)
= ෍
𝑗=1
𝐷
log 𝑝𝑖,𝑗
x 𝑖,𝑗
1 − 𝑝𝑖,𝑗
1−x 𝑖,𝑗
= ෍
𝑗=1
𝐷
x 𝑖,𝑗
log 𝑝𝑖,𝑗 + 1 − x 𝑖,𝑗
log 1 − 𝑝𝑖,𝑗
𝑝𝑖𝑧(𝑖)
𝐷
𝐽
argmin
𝟏
𝑵
σ𝒊=𝟏
𝑵
𝑳 𝜽, 𝝓; 𝐱 𝒊
=
𝟏
𝑵
σ𝒊=𝟏
𝑵
−𝑬
𝒒 𝝓 𝒛 𝐱 𝒊 𝒍𝒐𝒈 𝒑 𝐱 𝒊
𝒈 𝜽 + 𝑲𝑳 𝒒 𝝓 𝒛 𝐱(𝒊)
∥ 𝒑 𝒛
𝝓, 𝜽
𝑔 𝜃(∙)
cross entropy
Decoder – likelihood (Gaussian)
𝑔 𝜃(∙)
log 𝑝 𝜃 x 𝑖 |𝑧(𝑖) = log 𝑁 x 𝑖 ; 𝜇𝑖, 𝜎𝑖
2
𝐼
= − ෍
𝑗=1
𝐷 1
2
log 𝜎𝑖,𝑗
2
+
x 𝑖,𝑗 − 𝜇𝑖,𝑗
2
2𝜎𝑖,𝑗
2
log 𝑝 𝜃 x 𝑖 |𝑧(𝑖) ∝ − ෍
𝑗=1
𝐷
x 𝑖,𝑗 − 𝜇𝑖,𝑗
2
𝜇𝑖
𝜎𝑖
𝐸
𝑞 𝜙 𝑧 x 𝑖 log 𝑝 x 𝑖 |𝑔 𝜃(𝑧) = න log 𝑝 x 𝑖 |𝑔 𝜃(𝑧) 𝑞 𝜙 𝑧 x 𝑖 𝑑𝑧 ≈
1
𝐿
෍
𝑧(𝑖,𝑙)
log 𝑝 x 𝑖 |𝑔 𝜃(𝑧(𝑖, 𝑙)) ≈ log 𝑝 x 𝑖 |𝑔 𝜃(𝑧(𝑖))
monte-carlo technique 𝐿 = 1
argmin
𝟏
𝑵
σ𝒊=𝟏
𝑵
𝑳 𝜽, 𝝓; 𝐱 𝒊
=
𝟏
𝑵
σ𝒊=𝟏
𝑵
−𝑬
𝒒 𝝓 𝒛 𝐱 𝒊 𝒍𝒐𝒈 𝒑 𝐱 𝒊
𝒈 𝜽 + 𝑲𝑳 𝒒 𝝓 𝒛 𝐱(𝒊)
∥ 𝒑 𝒛
𝝓, 𝜽
𝐷
𝐷
𝑧(𝑖)
𝐽
Structure 1 - Bernoulli
𝑔 𝜃(∙)𝐱 𝒊 𝑞 𝜙(∙)
𝜇𝑖
𝜎𝑖
𝜖𝑖𝑁 0, 1
Sampling
Reparameterization Trick
𝑧(𝑖)
⊕
⊗
𝐷 𝐽
𝑝𝑖
argmin
𝟏
𝑵
σ𝒊=𝟏
𝑵
𝑳 𝜽, 𝝓; 𝐱 𝒊
=
𝟏
𝑵
σ𝒊=𝟏
𝑵 σ 𝑗=1
𝐷
x 𝑖,𝑗
log 𝑝𝑖,𝑗 + 1 − x 𝑖,𝑗
log 1 − 𝑝𝑖,𝑗 +
1
2
σ 𝑗=1
𝐽
𝜇𝑖,𝑗
2
+ 𝜎𝑖,𝑗
2
− ln 𝜎𝑖,𝑗
2
− 1
𝝓, 𝜽
𝑔 𝜃(∙)
𝜇𝑖
𝜎𝑖
𝐱 𝒊
𝑞 𝜙(∙)
𝜇𝑖
𝜎𝑖
𝜎𝑖𝑁 0, 1
Sampling
Reparameterization Trick
𝑧(𝑖)
⊕
⊗
𝐷
𝐽
argmin
𝟏
𝑵
σ𝒊=𝟏
𝑵
𝑳 𝜽, 𝝓; 𝐱 𝒊
=
𝟏
𝑵
σ𝒊=𝟏
𝑵 σ 𝑗=1
𝐷 1
2
log 𝜎𝑖,𝑗
2
+
x(𝑖,𝑗)−𝜇 𝑖,𝑗
2
2𝜎𝑖,𝑗
2 +
1
2
σ 𝑗=1
𝐽
𝜇𝑖,𝑗
2
+ 𝜎𝑖,𝑗
2
− ln 𝜎𝑖,𝑗
2
− 1
𝝓, 𝜽
Structure 2 – Gaussian1
𝑔 𝜃(∙) 𝜇𝑖
𝑞 𝜙(∙)
𝜇𝑖
𝜎𝑖
𝜎𝑖𝑁 0, 1
Sampling
Reparameterization Trick
⊕
⊗
𝐷
𝐽
argmin
𝟏
𝑵
σ𝒊=𝟏
𝑵
𝑳 𝜽, 𝝓; 𝐱 𝒊
=
𝟏
𝑵
σ𝒊=𝟏
𝑵 σ 𝑗=1
𝐷
x 𝑖,𝑗
− 𝜇𝑖,𝑗
2
+
1
2
σ 𝑗=1
𝐽
𝜇𝑖,𝑗
2
+ 𝜎𝑖,𝑗
2
− ln 𝜎𝑖,𝑗
2
− 1
𝝓, 𝜽
Structure 3 – Gaussian2
𝐱 𝒊
𝑧(𝑖)
Tensorflow – VAE(1)
1. inference
Tensorflow – VAE(2)
2. generator
Tensorflow – VAE(3)
3. _build_net
reparameterization trick
Tensorflow – VAE(4)
4.result
Tensorflow – VAE(5)
5. generated image plotting
dim_z=2로 설정하여
2차원 [-1.5, 1.5] × [-1.5, 1.5] domain의
각 점에 대하여 생성된 숫자 이미지 plot
Tensorflow – VAE(6)
real image recontructed image generated image

Más contenido relacionado

La actualidad más candente

0131 1 spectral_theorem_transformation
0131 1 spectral_theorem_transformation0131 1 spectral_theorem_transformation
0131 1 spectral_theorem_transformationJeonghun Yoon
 
Neural network (perceptron)
Neural network (perceptron)Neural network (perceptron)
Neural network (perceptron)Jeonghun Yoon
 
04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )Jeonghun Yoon
 
0124 1 linear_algebra_basic_vector
0124 1 linear_algebra_basic_vector0124 1 linear_algebra_basic_vector
0124 1 linear_algebra_basic_vectorJeonghun Yoon
 
0307 1 estimation_theory
0307 1 estimation_theory0307 1 estimation_theory
0307 1 estimation_theoryJeonghun Yoon
 
선형대수 02. 가우스 소거법
선형대수 02. 가우스 소거법선형대수 02. 가우스 소거법
선형대수 02. 가우스 소거법AHRA CHO
 
08. spectal clustering
08. spectal clustering08. spectal clustering
08. spectal clusteringJeonghun Yoon
 
Wasserstein GAN 수학 이해하기 I
Wasserstein GAN 수학 이해하기 IWasserstein GAN 수학 이해하기 I
Wasserstein GAN 수학 이해하기 ISungbin Lim
 
Dsh data sensitive hashing for high dimensional k-nn search
Dsh  data sensitive hashing for high dimensional k-nn searchDsh  data sensitive hashing for high dimensional k-nn search
Dsh data sensitive hashing for high dimensional k-nn searchWooSung Choi
 
Closest pair problem with randomization
Closest pair problem with randomizationClosest pair problem with randomization
Closest pair problem with randomizationChangki Yun
 
선형대수 06. 영벡터공간과 해집합
선형대수 06. 영벡터공간과 해집합선형대수 06. 영벡터공간과 해집합
선형대수 06. 영벡터공간과 해집합AHRA CHO
 
[Probability for machine learning]
[Probability for machine learning][Probability for machine learning]
[Probability for machine learning]강민국 강민국
 
선형대수 04. Inverse and Transpose
선형대수 04. Inverse and Transpose선형대수 04. Inverse and Transpose
선형대수 04. Inverse and TransposeAHRA CHO
 
선형대수 03. LU Decomposition
선형대수 03. LU Decomposition선형대수 03. LU Decomposition
선형대수 03. LU DecompositionAHRA CHO
 
Ensemble Model (Hybrid model)
Ensemble Model (Hybrid model)Ensemble Model (Hybrid model)
Ensemble Model (Hybrid model)Jeonghun Yoon
 
[아꿈사] 게임 기초 수학 물리 1,2장
[아꿈사] 게임 기초 수학 물리 1,2장[아꿈사] 게임 기초 수학 물리 1,2장
[아꿈사] 게임 기초 수학 물리 1,2장sung ki choi
 
0228 2 sample_distribution
0228 2 sample_distribution0228 2 sample_distribution
0228 2 sample_distributionJeonghun Yoon
 

La actualidad más candente (19)

0131 1 spectral_theorem_transformation
0131 1 spectral_theorem_transformation0131 1 spectral_theorem_transformation
0131 1 spectral_theorem_transformation
 
Neural network (perceptron)
Neural network (perceptron)Neural network (perceptron)
Neural network (perceptron)
 
04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )
 
0124 1 linear_algebra_basic_vector
0124 1 linear_algebra_basic_vector0124 1 linear_algebra_basic_vector
0124 1 linear_algebra_basic_vector
 
0307 1 estimation_theory
0307 1 estimation_theory0307 1 estimation_theory
0307 1 estimation_theory
 
선형대수 02. 가우스 소거법
선형대수 02. 가우스 소거법선형대수 02. 가우스 소거법
선형대수 02. 가우스 소거법
 
08. spectal clustering
08. spectal clustering08. spectal clustering
08. spectal clustering
 
Linear algebra
Linear algebraLinear algebra
Linear algebra
 
Wasserstein GAN 수학 이해하기 I
Wasserstein GAN 수학 이해하기 IWasserstein GAN 수학 이해하기 I
Wasserstein GAN 수학 이해하기 I
 
Dsh data sensitive hashing for high dimensional k-nn search
Dsh  data sensitive hashing for high dimensional k-nn searchDsh  data sensitive hashing for high dimensional k-nn search
Dsh data sensitive hashing for high dimensional k-nn search
 
Closest pair problem with randomization
Closest pair problem with randomizationClosest pair problem with randomization
Closest pair problem with randomization
 
선형대수 06. 영벡터공간과 해집합
선형대수 06. 영벡터공간과 해집합선형대수 06. 영벡터공간과 해집합
선형대수 06. 영벡터공간과 해집합
 
[Probability for machine learning]
[Probability for machine learning][Probability for machine learning]
[Probability for machine learning]
 
선형대수 04. Inverse and Transpose
선형대수 04. Inverse and Transpose선형대수 04. Inverse and Transpose
선형대수 04. Inverse and Transpose
 
선형대수 03. LU Decomposition
선형대수 03. LU Decomposition선형대수 03. LU Decomposition
선형대수 03. LU Decomposition
 
Ensemble Model (Hybrid model)
Ensemble Model (Hybrid model)Ensemble Model (Hybrid model)
Ensemble Model (Hybrid model)
 
0207 1 gradient
0207 1 gradient0207 1 gradient
0207 1 gradient
 
[아꿈사] 게임 기초 수학 물리 1,2장
[아꿈사] 게임 기초 수학 물리 1,2장[아꿈사] 게임 기초 수학 물리 1,2장
[아꿈사] 게임 기초 수학 물리 1,2장
 
0228 2 sample_distribution
0228 2 sample_distribution0228 2 sample_distribution
0228 2 sample_distribution
 

Similar a Vae

Auto-Encoders and Variational Auto-Encoders
Auto-Encoders and Variational Auto-EncodersAuto-Encoders and Variational Auto-Encoders
Auto-Encoders and Variational Auto-EncodersJinho Lee
 
Variational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial ModelVariational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial ModelSEMINARGROOT
 
RLCode와 A3C 쉽고 깊게 이해하기
RLCode와 A3C 쉽고 깊게 이해하기RLCode와 A3C 쉽고 깊게 이해하기
RLCode와 A3C 쉽고 깊게 이해하기Woong won Lee
 
Linear algebra.pptx
Linear algebra.pptxLinear algebra.pptx
Linear algebra.pptxGeonWooYoo1
 
개념 이해가 쉬운 Variational Autoencoder (VAE)
개념 이해가 쉬운 Variational Autoencoder (VAE)개념 이해가 쉬운 Variational Autoencoder (VAE)
개념 이해가 쉬운 Variational Autoencoder (VAE)jaypi Ko
 
03. linear regression
03. linear regression03. linear regression
03. linear regressionJeonghun Yoon
 
Deep learning study 1
Deep learning study 1Deep learning study 1
Deep learning study 1San Kim
 
Linear regression
Linear regressionLinear regression
Linear regression전 희천
 
Eigendecomposition and pca
Eigendecomposition and pcaEigendecomposition and pca
Eigendecomposition and pcaJinhwan Suk
 
Multinomial classification and application of ML
Multinomial classification and application of MLMultinomial classification and application of ML
Multinomial classification and application of ML희수 박
 
선형대수 08. 선형 변환 (Linear Transformation)
선형대수 08. 선형 변환 (Linear Transformation)선형대수 08. 선형 변환 (Linear Transformation)
선형대수 08. 선형 변환 (Linear Transformation)AHRA CHO
 
02.09 naive bayesian classifier
02.09 naive bayesian classifier02.09 naive bayesian classifier
02.09 naive bayesian classifierDea-hwan Ki
 
Lecture 2: Supervised Learning
Lecture 2: Supervised LearningLecture 2: Supervised Learning
Lecture 2: Supervised LearningSang Jun Lee
 
선형대수 12강 Gram-Schmidt Orthogonalization
선형대수 12강 Gram-Schmidt Orthogonalization선형대수 12강 Gram-Schmidt Orthogonalization
선형대수 12강 Gram-Schmidt OrthogonalizationAHRA CHO
 
Deep Learning from scratch 5장 : backpropagation
 Deep Learning from scratch 5장 : backpropagation Deep Learning from scratch 5장 : backpropagation
Deep Learning from scratch 5장 : backpropagationJinSooKim80
 
해커에게 전해들은 머신러닝 #3
해커에게 전해들은 머신러닝 #3해커에게 전해들은 머신러닝 #3
해커에게 전해들은 머신러닝 #3Haesun Park
 
Q Learning과 CNN을 이용한 Object Localization
Q Learning과 CNN을 이용한 Object LocalizationQ Learning과 CNN을 이용한 Object Localization
Q Learning과 CNN을 이용한 Object Localization홍배 김
 
13.상관과 회귀
13.상관과 회귀13.상관과 회귀
13.상관과 회귀Yoonwhan Lee
 
Code로 이해하는 RNN
Code로 이해하는 RNNCode로 이해하는 RNN
Code로 이해하는 RNNSANG WON PARK
 

Similar a Vae (20)

Auto-Encoders and Variational Auto-Encoders
Auto-Encoders and Variational Auto-EncodersAuto-Encoders and Variational Auto-Encoders
Auto-Encoders and Variational Auto-Encoders
 
Variational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial ModelVariational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial Model
 
RLCode와 A3C 쉽고 깊게 이해하기
RLCode와 A3C 쉽고 깊게 이해하기RLCode와 A3C 쉽고 깊게 이해하기
RLCode와 A3C 쉽고 깊게 이해하기
 
Linear algebra.pptx
Linear algebra.pptxLinear algebra.pptx
Linear algebra.pptx
 
개념 이해가 쉬운 Variational Autoencoder (VAE)
개념 이해가 쉬운 Variational Autoencoder (VAE)개념 이해가 쉬운 Variational Autoencoder (VAE)
개념 이해가 쉬운 Variational Autoencoder (VAE)
 
03. linear regression
03. linear regression03. linear regression
03. linear regression
 
Deep learning study 1
Deep learning study 1Deep learning study 1
Deep learning study 1
 
Linear regression
Linear regressionLinear regression
Linear regression
 
Eigendecomposition and pca
Eigendecomposition and pcaEigendecomposition and pca
Eigendecomposition and pca
 
Multinomial classification and application of ML
Multinomial classification and application of MLMultinomial classification and application of ML
Multinomial classification and application of ML
 
선형대수 08. 선형 변환 (Linear Transformation)
선형대수 08. 선형 변환 (Linear Transformation)선형대수 08. 선형 변환 (Linear Transformation)
선형대수 08. 선형 변환 (Linear Transformation)
 
02.09 naive bayesian classifier
02.09 naive bayesian classifier02.09 naive bayesian classifier
02.09 naive bayesian classifier
 
Lecture 2: Supervised Learning
Lecture 2: Supervised LearningLecture 2: Supervised Learning
Lecture 2: Supervised Learning
 
선형대수 12강 Gram-Schmidt Orthogonalization
선형대수 12강 Gram-Schmidt Orthogonalization선형대수 12강 Gram-Schmidt Orthogonalization
선형대수 12강 Gram-Schmidt Orthogonalization
 
Deep Learning from scratch 5장 : backpropagation
 Deep Learning from scratch 5장 : backpropagation Deep Learning from scratch 5장 : backpropagation
Deep Learning from scratch 5장 : backpropagation
 
해커에게 전해들은 머신러닝 #3
해커에게 전해들은 머신러닝 #3해커에게 전해들은 머신러닝 #3
해커에게 전해들은 머신러닝 #3
 
Q Learning과 CNN을 이용한 Object Localization
Q Learning과 CNN을 이용한 Object LocalizationQ Learning과 CNN을 이용한 Object Localization
Q Learning과 CNN을 이용한 Object Localization
 
13.상관과 회귀
13.상관과 회귀13.상관과 회귀
13.상관과 회귀
 
Number theory
Number theoryNumber theory
Number theory
 
Code로 이해하는 RNN
Code로 이해하는 RNNCode로 이해하는 RNN
Code로 이해하는 RNN
 

Más de Lee Gyeong Hoon

Más de Lee Gyeong Hoon (8)

Nlp study1
Nlp study1Nlp study1
Nlp study1
 
Mylab
MylabMylab
Mylab
 
Gan
GanGan
Gan
 
Svmtf
SvmtfSvmtf
Svmtf
 
The fastalgorithmfordeepbeliefnets
The fastalgorithmfordeepbeliefnetsThe fastalgorithmfordeepbeliefnets
The fastalgorithmfordeepbeliefnets
 
Convolutional rnn
Convolutional rnnConvolutional rnn
Convolutional rnn
 
세미나 20170929
세미나 20170929세미나 20170929
세미나 20170929
 
Where to Apply Dropout in Recurrent Neural Networks for Handwriting Recognition?
Where to Apply Dropout in Recurrent Neural Networks for Handwriting Recognition?Where to Apply Dropout in Recurrent Neural Networks for Handwriting Recognition?
Where to Apply Dropout in Recurrent Neural Networks for Handwriting Recognition?
 

Último

실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석JMP Korea
 
데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법JMP Korea
 
공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화JMP Korea
 
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?Jay Park
 
JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!JMP Korea
 
JMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement MethodologyJMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement MethodologyJMP Korea
 
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개JMP Korea
 
JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례JMP Korea
 

Último (8)

실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
 
데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법
 
공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화
 
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
 
JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!
 
JMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement MethodologyJMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
 
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
 
JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례
 

Vae

  • 1. Auto-Encoding Variational Bayes Diederik P. Kingma, Max Welling, 2014
  • 2. Motivation – generative model Trainig samples Density Estimation 𝑝 𝑥 Ƹ𝑝(𝑥) Sampling
  • 3. Problem scenario - Latent Variable Model 𝑧 x Generator 𝑔 𝜃(∙) step1 : a value 𝑧(𝑖) is generated from some prior distribution 𝑝(𝑧) (normal or uniform) step2 : a value x(𝑖) is generated from some contional distribution 𝑝(x|𝑔 𝜃∗(𝑧)) • X = x(𝑖) 𝑖=1 𝑁 • x • 𝑧 • 𝑝(∙) • 𝑔 𝜃 ∙ 𝑔: 𝑍 × Θ → 𝜒 • 𝑔 𝑧; 𝜃 = 𝑔 𝜃 𝑧 • 𝑝 x 𝑔 𝜃 𝑧 = 𝑝 𝜃(x|𝑧) continuous random variable in space 𝑍 a deterministic function parameterized by 𝜃 in some space Θ random variable in the space 𝜒 dataset likelihood random variable pdf of 𝑧 , 𝜒 is some space Goal : maximize 𝑝 X = ‫׬‬ 𝑝 X|𝑔 𝜃 𝑧 𝑝 𝑧 𝑑𝑧 !!! In VAEs, this output distribution is often istropic gaussian i.e. 𝑝 X 𝑔 𝜃 𝑧 = 𝑁(X|𝑔 𝜃 𝑧 , 𝜎2 𝐼) (Tutorial on VAEs, 3page)
  • 4. Problem1 - 𝑝 𝜃 𝑥 𝑧 • 𝑝 x = ‫׬‬ 𝑝 x|𝑔 𝜃 𝑧 𝑝 𝑧 𝑑𝑧 the integral of the marginal likelihood → ‫׬‬ 𝑝 x|𝑔 𝜃 𝑧 𝑝 𝑧 𝑑𝑧 is intractable Solution • Bad solution 임의의 prior distribution에서 𝑧를 샘플링하여 likelihood가 커지도록 𝜃를 조절하는 방법 → 원하는 결과를 얻지 못함. 데이터 셋의 분포를 추정하기 어려움 • Good solution 𝑝 z|x 에서 𝑧를 샘플링하여 likelihood가 커지도록 𝜃를 조절하는 방법 → 𝑝 z|x = 𝑝 x 𝑧 𝑝(𝑧) 𝑝(x) is intractable → Variational Inference 방법을 이용하여 해결
  • 5. Problem2 - Sampling • 𝑧를 샘플링 해야한다 𝑧 𝑖~𝑁 𝜇𝑖, 𝜎𝑖 2 𝐼 • 샘플링을 하면 gradient descent 방법을 사용할 수 없다. • Reparameterization trick • backpropagation 계산이 가능한 방법으로 대체한다. 𝑧 𝑖 = 𝜇𝑖 + 𝜎𝑖 2 ⨀𝜖, 𝜖~𝑁(0, 𝐼) Solution
  • 6. Bad Solution – maximum likelihood estimation directly step1 : 𝑝(𝑧)에서 데이터 𝑛개를 샘플링한다. 𝑧(1) , ⋯ , 𝑧(2) step2 : 𝑝(x) ≈ σ𝑖=1 𝑛 𝑝 x 𝑔 𝜃 𝑧(𝑖) 𝑝 𝑧(𝑖) * 단, 𝑥의 차원이 크면 𝑛도 커야 한다. step3 : 𝑝 𝑥 𝑔 𝜃 𝑧 를 Isotropic Gaussian(𝑁(𝑥|𝑔 𝜃 𝑧 , 𝜎2 𝐼))으로 가정하면, -log 𝑝 𝑥 𝑔 𝜃 𝑧 는 𝑔 𝜃 𝑧 와 𝑥의 Euclidian distance와 비례관계 * MSE를 목적함수로 학습 문제점 x − 𝑔 𝜃 𝑧(𝑏) 2 < x − 𝑔 𝜃 𝑧(𝑐) 2 → 𝑝(x|𝑔 𝜃 𝑧(𝑏) ) > 𝑝(x|𝑔 𝜃 𝑧(𝑐) ) (c)의 샘플로 생성된 이미지가 의미적으로 (a)에 더 비슷하지만, MSE관점에서는 (b)의 샘플이 𝑝(x)에 기여하는 바가 더 크다. * 올바른 학습이 어려움
  • 7. Good Solution – Variational inference • 𝑧를 임의의 정규분포로부터 샘플링하는 것은 Bad Solution → x와 의미적으로 유사한 샘플을 얻기 위하여 𝑝(𝑧|x)로 부터 샘플링 → 𝑝(𝑧|x)를 알 수 없음 → 해석하기 쉬운 확률 분포 중 하나(𝑞 𝜙(𝑧|𝑥))를 택하고, 𝜙 값을 조정하여 𝑝(𝑧|𝑥)와 유사하게 만들자. * Variational Inference → 𝑞 𝜙(𝑧|𝑥) 분포로부터 𝑧를 샘플링 • 요약 1. 데이터 셋과 유사한 이미지를 생성하자 2. 𝑔 𝜃(∙)와 𝑧를 이용해서 생성하자 3. 𝑧는 쉬운 확률 분포(정규분포) 에서 샘플링하자 4. 데이터셋과 의미적으로 유사한 샘플을 얻을 수 있도록 𝑧를 𝑝(𝑧|x)에서 샘플링하자 5. 𝑝(𝑧|x)를 구하기 어렵다 6. 쉬운 확률 분포 𝑞 𝜙(𝑧|x)를 택하고 𝑝(𝑧|x)에 근사하게 파라미터를 조절하자. 7. 𝑞 𝜙(𝑧|x) 분포로부터 𝑧를 샘플링하자
  • 8. Variational inference – ELBO : Evidence Lower BOund • Relationship among 𝑝(𝑥), 𝑝(𝑧|𝑥), 𝑞 𝜙(𝑧|𝑥) : Derivation 1 log 𝑝(x) Jensen’s Ineuqality, log(∙) is concave = log න 𝑝 x 𝑧 𝑝 𝑧 𝑞 𝜙 𝑧 x 𝑞 𝜙 𝑧 x 𝑑𝑧 ≥ න log 𝑝 x 𝑧 𝑝 𝑧 𝑞 𝜙 𝑧 x 𝑞 𝜙 𝑧 x 𝑑𝑧 = log න 𝑝 x 𝑧 𝑝(𝑧) 𝑑𝑧 log 𝑝(x) ≥ න log 𝑝 x 𝑧 𝑞 𝜙 𝑧 x 𝑑𝑧 − න log 𝑞 𝜙 𝑧 x 𝑝 𝑧 𝑞 𝜙 𝑧 x 𝑑𝑧 = 𝐸 𝑞 𝜙(𝑧|x) log 𝑝(x|𝑧) − 𝐾𝐿(𝑞 𝜙 𝑧 x ∥ 𝑝 𝑧 ) 𝐸𝐿𝐵𝑂(𝜙)
  • 9. Variational inference – ELBO : Evidence Lower BOund • Relationship among 𝑝(x), 𝑝(𝑧|x), 𝑞 𝜙(𝑧|x) : Derivation 2 log 𝑝(x) = න log 𝑝 x 𝑞 𝜙 𝑧 x 𝑑𝑧 = න log 𝑝 x, 𝑧 𝑝 𝑧 x 𝑞 𝜙(𝑧|x) = න log 𝑝 x, 𝑧 𝑞 𝜙 𝑧 x ∙ 𝑞 𝜙 𝑧 x 𝑝 𝑧 x 𝑞 𝜙 𝑧 x 𝑑𝑧 = න log 𝑝 x, 𝑧 𝑞 𝜙 𝑧 x 𝑞 𝜙 𝑧 x 𝑑𝑧 + න log 𝑞 𝜙 𝑧 x 𝑝 𝑧 x 𝑞 𝜙 𝑧 x 𝑑𝑧 𝐸𝐿𝐵𝑂(𝜙) 𝐾𝐿 𝑞 𝜙 𝑧 x ∥ 𝑝 𝑧 x 𝐾𝐿을 최소화하는 𝑞 𝜙 𝑧 x 의 𝜙값을 구하면 된다. 𝑝 𝑧 x 를 알 수 없기 때문에 𝐾𝐿을 최소화하는 대신 ELBO를 최대화하는 𝜙값을 찾는다. න 𝑞 𝜙 𝑧 x 𝑑𝑧 = 1
  • 10. Variational inference – ELBO : Evidence Lower BOund • Relationship among 𝑝(x), 𝑝(𝑧|x), 𝑞 𝜙(𝑧|x) : Derivation 2 log 𝑝(x) = 𝐸𝐿𝐵𝑂 𝜙 + 𝐾𝐿 𝑞 𝜙 𝑧 x ∥ 𝑝 𝑧 x Goal : argmax 𝜙 𝐸𝐿𝐵𝑂(𝜙) 𝐸𝐿𝐵𝑂 𝜙 = න log 𝑝 x, 𝑧 𝑞 𝜙 𝑧 x 𝑞 𝜙 𝑧 x 𝑑𝑧 = න log 𝑝 x|𝑧 𝑝(𝑧) 𝑞 𝜙 𝑧 x 𝑞 𝜙 𝑧 x 𝑑𝑧 = න log 𝑝(x|𝑧) 𝑞 𝜙 𝑧 x 𝑑𝑧 − න log 𝑞 𝜙 𝑧 x 𝑝 𝑧 𝑞 𝜙 𝑧 x 𝑑𝑧 = 𝐸 𝑞 𝜙(𝑧|x) log 𝑝(x|𝑧) − 𝐾𝐿(𝑞 𝜙(𝑧|x) ∥ 𝑝(𝑧)) log 𝑝(x) ≥ 𝐸 𝑞 𝜙(𝑧|x) log 𝑝(x|𝑧) − 𝐾𝐿(𝑞 𝜙(𝑧|x) ∥ 𝑝(𝑧))
  • 11. Loss function • log 𝑝(x) ≥ 𝐸 𝑞 𝜙(𝑧|x) log 𝑝(x|𝑧) − 𝐾𝐿(𝑞 𝜙(𝑧|x) ∥ 𝑝(𝑧)) • log 𝑝(x|𝑔 𝜃(𝑧)) ≥ 𝐸 𝑞 𝜙(𝑧|x) log 𝑝(x|𝑔 𝜃(𝑧)) − 𝐾𝐿(𝑞 𝜙(𝑧|x) ∥ 𝑝(𝑧)) 𝑝 x = න 𝑝 x|𝑔 𝜃 𝑧 𝑝 𝑧 𝑑𝑧 • for data x(𝑖), 𝑳 𝜽, 𝝓; 𝐱 𝒊 = −𝑬 𝒒 𝝓 𝒛 𝐱 𝒊 𝐥𝐨𝐠 𝒑 𝐱 𝒊 𝒈 𝜽(𝒛) + 𝑲𝑳 𝒒 𝝓 𝒛 𝐱(𝒊) ∥ 𝒑 𝒛 Note. 논문의 3번 식과 부호가 다르다. 논문에서의 L은 lower bound의 의미, ppt에서의 L은 loss의 의미. 논문의 lower bound를 최대화하는 것은 ppt의 loss를 최소화하는 것과 동일.
  • 12. Objective function 𝑧 x Generator 𝑔 𝜃(∙) x Inference 𝑞 𝜙(∙) ~ Sampling argmin 1 𝑁 σ𝑖=1 𝑁 𝐿 𝜃, 𝜙; x 𝑖 = 1 𝑁 σ𝑖=1 𝑁 −𝐸 𝑞 𝜙 𝑧 x 𝑖 log 𝑝 x 𝑖 𝑔 𝜃 + 𝐾𝐿 𝑞 𝜙 𝑧 x(𝑖) ∥ 𝑝 𝑧 𝜙, 𝜃
  • 13. Encoder – 𝐾𝐿 divergence x(𝑖) 𝑞 𝜙(𝑧|x(𝑖)) 𝜇𝑖 𝜎𝑖 Assumption 1 Isotropic gaussian distribution 𝑞 𝜙 𝑧 𝑥𝑖 ~ 𝑁(𝜇𝑖, 𝜎𝑖 2 𝐼) Asuumption 2 Gaussian distribution 𝑝(𝑧) ~ 𝑁 0, 𝐼 𝐾𝐿 𝑞 𝜙 𝑧 x(𝑖) ∥ 𝑝 𝑧 = 1 2 𝑡𝑟 𝜎𝑖 2 𝐼 + 𝜇𝑖 𝑇 𝜇𝑖 − 𝐽 + ln 1 ς 𝑗=1 𝐽 𝜎𝑖,𝑗 2 = 1 2 ෍ 𝑗=1 𝐽 𝜎𝑖,𝑗 2 + ෍ 𝑗=1 𝐽 𝜇𝑖,𝑗 2 − 𝐽 − ෍ 𝑗=1 𝐽 ln 𝜎𝑖,𝑗 2 = 1 2 ෍ 𝑗=1 𝐽 𝜇𝑖,𝑗 2 + 𝜎𝑖,𝑗 2 − ln 𝜎𝑖,𝑗 2 − 1 The Kullback-Leibler divergence from 𝑁0(𝜇0, Σ0) to 𝑁1(𝜇1, Σ1) for non-singular matrices Σ0 and Σ1 is 𝐾𝐿 𝑁0 ∥ 𝑁1 = 1 2 𝑡𝑟 Σ1 −1 Σ0 + 𝜇1 − 𝜇0 𝑇Σ1 −1 𝜇1 − 𝜇0 − 𝑘 + ln Σ1 Σ0 , where 𝑘 is the dimension of the vector space argmin 𝟏 𝑵 σ𝒊=𝟏 𝑵 𝑳 𝜽, 𝝓; 𝐱 𝒊 = 𝟏 𝑵 σ𝒊=𝟏 𝑵 −𝑬 𝒒 𝝓 𝒛 𝐱 𝒊 𝒍𝒐𝒈 𝒑 𝐱 𝒊 𝒈 𝜽 + 𝑲𝑳 𝒒 𝝓 𝒛 𝐱(𝒊) ∥ 𝒑 𝒛 𝝓, 𝜽 𝐷 𝐽 𝐽
  • 14. Encoder – reparameterised trick 𝐸 𝑞 𝜙 𝑧 x 𝑖 log 𝑝 x 𝑖 |𝑔 𝜃(𝑧) = න log 𝑝 x 𝑖 |𝑔 𝜃(𝑧) 𝑞 𝜙 𝑧 x 𝑖 𝑑𝑧 ≈ 1 𝐿 σ 𝑧(𝑖,𝑙) log 𝑝 x 𝑖 |𝑔 𝜃(𝑧(𝑖, 𝑙)) monte-carlo technique 𝑧 𝑖, 𝑗~𝑁 𝜇𝑖, 𝜎𝑖 2 𝐼 𝑧 𝑖, 𝑗 = 𝜇𝑖 + 𝜎𝑖 2 ⨀𝜖, 𝜖~𝑁(0, 𝐼) argmin 𝟏 𝑵 σ𝒊=𝟏 𝑵 𝑳 𝜽, 𝝓; 𝐱 𝒊 = 𝟏 𝑵 σ𝒊=𝟏 𝑵 −𝑬 𝒒 𝝓 𝒛 𝐱 𝒊 𝒍𝒐𝒈 𝒑 𝐱 𝒊 𝒈 𝜽 + 𝑲𝑳 𝒒 𝝓 𝒛 𝐱(𝒊) ∥ 𝒑 𝒛 𝝓, 𝜽 x(𝑖) 𝑞 𝜙(𝑧|x(𝑖)) 𝜇𝑖 𝜎𝑖 𝐷 𝐽 𝐽
  • 15. Decoder – likelihood (Bernoulli) 𝐸 𝑞 𝜙 𝑧 x 𝑖 log 𝑝 x 𝑖 |𝑔 𝜃(𝑧) = න log 𝑝 x 𝑖 |𝑔 𝜃(𝑧) 𝑞 𝜙 𝑧 x 𝑖 𝑑𝑧 ≈ 1 𝐿 ෍ 𝑧(𝑖,𝑙) log 𝑝 x 𝑖 |𝑔 𝜃(𝑧(𝑖, 𝑙)) ≈ log 𝑝 x 𝑖 |𝑔 𝜃(𝑧(𝑖)) monte-carlo technique 𝐿 = 1 log 𝑝 𝜃 x 𝑖 |𝑧 𝑖 = log ෑ 𝑗=1 𝐷 𝑝 𝜃 x 𝑖,𝑗 |𝑧(𝑖) = ෍ 𝑗=1 𝐷 log 𝑝 𝜃 x 𝑖,𝑗 |𝑧(𝑖) 𝑝 𝜃 x(𝑖)|𝑔 𝜃(𝑧(𝑖)) ~𝐵𝑒𝑟𝑛𝑜𝑢𝑙𝑙𝑖(𝑝𝑖) = ෍ 𝑗=1 𝐷 log 𝑝𝑖,𝑗 x 𝑖,𝑗 1 − 𝑝𝑖,𝑗 1−x 𝑖,𝑗 = ෍ 𝑗=1 𝐷 x 𝑖,𝑗 log 𝑝𝑖,𝑗 + 1 − x 𝑖,𝑗 log 1 − 𝑝𝑖,𝑗 𝑝𝑖𝑧(𝑖) 𝐷 𝐽 argmin 𝟏 𝑵 σ𝒊=𝟏 𝑵 𝑳 𝜽, 𝝓; 𝐱 𝒊 = 𝟏 𝑵 σ𝒊=𝟏 𝑵 −𝑬 𝒒 𝝓 𝒛 𝐱 𝒊 𝒍𝒐𝒈 𝒑 𝐱 𝒊 𝒈 𝜽 + 𝑲𝑳 𝒒 𝝓 𝒛 𝐱(𝒊) ∥ 𝒑 𝒛 𝝓, 𝜽 𝑔 𝜃(∙) cross entropy
  • 16. Decoder – likelihood (Gaussian) 𝑔 𝜃(∙) log 𝑝 𝜃 x 𝑖 |𝑧(𝑖) = log 𝑁 x 𝑖 ; 𝜇𝑖, 𝜎𝑖 2 𝐼 = − ෍ 𝑗=1 𝐷 1 2 log 𝜎𝑖,𝑗 2 + x 𝑖,𝑗 − 𝜇𝑖,𝑗 2 2𝜎𝑖,𝑗 2 log 𝑝 𝜃 x 𝑖 |𝑧(𝑖) ∝ − ෍ 𝑗=1 𝐷 x 𝑖,𝑗 − 𝜇𝑖,𝑗 2 𝜇𝑖 𝜎𝑖 𝐸 𝑞 𝜙 𝑧 x 𝑖 log 𝑝 x 𝑖 |𝑔 𝜃(𝑧) = න log 𝑝 x 𝑖 |𝑔 𝜃(𝑧) 𝑞 𝜙 𝑧 x 𝑖 𝑑𝑧 ≈ 1 𝐿 ෍ 𝑧(𝑖,𝑙) log 𝑝 x 𝑖 |𝑔 𝜃(𝑧(𝑖, 𝑙)) ≈ log 𝑝 x 𝑖 |𝑔 𝜃(𝑧(𝑖)) monte-carlo technique 𝐿 = 1 argmin 𝟏 𝑵 σ𝒊=𝟏 𝑵 𝑳 𝜽, 𝝓; 𝐱 𝒊 = 𝟏 𝑵 σ𝒊=𝟏 𝑵 −𝑬 𝒒 𝝓 𝒛 𝐱 𝒊 𝒍𝒐𝒈 𝒑 𝐱 𝒊 𝒈 𝜽 + 𝑲𝑳 𝒒 𝝓 𝒛 𝐱(𝒊) ∥ 𝒑 𝒛 𝝓, 𝜽 𝐷 𝐷 𝑧(𝑖) 𝐽
  • 17. Structure 1 - Bernoulli 𝑔 𝜃(∙)𝐱 𝒊 𝑞 𝜙(∙) 𝜇𝑖 𝜎𝑖 𝜖𝑖𝑁 0, 1 Sampling Reparameterization Trick 𝑧(𝑖) ⊕ ⊗ 𝐷 𝐽 𝑝𝑖 argmin 𝟏 𝑵 σ𝒊=𝟏 𝑵 𝑳 𝜽, 𝝓; 𝐱 𝒊 = 𝟏 𝑵 σ𝒊=𝟏 𝑵 σ 𝑗=1 𝐷 x 𝑖,𝑗 log 𝑝𝑖,𝑗 + 1 − x 𝑖,𝑗 log 1 − 𝑝𝑖,𝑗 + 1 2 σ 𝑗=1 𝐽 𝜇𝑖,𝑗 2 + 𝜎𝑖,𝑗 2 − ln 𝜎𝑖,𝑗 2 − 1 𝝓, 𝜽
  • 18. 𝑔 𝜃(∙) 𝜇𝑖 𝜎𝑖 𝐱 𝒊 𝑞 𝜙(∙) 𝜇𝑖 𝜎𝑖 𝜎𝑖𝑁 0, 1 Sampling Reparameterization Trick 𝑧(𝑖) ⊕ ⊗ 𝐷 𝐽 argmin 𝟏 𝑵 σ𝒊=𝟏 𝑵 𝑳 𝜽, 𝝓; 𝐱 𝒊 = 𝟏 𝑵 σ𝒊=𝟏 𝑵 σ 𝑗=1 𝐷 1 2 log 𝜎𝑖,𝑗 2 + x(𝑖,𝑗)−𝜇 𝑖,𝑗 2 2𝜎𝑖,𝑗 2 + 1 2 σ 𝑗=1 𝐽 𝜇𝑖,𝑗 2 + 𝜎𝑖,𝑗 2 − ln 𝜎𝑖,𝑗 2 − 1 𝝓, 𝜽 Structure 2 – Gaussian1
  • 19. 𝑔 𝜃(∙) 𝜇𝑖 𝑞 𝜙(∙) 𝜇𝑖 𝜎𝑖 𝜎𝑖𝑁 0, 1 Sampling Reparameterization Trick ⊕ ⊗ 𝐷 𝐽 argmin 𝟏 𝑵 σ𝒊=𝟏 𝑵 𝑳 𝜽, 𝝓; 𝐱 𝒊 = 𝟏 𝑵 σ𝒊=𝟏 𝑵 σ 𝑗=1 𝐷 x 𝑖,𝑗 − 𝜇𝑖,𝑗 2 + 1 2 σ 𝑗=1 𝐽 𝜇𝑖,𝑗 2 + 𝜎𝑖,𝑗 2 − ln 𝜎𝑖,𝑗 2 − 1 𝝓, 𝜽 Structure 3 – Gaussian2 𝐱 𝒊 𝑧(𝑖)
  • 22. Tensorflow – VAE(3) 3. _build_net reparameterization trick
  • 24. Tensorflow – VAE(5) 5. generated image plotting dim_z=2로 설정하여 2차원 [-1.5, 1.5] × [-1.5, 1.5] domain의 각 점에 대하여 생성된 숫자 이미지 plot
  • 25. Tensorflow – VAE(6) real image recontructed image generated image