SlideShare uma empresa Scribd logo
1 de 44
Baixar para ler offline
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
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의 상태에 의존하는 지역성을 가짐.
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이 어떻게 작동하는지
확인함으로써 마무리 짓는 것으로 한다.
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)가 되지만, 층이
깊어지면, 이전 층의 영향을 받게 되어 이전 층의 가능한 모든 상태를 고려하여야 하는 문제가 생긴다.
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
𝑊 𝑇
𝑊
𝑖
𝑖
𝑗𝑘
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
𝑊𝑊 𝑇
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
𝑖 > + ⋯
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연산
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{− 𝑏𝑖 + σ 𝑗∈𝑁 𝑖
𝑤𝑖𝑗 𝑥𝑗 }
= 𝜎(𝑏𝑖 + ෍
𝑗∈𝑁𝑖
𝑤𝑖𝑗 𝑥𝑗)
임을 알 수 있다.
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
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
𝑗 > − < 𝑣∞
𝑖ℎ∞
𝑗 >
𝑊 𝑊 𝑇
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
𝑊
𝜎
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
𝑊 𝑇
𝑊
𝑊
𝑊 𝑇
𝑊
𝑊 𝑇
𝑊 𝑇
𝑊
𝑊
𝑊
𝑊 𝑇
𝑊 𝑇
이론적 배경까지 들어가면 너무 복잡해지므로, 실제로 구현 과정을 통하여 이해하도록 한다.
미니 배치이므로 평균을 구함
4) CD(contrastive divergence learning)
실제 생성
생성실제
실제
실제
생성
생성
3. Restricted Boltzmann machines and contrastive divergence learning
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
• 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
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
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
Up-pass(bottom up) process Finish!
data
wakehidstates
Pseudo-Code(2)
Positive phase statistics for contrastive divergence
poslabtopstatistics = targets’ * waketopstates;
pospentopstatistics = wakepenstates’*waketopstates;
wakepenstates
waketopstates
targets
1
hidrecbiases
1
penrecbiases
1
topbiases
vishid
hidpen
pentop
19
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
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
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
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
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
예측
실제
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
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
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
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
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
Prediction sleep phase
Pseudo-Code(6)
Prediction
psleeppenstates = logistic(sleephidstates*hidpen + penrecbiases)
psleephidstates = logistic(sleepvisprobs*vishid + hidrecbiases)
pvisprobs = logistic(wakehidstates*hidvis + visgenbiases)
phidprobs = logistic(wakepenstates*penhid + hidgenbiases) psleeppenstates
sleephidstates
sleepvisprobs
hidpen
1
penrecbiasessleeppenstates실제
예측
30
Prediction sleep phase
Pseudo-Code(6)
Prediction
psleeppenstates = logistic(sleephidstates*hidpen + penrecbiases)
psleephidstates = logistic(sleepvisprobs*vishid + hidrecbiases)
pvisprobs = logistic(wakehidstates*hidvis + visgenbiases)
phidprobs = logistic(wakepenstates*penhid + hidgenbiases)
sleeppenstates
psleephidstates
vishid
1
hidrecbiasessleephidstates실제
예측
sleepvisprobs
31
Prediction wake phase
Pseudo-Code(6)
Prediction
psleeppenstates = logistic(sleephidstates*hidpen + penrecbiases)
psleephidstates = logistic(sleepvisprobs*vishid + hidrecbiases)
pvisprobs = logistic(wakehidstates*hidvis + visgenbiases)
phidprobs = logistic(wakepenstates*penhid + hidgenbiases)
pvisprobs
hidvis1
visgenbiases
wakehidstates
wakepenstates
data 실제
예측
32
Prediction wake phase
Pseudo-Code(6)
Prediction
psleeppenstates = logistic(sleephidstates*hidpen + penrecbiases)
psleephidstates = logistic(sleepvisprobs*vishid + hidrecbiases)
pvisprobs = logistic(wakehidstates*hidvis + visgenbiases)
phidprobs = logistic(wakepenstates*penhid + hidgenbiases)
data
penhid1
hidgenbiases phidprobs
wakepenstates
wakehidstates 실제
예측
33
RBM update rule using contrastive divergence learning
𝜕 log 𝑝(𝐯0)
𝜕𝑤𝑖𝑗
=< 𝑣0
𝑖ℎ0
𝑗 > − < 𝑣 𝑇
𝑖ℎ 𝑇
𝑗 >
𝑾 ← 𝑾 + 𝜶 (< 𝐯0
𝐡0
> − < 𝐯1
𝐡1
>)
𝒗𝒃 ← 𝒗𝒃 + 𝜶 (< 𝐯0
> − < 𝐯1
>)
𝒉𝒃 ← 𝒉𝒃 + 𝜶 (< 𝐡0
> − < 𝐡1
>)
h0
v0
v1
v2
h1
h2
𝑊 𝑇
𝑊
𝑊
𝑊 𝑇
𝑊
𝑊 𝑇
𝑊 𝑇
𝑊
𝑊
𝑊
𝑊 𝑇
𝑊 𝑇
Generative weight update
Pseudo-Code(7)
Updates to generative parameters
hidvis = hidvis + r*wekehidstates’*(data-pvisprobs)
visgenbiases = visgenbiases + r*(data-pvisprobs)
penhid = penhid+r*wakepenstates’*(wakehidstates-phidprobs)
hidgenbiases = hidgenbiases + r*(wakehidstates-phidprobs)
pvisprobs
hidvis1
visgenbiases
wakehidstates
wakepenstates
data 실제
예측
35
wakehidstates
datapvisprobs
Pseudo-Code(7)
Updates to generative parameters
hidvis = hidvis + r*wekehidstates’*(data-pvisprobs)
visgenbiases = visgenbiases + r*(data-pvisprobs)
penhid = penhid+r*wakepenstates’*(wakehidstates-phidprobs)
hidgenbiases = hidgenbiases + r*(wakehidstates-phidprobs)
data
penhid1
hidgenbiases
phidprobs
wakepenstates
wakehidstates 실제
예측
36
Generative weight update
Top level layer update
Pseudo-Code(8)
Updates to top level associative memory
labtop = labtop + r*(poslabtopstatistics-neglabtopstatistics)
labgenbiases = labgenbiases + r*(targets – neglabprobs)
pentop = pentop + r*(pospentopstatistics – negpentopstatistics)
pengenbiases = pengenbiases + r*(wakepenstates – negpenstates)
topbiases = topbiases + r*(waketopstates – negtopstates)
top
pen
laptop
1 labgenbiases
poslabtopstatistics = targets’ * waketopstates
pospentopstatistics = wakepenstates’*waketopstates
negpentopstatistics = negpenstates’ * negtopstates
neglabtopstatistics = neglabprobs’ * negtopstates 37
neglabprobs
targets
Top level layer update
Pseudo-Code(8)
Updates to top level associative memory
labtop = labtop + r*(poslabtopstatistics-neglabtopstatistics)
labgenbiases = labgenbiases + r*(targets – neglabprobs)
pentop = pentop + r*(pospentopstatistics – negpentopstatistics)
pengenbiases = pengenbiases + r*(wakepenstates – negpenstates)
topbiases = topbiases + r*(waketopstates – negtopstates)
poslabtopstatistics = targets’ * waketopstates
pospentopstatistics = wakepenstates’*waketopstates
negpentopstatistics = negpenstates’ * negtopstates
neglabtopstatistics = neglabprobs’ * negtopstates
1
topbiases
sleeppenstates
toppen
pengenbiases
negtopstates
topbiases
1
waketopstates
wakepenstates
pentop
38
negpenstates(8-9 page)
Recognition weight update
Pseudo-Code(9)
Updates to recognition/inference approximation parameters
hidpen = hidpen + r*(sleephidstates’*(sleeppenstates – psleeppenstates))
penrecbiases = penrecbiases + r*(sleeppenstates – psleeppenstates)
vishid = vishid + r*(sleepvisprobs’*(sleephidstates – psleephidstates))
hidrecbiases = hidrecbiases + r*(sleephidstates – psleephidstates)
39
psleeppenstates
sleephidstates
sleepvisprobs
hidpen
1
penrecbiasessleeppenstates
39
Recognition weight update
Pseudo-Code(9)
Updates to recognition/inference approximation parameters
hidpen = hidpen + r*(sleephidstates’*(sleeppenstates – psleeppenstates))
penrecbiases = penrecbiases + r*(sleeppenstates – psleeppenstates)
vishid = vishid + r*(sleepvisprobs’*(sleephidstates – psleephidstates))
hidrecbiases = hidrecbiases + r*(sleephidstates – psleephidstates)
data
1
hidrecbiases
vishid
psleephidstates
sleephidstates
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
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
Result
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관련 문일철 교수님 강의

