Where to Apply Dropout in Recurrent Neural Networks for Handwriting Recognition?
The fastalgorithmfordeepbeliefnets
1. A fast learning algorithm for deep belief nets
Gyeong-hoon Lee
Chungnam National University
e-mail : ghlee0304@cnu.ac.kr
[Data Mining Lab Seminar]
June. 12. 2017
1
2. 1 Introduction
• Learning is difficult in densely-connected, directed belief nets that have many hidden layers,
because it is difficult to infer the conditional distribution of the hidden activities when given a data vector.
• “깊어질 수록 hidden layer 사이의 조건부 확률을 추론하기 어려워진다”는 이 글을 토대로 의미를 파악하기 어렵기 때문에
이 논문 이전에 기존의 neural net이 deep하게 하지 못한 문제점을 살펴본다.
- 이전 층과 다음 층이 서로 함께 학습이 되므로 층이 늘어날수록 고려해야 하는 parameter 즉, weight와 bias의 수가
늘어나게 되어 시간이 많이 걸린다.
- network가 깊어지면 overfitting이 일어날 수 있다.
- deep해질수록 어떤 상태가 converge한 상태인지, 좋은 initialization이 무엇인지에 대한 연구가 부족했다.
• 이 논문에서는 오른쪽과 같은 구조를 사용하고 몇 가지
특징을 가지고 있다고 한다.
- hidden layer가 깊어져도 좋은 parameter를 찾을 수 있는
빠르고 탐욕스러운(greedy) 알고리즘이다.
- 비지도 학습이지만 지도 학습에 적용할 수 있다.
- 이전 layer와 다음 layer의 상태에 의존하는 지역성을 가짐.
3. 2 Complementary priors
• DBN이전의 모델
- Markov Chain Monte Carlo method(Neal, 1992) (MCMC) can be used to sample from the posterior, but they are
typically very time consuming.
[간단한 모델 설명]
Markov Chain : transition rule이 주어진 상태에서, 확률적으로 이전 상태의 정보를 이용하여 다음 상태의 정보를 transition
rule에 의하여 상태 천이를 하는 연결 체인으로 지속 반복하여 stationary distribution을 구하는 것이 목표.
𝑋1 𝑋2
[0.5 0.2 0.3] 0.51 0.22 0.37 = [0.5 0.2 0.3]
0.7 0.2 0.1
0.2 0.3 0.5
0.4 0.2 0.4
transition matrix특정 시점의 상태
MCMC : Markov Chain과 달리, 임의의 stationary distribution을 가정한다. 현재의 상태와 샘플링을 통하여 확률적으로 다음
상태를 할당함으로써 transition rule을 학습하고 이를 반복하여 우리가 찾고자 하는 stationary distribution으로
수렴하도록 하는 알고리즘이다. 하지만, 이것을 deep belief net에 사용하는 경우 너무 계산량이 많아서 느리다.
->이를 제대로 공부하는 것은 시간이 상당히 걸리므로, MCMC의 성질을 가지는 Gibbs Sampling이 어떻게 작동하는지
확인함으로써 마무리 짓는 것으로 한다.
4. 2 Complementary priors
• DBN이전의 모델
- Variational Method(Neal and Hinton, 1998) approximate the true posterior with a more tractable distribution and they
can be used to improve a lower bound on the log probability of the training data.
-> hidden variable들이 visible variable들과 높은 연관성을 가지는 다층 네트워크의 경우, 근사한(approximate)한
distribution이 실제와 차이가 클 경우 학습하는 과정이 향상될 것이라는 것을 보장하지는 않는다. 또한 최대 우도 방법을
이용하는 경우 unbiased된 샘플들을 얻어야 하기는 문제가 생긴다.
- A logistic(sigmoid) belief net (Neal, 1992) is composed of stochastic binary units.
𝑆𝑗
𝑤𝑗𝑖
𝑆𝑖
𝑏𝑖
𝑝𝑖 = 𝑝 𝑠𝑖 = 1 =
1
1 + exp(−𝑏𝑖 − σ 𝑗 𝑠𝑗 𝑤𝑗𝑖)
∆𝑤𝑗𝑖 = 𝜀𝑠𝑗 𝑠𝑖 − 𝑝𝑖
-> 𝜀 는 학습률을 의미하고, 여기서의 학습에서 Gibbs Sampling이
사용된다. 간단하게 학습과정을 살펴보면 임의로 𝑆𝑗 상태를 샘플링 하고
(coin toss 등) (𝑆𝑖는 visible variable로 우리가 이미 값을 알고 있다.)
𝑆𝑗의 상태를 바꾸어 가면서 계속해서 weight를 학습하는 과정이다.
여기서 𝑏𝑖는 1 또는 0의 값을 가진다.
- 이 모델의 경우 하나의 Hidden layer일 때는 각각의 hidden variable들이 독립적이므로 하나의 요소(factorial)가 되지만, 층이
깊어지면, 이전 층의 영향을 받게 되어 이전 층의 가능한 모든 상태를 고려하여야 하는 문제가 생긴다.
5. 2.1 An infinite directed model with tied weights
h0
v0
v1
v2
h1
h2
etc.
𝑊 𝑇
𝑊
𝑊
𝑊 𝑇
𝑊
𝑊 𝑇
2.1의 요지 : An infinite sigmoid belief net that is equivalent to an RBM
1. vi, hj는 각각 같은 사이즈를 가지고, v와 h의 사이즈는 다르다.
2. vi에는 visible variable이 있는 레이어 즉, input으로 사용한 real data가 있는 것을 말한다.
3. 이렇게 구성한 infinite sigmoid의 경우, 하나의 RBM과 동일하며, 이 과정에서 hidden layer에
unbiased된 샘플들을 얻을 수 있다는 것을 증명하였다.
4. 다시 말하면, 아래 그림과 같이 h0에서 k와 j는 서로 독립이고 이전에 받는 영향은 단순하게 v0에
W의 transpose를 곱하여 sigmoid를 취한 값이므로, k와 j는 i를 설명하는 요인(factorial)이 된다.
이것에 대한 자세한 설명은 이해하지 못하였으며, 이러한 과정을 통하여 각 레이어를 block 단위
로 학습하여 얻은 hidden layer의 값들이 input을 잘 설명하는 특정 값이라는 결론을 얻는다.
h0
v0
v1
𝑊 𝑇
𝑊
𝑖
𝑖
𝑗𝑘
6. 2.1 An infinite directed model with tied weights
h0
v0
v1
v2
h1
h2
etc.
𝑊 𝑇
𝑊
𝑊
𝑊 𝑇
𝑊
𝑊 𝑇
2.1의 요지 : An infinite sigmoid belief net that is equivalent to an RBM
𝑊 𝑇
𝑊
𝑊
𝑊
𝑊 𝑇
𝑊 𝑇
1. 결과적으로, 각 레이어의 과정이 동일한 역할을 하기 때문에, 앞선 과정은 왼쪽 그림과 같이 순회
하는 것과 같은 결과를 가지고, 아래와 같이 RBM과 동일한 모습이 된다.
2. RBM은 학습은 뒤에서 Gibbs sampling과 CD를 설명하면서 다시 언급하겠지만 단순하게 말하면
다음과 같다.
- h0의 임의의 분포로부터 초기값을 넣는다. 또한 weight로 임의로 초기화한다.
- sigmoid net의 rule에 따라 weight를 학습한다.
- 다시 W의 transpose를 곱하고 sigmoid net의 rule에 따라 h0에 값을 수정한다.
- 이 과정을 수렴할 때까지 반복한다.
h0
v0
𝑊𝑊 𝑇
7. 2.1 An infinite directed model with tied weights
h0
v0
v1
v2
h1
h2
etc.
𝑊 𝑇
𝑊
𝑊
𝑊 𝑇
𝑊
𝑊 𝑇
2.1의 요지 : An infinite sigmoid belief net that is equivalent to an RBM
𝑊 𝑇
𝑊
𝑊
𝑊
𝑊 𝑇
𝑊 𝑇
3. 앞선 슬라이드에서 Sigmoid belief net을 위한 learning rule은 다음과 같았다.
∆𝑤𝑗𝑖 = 𝜀𝑠𝑗 𝑠𝑖 − 𝑝𝑖
4. 논문에서의 notation으로 바꾸고 논문에서 사용한 식을 사용하면 다음과 같이, 생성되는 weight의
derivative를 구할 수 있다.
𝜕 log 𝑝(𝐯0)
𝜕𝑤00
𝑖𝑗
=< ℎ0
𝑗 𝑣0
𝑖 − ො𝑣0
𝑖 > = < ℎ0
𝑗 𝑣0
𝑖 − 𝑣1
𝑖 >
여기서, 𝑤00
𝑖𝑗는 h0의 unit, 𝑗부터 v0의 unit 𝑖로의 weight이며, 𝐯0
는 하나의 data vector를 의미하
고 𝑣0
𝑖는 𝐯0
의 𝑖번째 성분, ො𝑣0
𝑖는 hidden unit으로부터 계산된 𝑣0
𝑖 = 1일 확률(sigmoid값)을 의미한다.
5. 따라서 전 과정에서의 derivative는 다음과 같이 얻어진다.
𝜕 log 𝑝(𝐯0
)
𝜕𝑤𝑖𝑗
=< ℎ0
𝑗 𝑣0
𝑖 − 𝑣1
𝑖 >+< 𝑣1
𝑖 ℎ0
𝑗 − ℎ1
𝑗 >+< ℎ1
𝑗 𝑣1
𝑖 − 𝑣2
𝑖 > + ⋯
8. 3. Restricted Boltzmann machines and contrastive divergence learning
• RBM은 깁스 샘플링을 이용하여 학습한다. 깁스 샘플링은 MCMC성질을 가지는 간단한 방법이지만, 논문과 책 등에서 말하는
깁스 샘플링 유도 공식은 복잡하고, 이를 구현하는 것 또한 다르다. 깁스 샘플링을 하는 이유는 RBM 학습 과정 시 기울기 하강
법을 실행하기 위하여, 각 유닛의 상태에 따른 기댓값을 구할 때, 모든 경우에 수를 따져야 하는 계산을 피하기 위함이다.
- 깁스 샘플링을 1) 기본적인 개념 2) RBM에서의 깁스 샘플링을 이용한 기울기 계산 3)실제 구현에서의 깁스 샘플링
1) 기본적인 개념
깁스 샘플링을 가장 단순하게 설명하는 것은 다음과 같다.
Initialize 𝐱(0)
~𝑞 𝑥
for iteration 𝑖 = 1,2, ⋯ do
𝑥1
(𝑖)
~𝑝 𝑋1 = 𝑥1 𝑋2 = 𝑥2
𝑖−1
, 𝑋3 = 𝑥3
𝑖−1
, ⋯ , 𝑋 𝑛 = 𝑥 𝑛
𝑖−1
𝑥2
(𝑖)
~𝑝 𝑋2 = 𝑥2 𝑋1 = 𝑥1
𝑖−1
, 𝑋3 = 𝑥3
𝑖−1
, ⋯ , 𝑋 𝑛 = 𝑥 𝑛
𝑖−1
⋮
𝑥 𝑛
(𝑖)
~𝑝 𝑋 𝑛 = 𝑥 𝑛 𝑋1 = 𝑥1
𝑖−1
, 𝑋2 = 𝑥2
𝑖−1
, ⋯ , 𝑋 𝑛−1 = 𝑥 𝑛−1
𝑖−1
end for
처음 임의의 분포 𝑞 𝑥 로부터 𝐱(0)
를 샘플링 한 후, 각 요소를 한 번에
업데이트 하지 않고, 한 요소가 업데이트 할 때는 다른 요소를 고정
시킨 후 값을 구한다. 이를 반복하면 𝐱는 결국 𝑝(x)를 따르게 된다.
𝑋1 𝑋2 𝑌 Prob
0 0 0 0.25
1 0 0 0.25
0 1 0 0.25
1 1 1 0.25
𝑦 = 1이 주어졌다고 가정하자.
𝑥1
(0)
= 0, 𝑥2
(0)
= 1 를 초기 할당한다.
𝑃 𝑋1 = 1 𝑥2 = 1, 𝑦 = 1 = 1
𝑃 𝑋1 = 0 𝑥2 = 1, 𝑦 = 1 = 0
→ 𝒙 𝟏
(𝟏)
= 𝟏
𝑃 𝑋2 = 1 𝑥1 = 0, 𝑦 = 1 = 0
𝑃 𝑋2 = 0 𝑥1 = 0, 𝑦 = 1 = 0
→ 𝒙 𝟐
(𝟏)
= 𝒙 𝟐
(𝟎)
= 𝟏
예) AND연산
9. 3. Restricted Boltzmann machines and contrastive divergence learning
2) RBM에서의 깁스 샘플링을 이용한 기울기 계산 (참고* 딥러닝 제대로 시작하기)
식이 다소 복잡하므로 중간 과정없이 책의 내용을 받아들인다.
이진 유닛을 가지는 네트워크에서 유닛 𝑖이외의 유닛의 변수를 열거한 벡터를 𝐱−𝑖라 하자. 조건부 분포의 정의에 따라
𝑝 𝑥𝑖 𝐱−𝑖, 𝜃 =
𝑝(𝐱, 𝛉)
σ 𝑥 𝑖=0,1 𝑝(𝐱, 𝛉)
로 쓰고, 이 식을 𝑝 𝐱 𝛉 =
1
𝑍(𝛉)
exp{−Φ(𝐱, 𝛉)}에 대입하면 다음과 같은 식을 얻는다. 여기서 −Φ 𝐱, 𝛉 = − σ𝑖=1
𝑀
𝑏𝑖 𝑥𝑖 − σ(𝑖,𝑗)∈𝜀 𝑤𝑖𝑗 𝑥𝑖 𝑥𝑗
는 에너지 함수를, 𝑍 𝛉 = σ 𝐱 exp{−Φ(𝐱, 𝛉)}는 정규화 상수를 의미한다. 𝑁𝑖는 유닛 𝑖와 결합을 갖는 유닛의 집합.
𝑝 𝑥𝑖 𝐱−𝑖, 𝛉 =
exp (𝑏𝑖 + σ 𝑗∈𝑁 𝑖
𝑤𝑖𝑗 𝑥𝑗)𝑥𝑖)
1 + exp(𝑏𝑖 + σ 𝑗∈𝑁𝑖
𝑤𝑖𝑗 𝑥𝑗)
식이 복잡하지만 𝑝 𝑥𝑖 = 1 𝐱−𝑖, 𝛉 을 계산해보면,
𝑝 𝑥𝑖 = 1 𝐱−𝑖, 𝛉 =
exp(𝑏𝑖 + σ 𝑗∈𝑁 𝑖
𝑤𝑖𝑗 𝑥𝑗)
1 + exp(𝑏𝑖 + σ 𝑗∈𝑁 𝑖
𝑤𝑖𝑗 𝑥𝑗)
=
1
1 + exp{− 𝑏𝑖 + σ 𝑗∈𝑁 𝑖
𝑤𝑖𝑗 𝑥𝑗 }
= 𝜎(𝑏𝑖 +
𝑗∈𝑁𝑖
𝑤𝑖𝑗 𝑥𝑗)
임을 알 수 있다.
10. 3. Restricted Boltzmann machines and contrastive divergence learning
2) RBM에서의 깁스 샘플링을 이용한 기울기 계산 (참고* 딥러닝 제대로 시작하기)
RBM은 가시 변수끼리 독립이고, 은닉 변수끼리 독립인 구조로 인하여 조건부 분포를 계산할 수 있는 성질을 가진다.
가시 변수의 값의 정해져 있을 때의 은닉 변수의 조건부 분포
𝑝 𝐡 𝐯, 𝜽 =
𝑝(𝐯, 𝐡|𝜽)
σℎ 𝑝(𝐯, 𝐡|𝜽)
를 가지고 앞에서와 같이 𝑝 𝐱 𝛉 =
1
𝑍(𝛉)
exp{−Φ(𝐱, 𝛉)}에 대입하면
𝑝 𝐡 𝐯, 𝜽 = ෑ
𝒋
𝑝(ℎ𝑗|𝐯, 𝜽)
𝑝 ℎ𝑗 𝐯, 𝜽 =
exp{(𝑏𝑗 + σ𝑖 𝑤𝑖𝑗 𝑣𝑖)ℎ𝑗}
1 + exp(𝑏𝑗 + σ𝑖 𝑤𝑖𝑗 𝑣𝑖)
샘플 데이터 {𝐯 𝑛|𝑛 = 1, ⋯ , 𝑁} 으로 부터 로그 우도 함수를 weight로 미분하면, (여기서 L = σ 𝑛 𝑝 𝐡 𝐯 𝑛, 𝜽 = σ 𝒏 ς𝒋 𝑝(ℎ𝑗|𝐯 𝑛, 𝜽))
1
𝑁
𝜕 log 𝐿
𝜕𝑤𝑖𝑗
=
1
𝑁
𝑛
𝑣 𝑛𝑖 𝑝 ℎ𝑗 = 1 𝐯 𝑛 −
𝐯,𝐡
𝑣𝑖ℎ𝑗 𝑝(𝐯, 𝐡|𝜽)
로 쓸 수 있고 경사 하강법에 의한 가중치의 업데이트 식을 다음과 같이 쓸 수 있다.
∆𝑤𝑖𝑗 = 𝜀( 𝑣𝑖ℎ𝑗 𝑑𝑎𝑡𝑎
− 𝑣𝑖ℎ𝑗 𝑚𝑜𝑑𝑒𝑙
)
논문에서는 단순하게 다음과 같이 썼는데 원리는 동일한 것으로 보인다. ∞의미는 뒤에서 설명.
ℎ1 ℎ2 ℎ3
ℎ1 ℎ2 ℎ3
𝑣1 𝑣2 𝑣3 𝑣4 𝑣5
𝑣1 𝑣2 𝑣3 𝑣4 𝑣5
11. 3. Restricted Boltzmann machines and contrastive divergence learning
2) RBM에서의 깁스 샘플링을 이용한 기울기 계산
앞선 과정을 떠올리며 다시 논문으로 돌아간다. 우리는 초기 샘플링 된 𝐯0
를 이용하여 다음과 같은 업데이트를 실시하는 것을
이미 알고 있다.
𝜕 log 𝑝(𝐯0
)
𝜕𝑤𝑖𝑗
=< ℎ0
𝑗 𝑣0
𝑖 − 𝑣1
𝑖 >+< 𝑣1
𝑖 ℎ0
𝑗 − ℎ1
𝑗 >+< ℎ1
𝑗 𝑣1
𝑖 − 𝑣2
𝑖 > + ⋯
이와 마찬가지로 초기 데이터가 주어졌을 때, 깁스 샘플링을 RBM이 stationary distribution에 이를 때
까지 반복한다.
h0
v0
v1
v2
h1
h2
etc.
𝑊 𝑇
𝑊
𝑊
𝑊 𝑇
𝑊
𝑊 𝑇
𝑊 𝑇
𝑊
𝑊
𝑊
𝑊 𝑇
𝑊 𝑇
⋯ < 𝑣∞
𝑖ℎ∞
𝑗 >< 𝑣0
𝑖ℎ0
𝑗 >
𝜕 log 𝑝(𝐯0)
𝜕𝑤𝑖𝑗
=< 𝑣0
𝑖ℎ0
𝑗 > − < 𝑣∞
𝑖ℎ∞
𝑗 >
𝑊 𝑊 𝑇
12. 3. Restricted Boltzmann machines and contrastive divergence learning
3)실제 구현에서의 깁스 샘플링(참고* 딥러닝 제대로 시작하기)
구현은 다음과 같이 시행한다. 먼저, 앞선 식 𝑝 𝑥𝑖 𝐱−𝑖, 𝛉 =
exp (𝑏 𝑖+σ 𝑗∈𝑁 𝑖
𝑤 𝑖𝑗 𝑥 𝑗)𝑥 𝑖)
1+exp(𝑏 𝑖+σ 𝑗∈𝑁 𝑖
𝑤𝑖𝑗 𝑥 𝑗)
에서 𝑝 𝑥𝑖 = 1 𝐱−𝑖, 𝛉 을 계산한다. 우리는 이것이
weight와 bias로 결합된 값을 시그모이드 함수를 취한 것이라는 것을 이미 알고 있다. 그 다음 구간 [0,1]의 균등 난수를 생성하여
그 값이 이 확률을 밑돌면 𝑥𝑖 = 1, 그렇지 않으면 𝑥𝑖 = 0으로 한다. 이렇게 얻은 𝑥𝑖가 위의 조건부 분포를 따르게 된다.
#visible variable
#hidden variable
#weight
v0
h0
hb
𝜎
𝑊
v1
𝑊 𝑇
𝜎
h1
𝑊
𝜎
13. 3. Restricted Boltzmann machines and contrastive divergence learning
4) CD(contrastive divergence learning)의 역할
깁스 샘플링을 수렴할 때까지 반복함으로써 수렴이 되었을 시 업데이트를 진행하지만, 그렇게 되면 학습시간이 너무 길어진다.
CD는 깁스 샘플링을 수렴할 때까지 하지 않고 은닉 변수와 가시 변수의 샘플링을 𝑇번 반복한다. 𝑇 = 1이 되어도 된다.
𝜕 log 𝑝(𝐯0
)
𝜕𝑤𝑖𝑗
=< 𝑣0
𝑖ℎ0
𝑗 > − < 𝑣 𝑇
𝑖ℎ 𝑇
𝑗 >
𝑾 ← 𝑾 + 𝜶 (< 𝐯0 𝐡0 > − < 𝐯1 𝐡1 >)
h0
v0
v1
v2
h1
h2
𝑊 𝑇
𝑊
𝑊
𝑊 𝑇
𝑊
𝑊 𝑇
𝑊 𝑇
𝑊
𝑊
𝑊
𝑊 𝑇
𝑊 𝑇
이론적 배경까지 들어가면 너무 복잡해지므로, 실제로 구현 과정을 통하여 이해하도록 한다.
미니 배치이므로 평균을 구함
14. 4) CD(contrastive divergence learning)
실제 생성
생성실제
실제
실제
생성
생성
3. Restricted Boltzmann machines and contrastive divergence learning
15. 500 units
500 units
2000 units 10 label units
500 units
RBM
𝑾1
𝑾2
RBM
500 units
𝑾3
RBM
Pretraining
2000 units
500 units
𝑾3
𝑾2
500 units
𝑾1
𝑾4 : random하게 초기화
10 label units
2000 units
500 units
500 units
𝑾′
4
𝑾′
3
𝑾′
2
𝑾′
1
backpropagation 적용
• A greedy learning algorithm
복잡한 모델을 효율적으로 학습하는 방법은 단순한 모델들을 결합하는 것이다. 이 모델은 이전 층의 결과를 다음 층의 input으
로 하여 input을 잘 표현하는 output
을 내놓는다.
결과적으로 이 알고리즘은 generative
모델을 향상시키는 것을 보장한다.
4. A greedy learning algorithm for transforming representations
16. • Learning the weight matrices one layer at a time is efficient but not optimal.
학습은 optimize하여 weigh를 학습하는 것이 아니라 깁스 샘플링과 CD를 이용하여 효율적으로 구하는 것이다.
• 종종 네트워크에서 오버 피팅 문제가 발생한다. 하지만, Pretraining 과정을 통하여 input 데이터만을 이용하여 각 레이어마다
weight에 어떤 제약을 주는 것으로 여길 수 있다.
• 모든 레이어에 weight에 greedily learning 후 좋은 initial value를 얻지만, 이전 레이어의 값들이 조건부 독립이라는 가정에서
다음 레이어를 approximate하는 제약이 존재한다.
5. Back-Fitting with the up-down algorithm
17. hid
vis
penlab
top
17
1) 각 층에 다음과 같이 간단하게 이름을 부여한다.
- 입력 데이터 : vis
- 첫 번째 은닉층 : hid
- 두 번째 은닉층 : pen
- 최상층 : top
- 라벨 데이터(target) : lab
2) 흐름은 다음과 같다.
1. up-pass에 의해서 최상층 무방향 엣지로 이루어진 층의 정보를 초기화 한다.
2. 무방향 엣지로 이루어진 층은 라벨 정보를 이용하여 깁스 샘플링, CD 과정을 거친다.
3. 2과정을 통하여 나온 결과로 down-pass를 진행한다.
4. down-pass 후 sleep phase의 상태를 up-pass로 예측한 뒤 recognition weight를 업데이트한다.
5. 최상층은 up-pass의 초기 상태(positive)와 CD과정으로 나온 상태(negative)를 이용하여 업데이트 한다.
6. wake phase의 상태를 down-pass로 예측한 뒤 generative weight를 업데이트한다.
Pseudo-Code For Up-Down Algorithm
18. Up-pass(bottom up) process
data
vishid
1
hidrecbiases
wakehidprobs
wakehidstates
Pseudo-Code(1)
Perform a bottom-up pass to get wake/positive phase
probabilities and sample states
wakehidprobs = logistic(data*vishid + hidrecbiases)
wakehidstates = wakehidprobs > rand(1,numhid)
wakepenprobs = logistic(wakehidstates*hidpen +penrecbiases)
wakepenstates = wakepenprobs>rand(1, numpen)
postopprobs = logistic(wakepenstates*pentop+targets*labtop+topbiases)
postopstates = waketopprobs>rand(1,numtop);
hidpen
1
penrecbiases
wakepenprobs
wakepenstates
pentop
postopprobs
postopstates
labtop
targets
1
topbiases
18
20. Top level CD Process
Pseudo-Code(3)
Perform numCDiters Gibbs sampling iterations using the top level Undirected associative memory
negtopstates = waketopstates
for iter = 1:numCDiters
negpenprobs = logistic(negtopstates*pentop’ + pengenbiases)
negpenstates = negpenprobs > rand(1, numpen)
neglabprobs = softmax(negtopstates*labtop’+labgenbiases)
negtopprobs = logistic(negpenstates*pentop+neglabprobs*labtop+topbiases)
negtopstates = negtopprobs > rand(1, numtop)
end
waketopstates
negtopstates
초기화
20
21. Top level CD Process
Pseudo-Code(3)
Perform numCDiters Gibbs sampling iterations using the top level Undirected associative memory
negtopstates = waketopstates
for iter = 1:numCDiters
negpenprobs = logistic(negtopstates*pentop’ + pengenbiases)
negpenstates = negpenprobs > rand(1, numpen)
neglabprobs = softmax(negtopstates*labtop’+labgenbiases)
negtopprobs = logistic(negpenstates*pentop+neglabprobs*labtop+topbiases)
negtopstates = negtopprobs > rand(1, numtop)
end
negtopstates
toppen
negpenprobs
negpenstates
1
pengenbiases
21
22. Top level CD Process
Pseudo-Code(3)
Perform numCDiters Gibbs sampling iterations using the top level Undirected associative memory
negtopstates = waketopstates
for iter = 1:numCDiters
negpenprobs = logistic(negtopstates*pentop’ + pengenbiases)
negpenstates = negpenprobs > rand(1, numpen)
neglabprobs = softmax(negtopstates*labtop’+labgenbiases)
negtopprobs = logistic(negpenstates*pentop+neglabprobs*labtop+topbiases)
negtopstates = negtopprobs > rand(1, numtop)
end
negtopstates
negpenstates
toplap
neglabprobs
1 labgenbiases
22
23. Top level CD Process
Pseudo-Code(3)
Perform numCDiters Gibbs sampling iterations using the top level Undirected associative memory
negtopstates = waketopstates
for iter = 1:numCDiters
negpenprobs = logistic(negtopstates*pentop’ + pengenbiases)
negpenstates = negpenprobs > rand(1, numpen)
neglabprobs = softmax(negtopstates*labtop’+labgenbiases)
negtopprobs = logistic(negpenstates*pentop+neglabprobs*labtop+topbiases)
negtopstates = negtopprobs > rand(1, numtop)
end
negtopstates
pentop
negpenstates
labtop
neglabprobs
negtopprobs
1
topbiases
23
targets
24. Top level CD Process Finish!
Pseudo-Code(4)
Negative phase statistics for contrastive divergence
negpentopstatistics = negpenstates’ * negtopstates
neglabtopstatistics = neglabprobs’ * negtopstates
negtopstates
negpenstates
24
neglabprobs
targets
예측
실제
25. down-pass(up bottom) process
Pseudo-Code(5)
Starting from the end of the gibbs sampling run, perform a top-down generative pass to get
sleep/negative phase probabilities and sample states
sleeppenstates = negpenstates
sleephidprobs = logistic(sleeppenstates*penhid+hidgenbiases)
sleephidstates = sleephidprobs > rand(1, numhid)
sleepvisprobs = logistic(sleephidstates*hidvis+visgenbiases)
negpenstates
sleeppenstates
초기화
25
26. down-pass(up bottom) process
Pseudo-Code(5)
Starting from the end of the gibbs sampling run, perform a top-down generative pass to get
sleep/negative phase probabilities and sample states
sleeppenstates = negpenstates
sleephidprobs = logistic(sleeppenstates*penhid+hidgenbiases)
sleephidstates = sleephidprobs > rand(1, numhid)
sleepvisprobs = logistic(sleephidstates*hidvis+visgenbiases)
sleeppenstates
penhid
sleephidprobs
sleephidstates
1
hidgenbiases
26
27. down-pass(up bottom) process
Pseudo-Code(5)
Starting from the end of the gibbs sampling run, perform a top-down generative pass to get
sleep/negative phase probabilities and sample states
sleeppenstates = negpenstates
sleephidprobs = logistic(sleeppenstates*penhid+hidgenbiases)
sleephidstates = sleephidprobs > rand(1, numhid)
sleepvisprobs = logistic(sleephidstates*hidvis+visgenbiases)
sleeppenstates
sleephidstates
1
visgenbiases
hidvis
sleepvisprobs
27
28. down-pass(up bottom) process Finish!
Pseudo-Code(5)
Starting from the end of the gibbs sampling run, perform a top-down generative pass to get
sleep/negative phase probabilities and sample states
sleeppenstates = negpenstates
sleephidprobs = logistic(sleeppenstates*penhid+hidgenbiases)
sleephidstates = sleephidprobs > rand(1, numhid)
sleepvisprobs = logistic(sleephidstates*hidvis+visgenbiases)
sleeppenstates
sleephidstates
sleepvisprobs
28
29. Pseudo-Code For Up-Down Algorithm
Pseudo-Code – 중간 과정 요약.
data
wakehidstates
wakepenstates
waketopstatestargets
1
hidrecbiases
1
penrecbiases
1 topbiases
vishid
hidpen
pentop
sleepvisprobs
sleephidstates
sleeppenstates
hidvis
penhid
toppen
1
hidgenbiases
1
pengenbiases
visgenbiases
1
poslabtopstatistics
pospentopstatistics
WAKE
SLEEP
labgenbiases
1
negtopstates
negpentopstatistics
neglabtopstatistics
topbiases
29
41. Experiment
MNIST
The Mnist database
- training images : 60,000
- test images : 10,000
1) Greedy layer-by-layer training
- 초기화 과정에서 밑(bottom)에서부터 시작
- 각 층의 가중치를 개별적으로 훈련
- 각 층에서 RBM의 input은 0과 1 사이의 값을 가짐
- 최상층에서 가중치를 학습할 때 레이블은 input으로 제공되어진다.
Network in paper
- training images : 44,000
- mini-batch images : 440
42. 6.Performance on the MNIST database
2) Up-down algorithm
- After the greedy layer-by-layer training, the network was trained, with a different learning
rate and weight-decay, for 300 epochs using the up-down algorithm.
- validation set : 10,000
- first 100 epochs : tree full iterations of alternating Gibbs sampling
- second 100 epochs : six iteration
- last 100 epochs : ten iteration
44. Complementary priors
• 참고 자료
http://cvn.ecp.fr/personnel/iasonas/course/DL5.pdf : DBN관련 pdf
https://www.youtube.com/watch?v=5zhhr7HpqjQ : 제프리 힌튼의 Coursera 강의
https://www.youtube.com/watch?v=1cLbr0417GM : Sampling관련 문일철 교수님 강의