12
Part 2. Multi Layer Networks Output nodes Input nodes Hidden nodes Output vector Input vector

Part 2. Multi Layer Networks

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Part 2. Multi Layer Networks

Part 2. Multi Layer Networks

Output nodes

Input nodes

Hidden nodes

Output vector

Input vector

Page 2: Part 2. Multi Layer Networks

Sigmoid-Function for Continuous Output

x1

x2

xn

.

.

.

w1

w2

wn

a=i=0n wi xi

O =1/(1+e-a)

O

inputs

weights

activationoutput

Output between 0 and 1 (when a = negative infinity, O = 0; when a= positive infinity, O=1.

Page 3: Part 2. Multi Layer Networks

Gradient Descent Learning Rule

For each training example X, Let O be the output (bewteen 0 and 1) Let T be the correct target value

Continuous output O a= w1 x1 + … + wn xn + O =1/(1+e-a)

Train the wi’s such that they minimize the squared error

E[w1,…,wn] = ½ kD (Tk-Ok)2

where D is the set of training examples

Page 4: Part 2. Multi Layer Networks

Explanation: Gradient Descent Learning Rule

wi = a Ok (1-Ok) (Tk-Ok) xik

xi

wi

Ok

activation ofpre-synaptic neuron

error dk of

post-synaptic neuron

derivative of activation function

learning rate

Page 5: Part 2. Multi Layer Networks

Backpropagation Algorithm (Han, Figure 9.5)

Initialize each wi to some small random value

Until the termination condition is met, Do

For each training example <(x1,…xn),t> Do

Input the instance (x1,…,xn) to the network and compute the network outputs Ok

For each output unit k

Errk=Ok(1-Ok)(tk-Ok)

For each hidden unit h

Errh=Oh(1-Oh) k wh,k Errk

For each network weight wi,j Do

wi,j=wi,j+wi,j where

wi,j= a Errj* Oi,

θj=θj+θj where

θj = a Errj,

a: is learning rate, set by the user;

Page 6: Part 2. Multi Layer Networks

Multilayer Neural Network

Given the following neural network with initialized weights as in the picture(next page), we are trying to distinguish between nails and screws and an example of training tuples is as follows:

T1{0.6, 0.1, nail}

T2{0.2, 0.3, screw}

Let the learning rate (l) be 0.1. Do the forward propagation of the signals in the network using T1 as input, then perform the back propagation of the error. Show the changes of the weights. Given the new updated weights with T1, use T2 as input, show whether the predication is correct or not.

Page 7: Part 2. Multi Layer Networks

Multilayer Neural Network

Page 8: Part 2. Multi Layer Networks

Multilayer Neural Network

Answer:

First, use T1 as input and then perform the back propagation.

At Unit 3:

a3 =x1w13 +x2w23+θ3 =0.14

o3 = = 0.535

Similarly, at Unit 4,5,6:

a4 = 0.22, o4 = 0.555

a5 = 0.64, o5 = 0.655

a6 = 0.1345, o6 = 0.534

1

1+ e-a

Page 9: Part 2. Multi Layer Networks

Multilayer Neural Network

Now go back, perform the back propagation, starts at Unit 6: Err6 = o6 (1- o6) (t- o6) = 0.534 * (1-0.534)*(1-0.534) =

0.116 ∆w36 = (l) Err6 O3 = 0.1 * 0.116 * 0.535 = 0.0062 w36 = w36 + ∆w36 = -0.394 ∆w46 = (l) Err6 O4 = 0.1 * 0.116 * 0.555 = 0.0064 w46 = w46 + ∆w46 = 0.1064 ∆w56 = (l) Err6 O5 = 0.1 * 0.116 * 0.655 = 0.0076 w56 = w56 + ∆w56 = 0.6076 θ6 = θ6 + (l) Err6 = -0.1 + 0.1 * 0.116 = -0.0884

Page 10: Part 2. Multi Layer Networks

Multilayer Neural Network

Continue back propagation: Error at Unit 3:

Err3 = o3 (1- o3) (w36 Err6) = 0.535 * (1-0.535) * (-0.394*0.116) = -0. 0114w13 = w13 + ∆w13 = w13 + (l) Err3X1 = 0.1 + 0.1*(-0.0114) * 0.6 = 0.09932w23 = w23 + ∆w23 = w23 + (l) Err3X2 = -0.2 + 0.1*(-0.0114) * 0.1 = -0.2001154θ3 = θ3 + (l) Err3 = 0.1 + 0.1 * (-0.0114) = 0.09886

Error at Unit 4:Err4 = o4 (1- o4) (w46 Err6) = 0.555 * (1-0.555) * (-0.1064*0.116) = 0.003w14 = w14 + ∆w14 = w14 + (l) Err4X1 = 0 + 0.1*(-0.003) * 0.6 = 0.00018w24 = w24 + ∆w24 = w24 + (l) Err4X2 = 0.2 + 0.1*(-0.003) * 0.1 = 0.20003θ4 = θ4 + (l) Err4 = 0.2 + 0.1 * (0.003) = 0.2003

Error at Unit 5:Err5 = o5 (1- o5) (w56 Err6) = 0.655 * (1-0.655) * (-0. 6076*0.116) = 0.016w15 = w15 + ∆w15 = w15 + (l) Err5X1 = 0.3 + 0.1* 0.016 * 0.6 = 0.30096w25 = w25 + ∆w25 = w25 + (l) Err5X2 = -0.4 + 0.1*0.016 * 0.1 = -0.39984θ5= θ5 + (l) Err5 = 0.5 + 0.1 * 0.016 = 0.5016

Page 11: Part 2. Multi Layer Networks

Multilayer Neural Network

After T1, the updated values are as follows:

Now, with the updated values, use T2 as input: At Unit 3:

a3 = x1w13 + x2w23 + θ3 = 0.0586898

o3 = = 0.515

w13 w14 w15 w23 w24 w25 w36 w46 w56

0.09932 0.00018 0.30096 -0.2001154 0.20003 -0.39984 -0.394 0.1064 0.6076

θ3 θ4 θ5 θ6 0.09886 0.2003 0.5016 -0.0884

1

1+ e-a

Page 12: Part 2. Multi Layer Networks

Multilayer Neural Network

Similarly,

a4 = 0.260345, o4 = 0.565

a5 = 0.441852, o5 = 0.6087

At Unit 6:

a6 = x3w36 + x4w46 + x5w56 + θ6 = 0.13865

o6 = = 0.5348

Since O6 is closer to 1, so the prediction should be nail, different from given “screw”.

So this predication is NOT correct.

1

1+ e-a