Mais conteúdo relacionado

Mais procurados

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
 
머피's 머신러닝: Latent Linear Model
머피's 머신러닝: Latent Linear Model머피's 머신러닝: Latent Linear Model
머피's 머신러닝: Latent Linear ModelJungkyu Lee
 
대칭가중치와 심층신뢰네트워크
대칭가중치와 심층신뢰네트워크대칭가중치와 심층신뢰네트워크
대칭가중치와 심층신뢰네트워크Sunggon Song
 
Restricted Boltzmann Machine
Restricted Boltzmann MachineRestricted Boltzmann Machine
Restricted Boltzmann MachineJungwon Kim
 
8. Logistic Regression
8. Logistic Regression8. Logistic Regression
8. Logistic RegressionJungkyu Lee
 
Murpy's Machine Learing: 10. Directed Graphical Model
Murpy's Machine Learing: 10. Directed Graphical ModelMurpy's Machine Learing: 10. Directed Graphical Model
Murpy's Machine Learing: 10. Directed Graphical ModelJungkyu Lee
 
Chapter 10 sequence modeling recurrent and recursive nets
Chapter 10 sequence modeling recurrent and recursive netsChapter 10 sequence modeling recurrent and recursive nets
Chapter 10 sequence modeling recurrent and recursive netsKyeongUkJang
 
