1 The Threshold Logic Unit (TLU)

Download Report

Transcript 1 The Threshold Logic Unit (TLU)

Chapter 3 Simple Supervised learning
The Threshold Logic Unit (TLU),
McCulloch&Pitts, 1943 is the simplest model
of an artificial neuron.
1
TLU is the feedforward structure,
which only one of several available.
The feedforward is used to place an
input pattern into one of several
classes according to the resulting
pattern of outputs.
2
The requirements of McCulloch-Pitts
1. The activation is binary. (1 is fire or 0 is
not fire)
2. The neurons are connected by directed,
weighted paths.
3. A connection path is excitatory if the
weight on the path is positive; otherwise
it is inhibitory. (All excitatory connections
into a particular neuron have the same
weights)
3
The requirements of McCulloch-Pitts
4. Each neuron has a fixed threshold such
that if the net input is greater than
threshold, the neuron fires.
5. The threshold is set so that inhibition is
absolute. That is, any nonzero inhibitory
input will prevent the neuron from firing.
6. It takes one time step for a signal to pass
over one connection link.
4
Simple McCulloch-Pitts Architecture
1 if y _ in  θ
f ( y _ in)  
 0 if y _ in  θ
2
X1
X2
X3
2
Y
-1
5
Algorithm
The weights for neuron are set,
together with the threshold for the
neuron’s activation function, thus the
neuron will perform a simple logic
function.
We used the simple neurons as
building blocks, that can model any
function that can be represented as a
logic function. Rather than a training
algorithm, it is used to determine the
values of weights and threshold.
6
Simple networks for logic functions
The binary form of the functions
for AND, OR and AND NOT are
defined for reference the neuron’s
activation function. This defined
the threshold on Y unit to be 2.
X1
W1
Y
X2
W2
7
AND function
gives the following four training input,
target output pairs :
X1 X2 
Y
0
0
0
0
1
0
1
0
0
1
1
1
จะสามารถกาหนด w1 และ w2 มีคา
่ เท่าก ับ ?
8
OR function
gives the following four training input,
target output pairs :
X1 X2 
Y
0
0
0
0
1
1
1
0
1
1
1
1
จะสามารถกาหนด w1 และ w2 มีคา
่ เท่าก ับ ?
9
AND NOT function
gives the following four training input,
target output pairs :
X1 X2 
Y
0
0
0
0
1
0
1
0
1
1
1
0
จะสามารถกาหนด w1 มีคา
่ เท่าก ับ ? และ
w2 มีคา
่ เท่าก ับ ?
10
XOR function
x1 XOR x2  (x1 AND NOT x2) OR (x2 AND NOT x1)
How to model the network for XOR function?
11
2.1 Pattern Classification
For NN approach, we assume that there are
a set of training patterns for which the correct
classification is known. In the simplest case,
we find the output unit represents
membership in the class with a response of 1;
a response of -1 (or 0) indicates the pattern
is not a member of the class.
Simple Pattern Classification
The activation function
y_in = w1x1+ w2x2 +….+ wnxn
The output (bipolar value)
f(y_in) =
-1 if y_in < threshold
1 if y_in >= threshold
AND TLU : threshold = 3
w1, w2 = ?
activation output
x1
x2
-1
-1
-1
-1
1
-1
1
-1
-1
1
1
1
14
2.2 The linear separation of classes
Critical condition of classification :
the activation equals the threshold
n
w x
i 1
i
i

