Transcript Document

Competitive Learning &
Vector Quantization &
Self-Organizing Maps
CL,競爭學習
VQ,向量量化網路
SOM,自組成映射圖網路
競爭學習(Competitive Learning)
概述
非監督式學習
Two layers(全連結)
• 輸入層
• 競爭層(輸出層)
競爭學習
• 競爭處理
• 學習聚類
輸出層神經元彼此競爭被
命中者即為優勝單元
當優勝單元出現時,允許
修正輸入層各神經元與優
勝單元間的權重值
競爭學習(續)
每個輸出節點即代表一種聚類,輸出值
正好就是與聚類的距離
wi1
Ii=D(wi, x)
…..
…….
x
wi2
win
D(u,v) is a distance measurement
Function. Euclidean distance
D(u,v)=|u-v|
競爭學習(續)
D(w1, x)
D(w2, x)
:
:
D(wn, x)
x
next x
Update weights
儘量調節 weight 接近 input
取最小的
輸出進行
權重值修
正
競爭學習(續)
Kohonen Learning law
Start with random weight vectors.
Each Kohonen unit calculates its input intensity Ii.
A competition takes place to see which unit has the smallest input intensity.
(Which unit has its weight vector wi closest x ?)
Once the winning Kohonen unit is determined, its output is set to 1 and all of the
Other Kohonen unit output signals are set to 0.
Training set : {x1, x2, …}
1 if i  argmin (D(w j , x))
j 1,...,m
Zi  
else
0
winew  wiold   x  wiold Z i ,   (0,1]
new
old
For the winning processing element wi  (1   ) wi   x
For the losing processing element wnew  wold
i
i
競爭學習(續)
漢明距(Hamming distance)
漢明空間(Hamming space)


H  x  x1 , x2 , ..., xn   R n , xi  1
n
T
共有2n個點,每個點皆與原點等距
H38 points
x向量與y向量不同
的個數即為漢明距
競爭學習(續)
漢明距(Hamming distance)
y = (y1, y2, …, yn)T xi , yi {1}
x = (x1, x2, …, xn)T
The Euclidean distance between th e two vectors is
d
x
  x2  y2   ...  xn  yn 