7. Linear Regression
7. Linear Regression7. Linear Regression
7. Linear RegressionJungkyu Lee
 
머피의 머신러닝: Undirencted Graphical Model
머피의 머신러닝: Undirencted Graphical Model머피의 머신러닝: Undirencted Graphical Model
머피의 머신러닝: Undirencted Graphical ModelJungkyu Lee
 
머피's 머신러닝: Latent Linear Model
머피's 머신러닝: Latent Linear Model머피's 머신러닝: Latent Linear Model
머피's 머신러닝: Latent Linear ModelJungkyu Lee
 
Code로 이해하는 RNN
Code로 이해하는 RNNCode로 이해하는 RNN
Code로 이해하는 RNNSANG WON PARK
 
Rnn개념정리
Rnn개념정리Rnn개념정리
Rnn개념정리종현 최
 
내가 이해하는 SVM(왜, 어떻게를 중심으로)
내가 이해하는 SVM(왜, 어떻게를 중심으로)내가 이해하는 SVM(왜, 어떻게를 중심으로)
내가 이해하는 SVM(왜, 어떻게를 중심으로)SANG WON PARK
 

Mais procurados (13)

Coursera Machine Learning (by Andrew Ng)_강의정리
Coursera Machine Learning (by Andrew Ng)_강의정리Coursera Machine Learning (by Andrew Ng)_강의정리
Coursera Machine Learning (by Andrew Ng)_강의정리
 
머피's 머신러닝: Latent Linear Model
머피's 머신러닝: Latent Linear Model머피's 머신러닝: Latent Linear Model
머피's 머신러닝: Latent Linear Model
 
대칭가중치와 심층신뢰네트워크
대칭가중치와 심층신뢰네트워크대칭가중치와 심층신뢰네트워크
대칭가중치와 심층신뢰네트워크
 
Restricted Boltzmann Machine
Restricted Boltzmann MachineRestricted Boltzmann Machine
Restricted Boltzmann Machine
 
8. Logistic Regression
8. Logistic Regression8. Logistic Regression
8. Logistic Regression
 
Murpy's Machine Learing: 10. Directed Graphical Model
Murpy's Machine Learing: 10. Directed Graphical ModelMurpy's Machine Learing: 10. Directed Graphical Model
Murpy's Machine Learing: 10. Directed Graphical Model
 
Chapter 10 sequence modeling recurrent and recursive nets
Chapter 10 sequence modeling recurrent and recursive netsChapter 10 sequence modeling recurrent and recursive nets
Chapter 10 sequence modeling recurrent and recursive nets
 