For 2-D case :
w1 x1  w2 x2  
กรณี binary input ทีก
่ าหนด w1, w2 = 1
threshold = 1.5
x2  ax1  b
: a = -1 , b =1.5
16
2.3 Biases and Thresholds
A bias acts as a weight on a connection from
a unit whose activation is always 1. Increasing
the bias increases the net input to the unit.
net = b + n wnxn
The output
-1 if net < 0
f(net) =
1 if net >= 0
Single Layer with a Binary Step Function
Consider a network with 2 inputs and 1 output
node (2 classes).
The net output of the network is a linear function
of the weights and the inputs.
net = W X = x1 w1 + x2 w2
y = f(net)
x1 w1 + x2 w2 = 0 defines a straight line through the input space.
x2 = - w1/w2 x1 <- this is line through the origin with slope -w1/w2
Bias (threshold)
What if the line dividing the 2 classes does not
go through the origin?
2.4 The inner products
v = (1,1) และ w =(0,2)
ั ันธ์ของมุมก ับค่าผลคูณ
ความสมพ
Vector Projections
v  w  v w cos
vw
vw 
w
2.5 Inner products and TLUs
a  w x  w x  
ด ังนน
ั้
23
แยกได้เป็น 2 กรณี (2 classes)
กรณี 1
24
กรณี 2
25
Other interesting geometric points to note:
•The weight vector (w1, w2) is normal to
the decision boundary.
Proof: Suppose z1 and z2 are points on the
decision boundary.
26
27
2.6 Training TLUs
Training Methods : three kinds of methods
for training single-layer networks that do
pattern classification.
• Hebb net - earliest and simplest learning rule
• Perceptron - guaranteed to find the right
weights if they exist
• The Adaline (uses Delta Rule) - can easily
be generalized to multi-layer
nets (nonlinear problems)
Hebb Algorithm
Step 0. Initialize all weights :
wi = 0 (i=1 to n)
Step 1. For each input training vector and target
output pair, s : t, do steps 2-4
Step 2. Set activations for input units :
xi = si ( i=1 to n)
Step 3. Set activation for output unit:
y=t
Step 4. Adjust the weights for
wi(new) = wi(old) + xiy
Adjust the bias
b(new) = b(old) + y
2.7 Perceptron
Rosenblatt introduced it in 1962.
Perceptron consists of a TLU whose
inputs come from a set of preprocessing
association units.
30
Perceptron Training
ใน training unit จะมีการปร ับ weight
vector และ threshold เพือ
่ ได้คา่ สาหร ับ
การแบ่งกลุม
่ ทีเ่ หมาะสม
การปร ับค่า weight
กรณี 1
กรณี 2
โดย 0    1
32
้ ารเรียนรูอ
Perceptron ใชก
้ ย่างง่าย
ทีเ่ รียกว่า simple training rule
จากรูป p1 คือ training input
p2 คือ training input
34
Perceptron Algorithm
Step 0. Initialize all weights :
wi = 0 (i=1 to n)
Set learning rate  ( 0 < <= 1)
Step 1. While stopping condition is false, do steps
2-6
Step 2. For each training pair s:t, do steps 3-5.
Step 3. Set activation of input units:
xi = si ( i=1 to n)
Step 4. Compute the response of output unit:
y_in = b + xiwi
1 if y_in > 
y = 0 if - <= y_in <=
-1 if y_in < -
Perceptron Algorithm
Step 5. Update the weights and bias if an error
occurred for this pattern
if y  t
wi(new) = wi(old) + xit
b(new) = b(old) + t
else
wi(new) = wi(old)
b(new) = b(old)
Step 6. Test stopping condition:
if no weights changed in Step2, stop;
else, continue.
การบ้าน
จงเขียนโปรแกรมเพือ
่ ทาการเรียนรู ้
ั OR ทีม
ฟังก์ชน
่ ค
ี า่ weight 0.1,
0.2 และ threshold=0.5 โดยมี
learning rate = 0.3
37
2.8 Perceptron as classifiers
การใช ้ perceptron training algorithm
อาจใชใ้ นการแบ่งข้อมูล (linearly separable
classes)
ถ้ามี 4 คลาสและจะทาการแบ่ง 2 ระนาบ
จะเขียน pattern space ได้ด ังรูป
เริม
่ จาก train two units เพือ
่ ทาการแบ่ง
เป็น 2 กลุม
่ ก่อน จะได้เป็น (A B) (C D)
และ (A D) (B C) ด ังนี้
output
ั ันธ์ของ 2 units เป็น 2 กลุม
จากความสมพ
่
ถ้าแบ่งเป็น 4 กลุม
่ จะได้ด ังนี้
41
โครงสร้างของ network ในการแบ่งข้อมูล
42
2.9 ADALINE
Adaptive Linear Neuron using delta rule
for training. An ADALINE is a special case in
which there is only one output unit.
Architecture of ADALINE is a single neuron
that receives input from several units.
w1
x1
.
.
.
xn
1
wn
b
Y
สมการปร ับค่า weight
w  w   (t  y)v
นน
่ ั คือ
wi   (t  y)vi
เรียกว่า a training rule หรือ learning rule
และ พารามิเตอร์  เรียกว่า learning rate
44
การเรียนรูแ
้ บบ supervise ใน neural นน
ั้
เป็นการเรียนรูข
้ อ
้ มูลจาก training set ซงึ่
ข้อมูลนนจะมี
ั้
รป
ู แบบ output ทีก
่ าหนดไว้แล้ว
ระบบ network จะนาข้อมูลเข้ามาทางาน
ภายใต้ learning rule เพือ
่ ปร ับค่า weight
จนกระทงได้
่ั
คา่ weight ทีเ่ หมาะสมสาหร ับ
นาไปใชง้ านต่อไป ซงึ่ ค่า weight ทีเ่ หมาะสม
จะพิจารณาเมือ
่ network นน
ั้ convergence
ถึงจุดทีไ่ ม่มก
ี ารเปลีย
่ นแปลงข้อมูล
45
Training Algorithm
Step 0. Initialize weights. (Small random values)
set learning rate .
Step 1. While stopping condition is false, do Step 2-6.
Step 2. For each bipolar training pair s:t,
do Step 3-5.
Step 3. Set activations of input units,
i=1,…,n
xi = si
Step 4. Compute net input to output
y_in = b + xiwi
Step 5. Update bias and weights
b(new) = b(old)+(t-y_in)
wi(new) = wi(old )+(t-y_in)xi
Step 6. Test for stopping condition.
2.10 Delta rule : minimizing an error
2.10.1 Hebb’s learning law
From linear associator network, the
output vector y’ is derived from the
input vector x by means of this formula.
y '  Wx
where W = (wij) is the
m x n weight matrix.
47
2.10.2 gradient descent function
48
y
y  y  x
x
y  slope x x
กำหนดให้ x   x slope
ด ังนน
ั้
y   ( slope )
จากค่า slope ทีย
่ กกาล ังสอง ทาให้คา
่ เป็นบวกเสมอ
่ ผลให้
และเมือ
่ คูณด้วยพารามิเตอร์ทม
ี่ ค
ี า
่ เป็นลบ สง
สมการข้างต้นมีคา
่ <0 ด ังนนจึ
ั้ งมีล ักษณะเป็น
“travelled down”
49
2
Delta rule is also known as
- Widrow-Hoff rule
- Least Mean Squares (LMS) rule
To train the network, we adjust the weights
in the network so as to decrease the cost
(this is where we require differentiability).
This is called gradient descent.
Delta Rule: Training by Gradient Descent Revisited
50
2.10.3 Gradient descent on error
The early ADALINE(ADAptive LInear
NEuron) model of Widrow and Hoff is
discussed as a simple type of processing
element. The Widrow learning law applied
minimizing error as the delta rule.
51
Delta rule จะทาการคานวณ error ทีเ่ กิดจาก
training set ของแต่ละครงั้ แล้วนาค่านนไป
ั้
ั
พิจารณาเป็นฟังก์ชนของ
weight ในรูปของ
gradient descent on the error
1
2
Ep  ( t  y )
2
ั
จากสมการ ค่า error Ep คือฟังก์ชนของ
weights
สาหร ับ input pattern 1 input ด ังนนค่
ั้ าของ
error ทงหมด
ั้
(Total error, E) แสดงด ังนี้
1n
2
E  ( t i  y i )
2 i 1
1n
2
E  ( t i  y i )
2 i 1
The learning algorithm terminates once we are
at, or sufficiently near to, the minimum of the
error function, where dE/dw = 0. We say
then that the algorithm has converged.
53
An important consideration is the learning
rate µ, which determines by how much
we change the weights w at each step.
If µ is too small, the algorithm will take
a long time to converge.
54
Conversely, if µ is too large, we may
end up bouncing around the error
surface out of control - the algorithm
diverges. This usually ends with an
overflow error in the computer's
floating-point arithmetic.
55
shows E for a range of values of w0 and w1
56
สาหร ับ delta rule ใน TLUs จะใช ้ activation
แทนค่า output (y) จะได้สมการด ังนี้
1
2
Ep  ( t  a )
2
การปร ับค่า weight ของ input แต่ละต ัว ตาม
่ ง output เป็น
การทางานของ TLU โดยปร ับชว
-1, 1 จะได้สมการปร ับ weight คือ
wi   ( t  a )x i
้ ับ semilinear สมการจะปร ับให้สอดคล้อง
ถ้าใชก
ก ับ sigmoid function โดยเพิม
่ derivative เข้า
ไปในสมการ
w i   ( a )( t  y ) x i
d ( a ) 1
 ( a ) 
  ( a )( 1   ( a ))
da