1  y1
2
2
2
 4(# mismatched components of x anf y)
Hamming distance
h  # mismatched components of x and y
(the number of bits that are different between x anf y)
d2
h
4
A
B
output
競爭學習(續)
範例
P1=(1, 0, 1)
P2=(1, 0, 0)
P3=(0, 1, 0)
P4=(0, 1, 1)
P1=(1, 0, 1)
P3=(0, 1, 0)
有三組不同
Distance=3
input
Hamming distance
P1
P2
P3
P4
P1
0
1
3
2
P2
1
0
2
3
P3
3
2
0
1
P4
2
3
1
0
P1
P2
Class A
P3
P4
Class B
向量量化網路(Vector Quantization)
非監督式學習網路
將輸入向量轉換到有限分類中的其中一
類
Input vector xi (i=1,2,…,n) wj (j=1,2,…,m)
亦即,將輸入向量xi映射至最接近的參考
權重向量wj
其中,m<n,j表示為分類的代號
向量量化網路(續)
網路架構
Output layer
Input layer
向量量化網路(續)
學習過程
1. 起始權重值設定
•
•
以亂數產生(小數值的亂數)
或以原始資料的前幾筆資料當作起始權重值
2. 藉由以下公式計算出原型(ptototype)單元
以展現輸入向量x
w  x  min w  x   x  w   w  x
2
n
c
i
i
j 1
j
ij
3. 依據下列公式進行權重向量的修正
2
i
wcnew  wcold   x  w c  for the winning unit c

new
old
w

w
for i  c

c
c
Y1
向量量化網路(續)
Y2
0 1 0
1
0
X1
X2
1
X3
避免強者愈強弱者愈弱可採用下式進行
第三步驟
wcnew  wcold   x  w c  for the winning unit c
 new
old
w

w
  x  w c 
for i  c
 c
c
X1=(0,1,0)
X2=(1,0,1)
X3=(1,1,1)
=0.6
0 1 
W  1 0


0 1
Y1=((0-0)2+(1-1)2+(0-0)2)=0
Y2=((0-1)2+(1-0)2+(0-1)2)=3
Y1為winner
修正與Y1連結的權重值
w11new  w11old   x1  w 11old   0  0.6  (0  0)  0
  1  0.6  (1  1)  1
w21new  w21old   x 2  w old
21
w31new  w31old   x 3  w 31old   0  0.6  (0  0)  0
向量量化網路(續)
X1=(0,1,0)
X2=(1,0,1)
X3=(1,1,1)
=0.6
0 1 
W  1 0


0 1
Y1=((1-0)2+(0-1)2+(1-0)2)=3
Y2=((1-1)2+(0-0)2+(1-1)2)=0
Y2為winner
修正與Y2連結的權重值
w12new  w12old   x1  w 12old   1  0.6  (1  1)  1
  0  0.6  (0  0)  0
w22new  w22old   x 2  w old
22
w32new  w32old   x 3  w 32old   1  0.6  (1  1)  1
X1=(0,1,0)
X2=(1,0,1)
X3=(1,1,1)
=0.6
0 1 
W  1 0


0 1
Y1=((1-0)2+(1-1)2+(1-0)2)=2
Y2=((1-1)2+(1-0)2+(1-1)2)=1
Y2為winner
修正與Y2連結的權重值
w12new  w12old   x1  w 12old   1  0.6  (1  1)  1
  0  0.6  (1  0)  0.6
w22new  w22old   x 2  w old
22
w32new  w32old   x 3  w 32old   1  0.6  (1  1)  1
自組成映射圖網路(SOM)
1980年由T. Kohonen提出
非監督式學習
拓樸映射圖
Two layers 網路(神經元全連結)
第二層由2D的網格組成
起始權重值以亂數取得(0,1)
可將連續值的n個向量聚為m種分類(n>m)
自組成映射圖網路(續)
網路架構
Competitive Layer
………….
……
Input Layer
Input : x
Weights : wj
The matching value for
Each unit j is ||x-wj||.
The unit with the lowest
matching value (the best
match) wins the competion
自組成映射圖網路(續)
SOM的程序
計算競爭層中每個神經元的值
尋找最小值者
確認圍繞優勝單元的鄰居範圍
以下式調整優勝者周邊鄰居的權重值
 xi  wij  if unit j is the neighborho od N C
wij  
0
otherwise

調整weight使周邊鄰居
wijnew  wijold  wij
愈來愈靠近優勝者
自組成映射圖網路(續)
鄰居的決定方式
C
R=2 Nc(t1)
R=1 Nc(t2)
R=0
C
自組成映射圖網路(續)
必須指定的兩個參數
學習速率,
學習速率開始可以設大
一點,然後慢慢減小
• 起始學習速率0=0.2 ~ 0.5
• 起始學習速率  t   0 1  t 
鄰居的範圍,NC
t

Rt  R0 1  
 T

T
T : 總訓練次數
t :目前的訓練次數
當聚類增加時,鄰居
範圍要相對縮減
• 通常R0的選擇方式為競爭層寬度的1/2或1/3
自組成映射圖網路(續)
Step 1. Initialize weights wij.
Set topological neighborhood parameters.
Set learning rate parameters.
Step 2. While stopping condition is false, do Dteps 3-9.
Step 3. For each input vector x, do Steps 4-6.
Step 4. For each j, compute :
演算法
D(i)   wij  xi 
2
i
Step 5. Find index J such that D(J) is a minimum.
Step 6. For all units j within a specified neighborhood of J, and for all i :
wijnew  wijold   xi  wijold 
Step 7. Update learning rate.
Step 8. Reduce radius of topological neighborhood at specified times.
Step 9. Test stopping condition.
自組成映射圖網路(續)
Exapmle
(1,1,0,0) ; (0,0,0,1) ; (1,0,0,0) ; (0,0,1,1).
m=2
(0)=0.6 , (t+1)=0.5(t)
僅有優勝單元允許修正權重值,R=0
Step 1 :
起始權重值矩陣
0.2
0.6

0.5

0.9
0.8
0.4
 , R  0 ,  (0)  0.6
0.7

0.3
自組成映射圖網路(續)
Step 4 : For first vector (1,1,0,0)
D(1)  (0.2  1) 2  (0.6  1) 2  (0.5  0) 2  (0.9  0) 2  1.86
D(2)  (0.8  1) 2  (0.4  1) 2  (0.7  0) 2  (0.3  0) 2  0.98
Step 5 : The vector is closest to output node 2, so J=2.
Step 6 : The weights on the winning unit are updated :
old
winew
 wiold
2
2  0.6( xi  wi 2 )
This gives the weight matrix :
0.2
0.6

0.5

0.9
0.92 
0.76 

0.28 

0.12 
Step 7 : reduce learning rate
=0.5×0.6=0.3
返回 Step 4 取第二個vector
繼續進行
:
:
自組成映射圖網路(續)
This gives the final weight matrix :
0.0
0.0

0.5

1.0
1.0 
0.5

0.0 

0.0 
Testing (1,1,0,1)
D(1)  (0.0  1) 2  (0.0  1) 2  (0.5  1) 2  (1.0  1) 2  2.25
D(2)  (1.0  1) 2  (0.5  1) 2  (0.0  0) 2  (0.0  1) 2  1.25
The vector is closest to output node 2, so J=2.
何時停止學習
可給訂一定的學習循環後結束(i.e. 10000次)