7. Linear Regression
7. Linear Regression7. Linear Regression
7. Linear Regression
 
머피의 머신러닝: Undirencted Graphical Model
머피의 머신러닝: Undirencted Graphical Model머피의 머신러닝: Undirencted Graphical Model
머피의 머신러닝: Undirencted Graphical Model
 
머피's 머신러닝: Latent Linear Model
머피's 머신러닝: Latent Linear Model머피's 머신러닝: Latent Linear Model
머피's 머신러닝: Latent Linear Model
 
Code로 이해하는 RNN
Code로 이해하는 RNNCode로 이해하는 RNN
Code로 이해하는 RNN
 
Rnn개념정리
Rnn개념정리Rnn개념정리
Rnn개념정리
 
내가 이해하는 SVM(왜, 어떻게를 중심으로)
내가 이해하는 SVM(왜, 어떻게를 중심으로)내가 이해하는 SVM(왜, 어떻게를 중심으로)
내가 이해하는 SVM(왜, 어떻게를 중심으로)
 

Semelhante a The fastalgorithmfordeepbeliefnets

Learning how to explain neural networks: PatternNet and PatternAttribution
Learning how to explain neural networks: PatternNet and PatternAttributionLearning how to explain neural networks: PatternNet and PatternAttribution
Learning how to explain neural networks: PatternNet and PatternAttributionGyubin Son
 
Understanding deep learning requires rethinking generalization (2017) 2 2(2)
Understanding deep learning requires rethinking generalization (2017)    2 2(2)Understanding deep learning requires rethinking generalization (2017)    2 2(2)
Understanding deep learning requires rethinking generalization (2017) 2 2(2)정훈 서
 
Guided policy search
Guided policy searchGuided policy search
Guided policy searchJaehyeon Park
 
[한글] Tutorial: Sparse variational dropout
[한글] Tutorial: Sparse variational dropout[한글] Tutorial: Sparse variational dropout
[한글] Tutorial: Sparse variational dropoutWuhyun Rico Shin
 
PR12 Season3 Weight Agnostic Neural Networks
PR12 Season3 Weight Agnostic Neural NetworksPR12 Season3 Weight Agnostic Neural Networks
PR12 Season3 Weight Agnostic Neural NetworksKyunghoon Jung
 
[kor ver.]패턴인식을 위한 인공신경망 Caps-net 구현
[kor ver.]패턴인식을 위한 인공신경망 Caps-net 구현 [kor ver.]패턴인식을 위한 인공신경망 Caps-net 구현
[kor ver.]패턴인식을 위한 인공신경망 Caps-net 구현 Adonis Han
 
Variational inference intro. (korean ver.)
Variational inference intro. (korean ver.)Variational inference intro. (korean ver.)
Variational inference intro. (korean ver.)Kiho Hong
 
From maching learning to deep learning episode2
From maching learning to deep learning episode2 From maching learning to deep learning episode2
From maching learning to deep learning episode2 Yongdae Kim
 
Lecture 4: Neural Networks I
Lecture 4: Neural Networks ILecture 4: Neural Networks I
Lecture 4: Neural Networks ISang Jun Lee
 
[컴퓨터비전과 인공지능] 7. 합성곱 신경망 1
[컴퓨터비전과 인공지능] 7. 합성곱 신경망 1[컴퓨터비전과 인공지능] 7. 합성곱 신경망 1
[컴퓨터비전과 인공지능] 7. 합성곱 신경망 1jdo
 
[컴퓨터비전과 인공지능] 7. 합성곱 신경망 2
[컴퓨터비전과 인공지능] 7. 합성곱 신경망 2[컴퓨터비전과 인공지능] 7. 합성곱 신경망 2
[컴퓨터비전과 인공지능] 7. 합성곱 신경망 2jdo
 
"From image level to pixel-level labeling with convolutional networks" Paper ...
"From image level to pixel-level labeling with convolutional networks" Paper ..."From image level to pixel-level labeling with convolutional networks" Paper ...
"From image level to pixel-level labeling with convolutional networks" Paper ...LEE HOSEONG
 
Supervised Constrastive Learning
Supervised Constrastive LearningSupervised Constrastive Learning
Supervised Constrastive LearningSungchul Kim
 
Early stopping as nonparametric variational inference
Early stopping as nonparametric variational inferenceEarly stopping as nonparametric variational inference
Early stopping as nonparametric variational inferencetaeseon ryu
 
딥러닝 기본 원리의 이해
딥러닝 기본 원리의 이해딥러닝 기본 원리의 이해
딥러닝 기본 원리의 이해Hee Won Park
 
2.supervised learning(epoch#2)-3
2.supervised learning(epoch#2)-32.supervised learning(epoch#2)-3
2.supervised learning(epoch#2)-3Haesun Park
 
Improved techniques for grid mapping with rao blackwellized particle filters 번역
Improved techniques for grid mapping with rao blackwellized particle filters 번역Improved techniques for grid mapping with rao blackwellized particle filters 번역
Improved techniques for grid mapping with rao blackwellized particle filters 번역jdo
 
밑바닥부터 시작하는 딥러닝 - 학습관련기술들 스크립트
밑바닥부터 시작하는 딥러닝 - 학습관련기술들 스크립트밑바닥부터 시작하는 딥러닝 - 학습관련기술들 스크립트
밑바닥부터 시작하는 딥러닝 - 학습관련기술들 스크립트혜승 이
 

Semelhante a The fastalgorithmfordeepbeliefnets (20)

Learning how to explain neural networks: PatternNet and PatternAttribution
Learning how to explain neural networks: PatternNet and PatternAttributionLearning how to explain neural networks: PatternNet and PatternAttribution
Learning how to explain neural networks: PatternNet and PatternAttribution
 
Understanding deep learning requires rethinking generalization (2017) 2 2(2)
Understanding deep learning requires rethinking generalization (2017)    2 2(2)Understanding deep learning requires rethinking generalization (2017)    2 2(2)
Understanding deep learning requires rethinking generalization (2017) 2 2(2)
 
Guided policy search
Guided policy searchGuided policy search
Guided policy search
 
[한글] Tutorial: Sparse variational dropout
[한글] Tutorial: Sparse variational dropout[한글] Tutorial: Sparse variational dropout
[한글] Tutorial: Sparse variational dropout
 
PR12 Season3 Weight Agnostic Neural Networks
PR12 Season3 Weight Agnostic Neural NetworksPR12 Season3 Weight Agnostic Neural Networks
PR12 Season3 Weight Agnostic Neural Networks
 
[kor ver.]패턴인식을 위한 인공신경망 Caps-net 구현
[kor ver.]패턴인식을 위한 인공신경망 Caps-net 구현 [kor ver.]패턴인식을 위한 인공신경망 Caps-net 구현
[kor ver.]패턴인식을 위한 인공신경망 Caps-net 구현
 
Variational inference intro. (korean ver.)
Variational inference intro. (korean ver.)Variational inference intro. (korean ver.)
Variational inference intro. (korean ver.)
 
From maching learning to deep learning episode2
From maching learning to deep learning episode2 From maching learning to deep learning episode2
From maching learning to deep learning episode2
 
Lecture 4: Neural Networks I
Lecture 4: Neural Networks ILecture 4: Neural Networks I
Lecture 4: Neural Networks I
 
[컴퓨터비전과 인공지능] 7. 합성곱 신경망 1
[컴퓨터비전과 인공지능] 7. 합성곱 신경망 1[컴퓨터비전과 인공지능] 7. 합성곱 신경망 1
[컴퓨터비전과 인공지능] 7. 합성곱 신경망 1
 
[컴퓨터비전과 인공지능] 7. 합성곱 신경망 2
[컴퓨터비전과 인공지능] 7. 합성곱 신경망 2[컴퓨터비전과 인공지능] 7. 합성곱 신경망 2
[컴퓨터비전과 인공지능] 7. 합성곱 신경망 2
 
"From image level to pixel-level labeling with convolutional networks" Paper ...
"From image level to pixel-level labeling with convolutional networks" Paper ..."From image level to pixel-level labeling with convolutional networks" Paper ...
"From image level to pixel-level labeling with convolutional networks" Paper ...
 
Supervised Constrastive Learning
Supervised Constrastive LearningSupervised Constrastive Learning
Supervised Constrastive Learning
 
Early stopping as nonparametric variational inference
Early stopping as nonparametric variational inferenceEarly stopping as nonparametric variational inference
Early stopping as nonparametric variational inference
 
딥러닝 기본 원리의 이해
딥러닝 기본 원리의 이해딥러닝 기본 원리의 이해
딥러닝 기본 원리의 이해
 
2.supervised learning(epoch#2)-3
2.supervised learning(epoch#2)-32.supervised learning(epoch#2)-3
2.supervised learning(epoch#2)-3
 
DL from scratch(6)
DL from scratch(6)DL from scratch(6)
DL from scratch(6)
 
Improved techniques for grid mapping with rao blackwellized particle filters 번역
Improved techniques for grid mapping with rao blackwellized particle filters 번역Improved techniques for grid mapping with rao blackwellized particle filters 번역
Improved techniques for grid mapping with rao blackwellized particle filters 번역
 
Review MLP Mixer
Review MLP MixerReview MLP Mixer
Review MLP Mixer
 
밑바닥부터 시작하는 딥러닝 - 학습관련기술들 스크립트
밑바닥부터 시작하는 딥러닝 - 학습관련기술들 스크립트밑바닥부터 시작하는 딥러닝 - 학습관련기술들 스크립트
밑바닥부터 시작하는 딥러닝 - 학습관련기술들 스크립트
 

Mais de Lee Gyeong Hoon

Mais de Lee Gyeong Hoon (8)

Nlp study1
Nlp study1Nlp study1
Nlp study1
 
Vae
VaeVae
Vae
 
Mylab
MylabMylab
Mylab
 
Gan
GanGan
Gan
 
Svmtf
SvmtfSvmtf
Svmtf
 
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?
 

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
  • 19. Up-pass(bottom up) process Finish! data wakehidstates Pseudo-Code(2) Positive phase statistics for contrastive divergence poslabtopstatistics = targets’ * waketopstates; pospentopstatistics = wakepenstates’*waketopstates; wakepenstates waketopstates targets 1 hidrecbiases 1 penrecbiases 1 topbiases vishid hidpen pentop 19
  • 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
  • 30. Prediction sleep phase Pseudo-Code(6) Prediction psleeppenstates = logistic(sleephidstates*hidpen + penrecbiases) psleephidstates = logistic(sleepvisprobs*vishid + hidrecbiases) pvisprobs = logistic(wakehidstates*hidvis + visgenbiases) phidprobs = logistic(wakepenstates*penhid + hidgenbiases) psleeppenstates sleephidstates sleepvisprobs hidpen 1 penrecbiasessleeppenstates실제 예측 30
  • 31. Prediction sleep phase Pseudo-Code(6) Prediction psleeppenstates = logistic(sleephidstates*hidpen + penrecbiases) psleephidstates = logistic(sleepvisprobs*vishid + hidrecbiases) pvisprobs = logistic(wakehidstates*hidvis + visgenbiases) phidprobs = logistic(wakepenstates*penhid + hidgenbiases) sleeppenstates psleephidstates vishid 1 hidrecbiasessleephidstates실제 예측 sleepvisprobs 31
  • 32. Prediction wake phase Pseudo-Code(6) Prediction psleeppenstates = logistic(sleephidstates*hidpen + penrecbiases) psleephidstates = logistic(sleepvisprobs*vishid + hidrecbiases) pvisprobs = logistic(wakehidstates*hidvis + visgenbiases) phidprobs = logistic(wakepenstates*penhid + hidgenbiases) pvisprobs hidvis1 visgenbiases wakehidstates wakepenstates data 실제 예측 32
  • 33. Prediction wake phase Pseudo-Code(6) Prediction psleeppenstates = logistic(sleephidstates*hidpen + penrecbiases) psleephidstates = logistic(sleepvisprobs*vishid + hidrecbiases) pvisprobs = logistic(wakehidstates*hidvis + visgenbiases) phidprobs = logistic(wakepenstates*penhid + hidgenbiases) data penhid1 hidgenbiases phidprobs wakepenstates wakehidstates 실제 예측 33
  • 34. RBM update rule using contrastive divergence learning 𝜕 log 𝑝(𝐯0) 𝜕𝑤𝑖𝑗 =< 𝑣0 𝑖ℎ0 𝑗 > − < 𝑣 𝑇 𝑖ℎ 𝑇 𝑗 > 𝑾 ← 𝑾 + 𝜶 (< 𝐯0 𝐡0 > − < 𝐯1 𝐡1 >) 𝒗𝒃 ← 𝒗𝒃 + 𝜶 (< 𝐯0 > − < 𝐯1 >) 𝒉𝒃 ← 𝒉𝒃 + 𝜶 (< 𝐡0 > − < 𝐡1 >) h0 v0 v1 v2 h1 h2 𝑊 𝑇 𝑊 𝑊 𝑊 𝑇 𝑊 𝑊 𝑇 𝑊 𝑇 𝑊 𝑊 𝑊 𝑊 𝑇 𝑊 𝑇
  • 35. Generative weight update Pseudo-Code(7) Updates to generative parameters hidvis = hidvis + r*wekehidstates’*(data-pvisprobs) visgenbiases = visgenbiases + r*(data-pvisprobs) penhid = penhid+r*wakepenstates’*(wakehidstates-phidprobs) hidgenbiases = hidgenbiases + r*(wakehidstates-phidprobs) pvisprobs hidvis1 visgenbiases wakehidstates wakepenstates data 실제 예측 35 wakehidstates datapvisprobs
  • 36. Pseudo-Code(7) Updates to generative parameters hidvis = hidvis + r*wekehidstates’*(data-pvisprobs) visgenbiases = visgenbiases + r*(data-pvisprobs) penhid = penhid+r*wakepenstates’*(wakehidstates-phidprobs) hidgenbiases = hidgenbiases + r*(wakehidstates-phidprobs) data penhid1 hidgenbiases phidprobs wakepenstates wakehidstates 실제 예측 36 Generative weight update
  • 37. Top level layer update Pseudo-Code(8) Updates to top level associative memory labtop = labtop + r*(poslabtopstatistics-neglabtopstatistics) labgenbiases = labgenbiases + r*(targets – neglabprobs) pentop = pentop + r*(pospentopstatistics – negpentopstatistics) pengenbiases = pengenbiases + r*(wakepenstates – negpenstates) topbiases = topbiases + r*(waketopstates – negtopstates) top pen laptop 1 labgenbiases poslabtopstatistics = targets’ * waketopstates pospentopstatistics = wakepenstates’*waketopstates negpentopstatistics = negpenstates’ * negtopstates neglabtopstatistics = neglabprobs’ * negtopstates 37 neglabprobs targets
  • 38. Top level layer update Pseudo-Code(8) Updates to top level associative memory labtop = labtop + r*(poslabtopstatistics-neglabtopstatistics) labgenbiases = labgenbiases + r*(targets – neglabprobs) pentop = pentop + r*(pospentopstatistics – negpentopstatistics) pengenbiases = pengenbiases + r*(wakepenstates – negpenstates) topbiases = topbiases + r*(waketopstates – negtopstates) poslabtopstatistics = targets’ * waketopstates pospentopstatistics = wakepenstates’*waketopstates negpentopstatistics = negpenstates’ * negtopstates neglabtopstatistics = neglabprobs’ * negtopstates 1 topbiases sleeppenstates toppen pengenbiases negtopstates topbiases 1 waketopstates wakepenstates pentop 38 negpenstates(8-9 page)
  • 39. Recognition weight update Pseudo-Code(9) Updates to recognition/inference approximation parameters hidpen = hidpen + r*(sleephidstates’*(sleeppenstates – psleeppenstates)) penrecbiases = penrecbiases + r*(sleeppenstates – psleeppenstates) vishid = vishid + r*(sleepvisprobs’*(sleephidstates – psleephidstates)) hidrecbiases = hidrecbiases + r*(sleephidstates – psleephidstates) 39 psleeppenstates sleephidstates sleepvisprobs hidpen 1 penrecbiasessleeppenstates 39
  • 40. Recognition weight update Pseudo-Code(9) Updates to recognition/inference approximation parameters hidpen = hidpen + r*(sleephidstates’*(sleeppenstates – psleeppenstates)) penrecbiases = penrecbiases + r*(sleeppenstates – psleeppenstates) vishid = vishid + r*(sleepvisprobs’*(sleephidstates – psleephidstates)) hidrecbiases = hidrecbiases + r*(sleephidstates – psleephidstates) data 1 hidrecbiases vishid psleephidstates sleephidstates
  • 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관련 문일철 교수님 강의