Docsity

Multi-Layer Perceptions - Study Materials | CPSC 636, Study notes of Computer Science

Toggle sidebar
bg1
Slide04
Haykin Chapter 4: Multi-Layer
Perceptrons
CPSC 636-600
Instructor: Yoonsuck Choe
Spring 2008
Some materials from this lecture are from Mitchell (1997) Machine Learning, McGraw-Hill.
1
Introduction
•Networks typically consisting of input, hidden, and output layers.
•Commonly referred to as Multilayer perceptrons.
•Popular learning algorithm is the error backpropagation algorithm
(backpropagation, or backprop, for short), which is a generalization of the
LMS rule.
–Forward pass: activate the network, layer by layer
–Backward pass: error signal backpropagates from output to hidden
and hidden to input, based on which weights are updated.
2
Multilayer Perceptrons: Characteristics
•Each model neuron has a nonlinear activation function, typically a logistic
function:yj=1
1+exp(−vj)
•Network contains one or more hidden layers (layers that are not either an
input or an output layer).
•Network exhibits a high degree of connectivity.
3
Multilayer Networks
•Differentiable threshold unit: sigmoid φ(v) = 1
1+exp(−v).Interesting
property: dφ(v)
dv =φ(v)(1 −φ(v)).
•Output: y=φ(xTw)
•Other functions: tanh(v) = exp(−2v)−1
exp(−2v)+1
4
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Multi-Layer Perceptions - Study Materials | CPSC 636 and more Study notes Computer Science in PDF only on Docsity!

Slide

Haykin Chapter 4: Multi-Layer

Perceptrons

CPSC 636-

Instructor: Yoonsuck Choe Spring 2008

Some materials from this lecture are from Mitchell (1997) Machine Learning, McGraw-Hill.

1

Introduction

  • Networks typically consisting of input, hidden, and output layers.
  • Commonly referred to as Multilayer perceptrons.
  • Popular learning algorithm is the error backpropagation algorithm (backpropagation, or backprop, for short), which is a generalization of the LMS rule. - Forward pass: activate the network, layer by layer - Backward pass: error signal backpropagates from output to hidden and hidden to input, based on which weights are updated.

2

Multilayer Perceptrons: Characteristics

  • Each model neuron has a nonlinear activation function, typically a logistic function: yj = (^) 1+exp(^1 −vj )
  • Network contains one or more hidden layers (layers that are not either an input or an output layer).
  • Network exhibits a high degree of connectivity.

Multilayer Networks

  • Differentiable threshold unit: sigmoid φ(v) = (^) 1+exp(^1 −v). Interesting property: dφ dv(v )= φ(v)(1 − φ(v)).
  • Output: y = φ(xT^ w)
  • Other functions: tanh(v) = exp(exp(−−^22 vv))+1−^1

Multilayer Networks and Backpropagation

F1 F

head hid (^) ... ...who’d hood

  • Nonlinear decision surfaces.

(^0) 0.2 (^) 0.4 (^) 0.6 (^) 0. 1 0 0.2^ 0.

0.6^ 0.8^1

0.1^ 0.2^ 0.3 0 0.4^ 0.5^ 0.6^ 0.

0.8^ 0.9^1

Output sigm(x+y-1.1)^ 0.8 0.6 0.

Input 1 Input 2

Output

(^0) 0.2 (^) 0.4 (^) 0.6 (^) 0. 1 0 0.2^ 0.

0.6^ 0.8^1

0.505^ 0.515^ 0.51 0.

0.525^ 0.535 0.52^ 0.

0.545 0.54^ 0.

Output sigm(sigm(x+y-1.1)+sigm(-x-y+1.13)-1)^ 0.54 0.53 0.

Input 1 Input 2

Output

(a) One output (b) Two hidden, one output

  • Another example: XOR 5

Error Gradient for a Single Sigmoid Unit

For n input-output pairs {(xk , dk )}nk=1: ∂E ∂wi^ =^

∂wi

X

k

(dk − yk )^2

= (^12)

X

k

∂wi^ (dk^ −^ yk^ )

2

X

k

2(dk − yk ) (^) ∂w∂ i

(dk − yk )

X

k

(dk − yk )

− ∂y ∂wk i

X

k

(dk − yk ) ∂y ∂vk k

∂vk | {z^ ∂w i} Chain rule

6

Error Gradient for a Sigmoid Unit

From the previous page:

∂E ∂wi^ =^ −^

X

k

(dk − yk ) ∂y ∂vk k

∂vk ∂wi

But we know: ∂yk ∂vk^ =^

∂φ(vk ) ∂vk^ =^ yk^ (1^ −^ yk^ )

∂vk ∂wi^ =^

∂(xTk w) ∂wi^ =^ xi,k

So: ∂E ∂wi^ =^ −^

X

k

(dk − yk )yk (1 − yk )xi,k

Backpropagation Algorithm

Initialize all weights to small random numbers. Until satisfied, Do

  • For each training example, Do
    1. Input the training example to the network and compute the network outputs
    2. For each output unit j δj ← yj (1 − yj )(dj − yj )
    3. For each hidden unit h δh ← yh(1 − yh) P j∈outputs wjhδj
    4. Update each network weight wi,j wji ← wji + ∆wji where ∆wji = ηδj xi. Note: wji is the weight from i to j (i.e., wj←i ).

Derivation of ∆w : Output Unit Weights

From the previous page:

∂E

∂vj

∂E

∂yj

∂yj

∂vj

= −(dj − yj )yj (1 − yj ).

Since ∂w∂vjij = ∂^

P i′^ wji′^ xi′

∂wji =^ xi,

∂E

∂wji

= ∂E

∂vj

∂vj

∂wji

= − (dj − yj )yj (1 − yj )

| {z }

δj =error×φ′(net)

|{z}^ xi

input

13

Derivation of ∆w : Hidden Unit Weights

Start with ∂w∂Eji = ∂v∂Ej ∂w^ ∂vjji = ∂v∂Ej xi:

∂E

∂vj^ =^

X

k∈Downstream(j)

∂E

∂vk

∂vk ∂vj

=

X

k∈Downstream(j)

−δk^ ∂v ∂vk j

=

X

k∈Downstream(j)

−δk^ ∂v ∂yk j

∂yj ∂vj

=

X

k∈Downstream(j)

−δk wkj^ ∂y ∂vj j =

X

k∈Downstream(j)

−δk wkj yj (1 − yj ) | {z } φ′(net)

(1)

14

Derivation of ∆w : Hidden Unit Weights

Finally, given ∂E ∂wji^ =^

∂E

∂vj

∂vj ∂wji^ =^

∂E

∂vj^ xi, and ∂E ∂vj^ =^

X

k∈Downstream(j)

−δk wkj yj (1 − yj ) | {z } φ′(net)

∆wji = −η (^) ∂w∂E ji

= η [yj (1 − yj ) | {z } φ′(net)

X

k∈Downstream(j)

δk wk j | {z } error

]

| {z } δj

xi

Summary

∆wji(n)

| {z }

weight correction

= |{z}η

learning rate

· δj (n)

| {z }

local gradient

· yi(n)

| {z }

input signal

Extension to Different Network Topologies

input

hidden

output

wji

wkj j

i

k

  • Arbitrary number of layers: for neurons in layer m:

δr = yr (1 − yr )

X

s∈layer m+

wsr δs.

  • Arbitrary acyclic graph:

δr = yr (1 − yr )

X

s∈Downstream(r)

wsr δs.

17

Backpropagation: Properties

  • Gradient descent over entire network weight vector.
  • Easily generalized to arbitrary directed graphs.
  • Will find a local, not necessarily global error minimum: - In practice, often works well (can run multiple times with different initial weights).
  • Minimizes error over training examples: - Will it generalize well to subsequent examples?
  • Training can take thousands of iterations → slow!
  • Using the network after training is very fast.

18

Learning Rate and Momentum

  • Tradeoffs regarding learning rate: - Smaller learning rate: smoother trajectory but slower convergence - Larger learning rate: fast convergence, but can become unstable.
  • Momentum can help overcome the issues above.

∆wji(n) = ηδj (n)yi(n) + α∆wji(n − 1).

The update rule can be written as:

∆wji(n) = η

X^ n

t=

αn−tδj (t)yi(t) = −η

X^ n

t=

αn−t^ ∂E(t)

∂wji(t)

Momentum (cont’d)

∆wji(n) =

X^ n

t=

αn−t^ ∂E(t)

∂wji(t)

  • The weight vector is the sum of an exponentially weighted time series.
  • Behavior: - When successive (^) ∂w∂Eji(t()t) take the same sign: Weight update is accelerated (speed up downhill). - When successive (^) ∂w∂Eji(t()t) have different signs: Weight update is damped (stabilize oscillation).

Learned Hidden Layer Representations

  • Learned encoding is similar to standard 3-bit binary code.
  • Automatic discovery of useful hidden layer representations is a key feature of ANN.
  • Note: The hidden layer representation is compressed. 25

Overfitting

0.002^ 0.

0.004^ 0.

0.006^ 0.

0.008^ 0.

0 5000 10000 15000 20000

Error

Number of weight updates

Error versus weight updates (example 1) Validation set errorTraining set error

0.01 0 0.02^ 0.

0.04^ 0.

0.06^ 0.

0 1000 2000 3000 4000 5000 6000

Error

Number of weight updates

Error versus weight updates (example 2) Validation set errorTraining set error

  • Error in two different robot perception tasks.
  • Training set and validation set error.
  • Early stopping ensures good performance on unobserved samples, but must be careful.
  • Weight decay, use of validation sets, use of k-fold cross-validation, etc. to overcome the problem.

26

Recurrent Networks

output

hidden

input context

delay

  • Sequence recognition.
  • Store tree structure (next slide).
  • Can be trained with plain backpropagation.
  • Generalization may not be perfect.

Recurrent Networks (Cont’d)

A B

A B

(A, B)

C (A, B)

(C, A, B)

C (A, B)

input

delay

stack

input stack delay input, stack

  • Autoassociation (intput = output)
  • Represent a stack using the hidden layer representation.
  • Accuracy depends on numerical precision.

Some Applications: NETtalk

  • NETtalk: Sejnowski and Rosenberg (1987).
  • Learn to pronounce English text.
  • Demo
  • Data available in UCI ML repository

29

NETtalk data

aardvark a-rdvark 1<<<>2<<

aback xb@k-0>1<<

abacus @bxkxs 1<0>0<

abaft xb@ft 0>1<<

abalone @bxloni 2<0>1>0 0

abandon xb@ndxn 0>1<>0<

abase xbes-0>1<<

abash xb@S-0>1<<

abate xbet-0>1<<

abatis @bxti-1<0>2<

  • Word – Pronunciation – Stress/Syllable
  • about 20,000 words 30

More Applications: Data Compression

  • Construct an autoassocia- tive memory where Input = Output.
  • Train with small hidden layer.
  • Encode using input-to- hidden weights.
  • Send or store hidden layer activation.
  • Decode received or stored hidden layer activation with the hidden-to-output weights.

Backpropagation Exercise

  • URL: http://www.cs.tamu.edu/faculty/choe/src/backprop-1.6.tar.gz
  • Untar and read the README file:

gzip -dc backprop-1.6.tar.gz | tar

xvf -

  • Run make to build (on departmental unix machines).
  • Run ./bp conf/xor.conf etc.

MLP as a General Function Approximator (cont’d)

  • The universal approximation theorem is an existence theorem, and it merely generalizes approximations by finite Fourier series.
  • The universal approximation theorem is directly applicable to neural networks (MLP), and it implies that one hidden layer is sufficient.
  • The theorem does not say that a single hidden layer is optimum in terms of learning time, generalization, etc.

37

Generalization

  • A network is said to generalize well when the input-output mapping computed by the network is correct (or nearly so) for test data never used during training.
  • This view is apt when we take the curve-fitting view.
  • Issues: overfitting or overtraining , due to memorization. Smoothness in the mapping is desired, and this is related to criteria like Occam’s razor.

38

Generalization and Training Set Size

  • Generalization is influenced by three factors: - Size of the training set, and how representative they are. - The architecture of the network. - Physical complexity of the problem.
  • Sample complexity and VC dimension are related. In practice,

N = O

W

where W is the total number of free parameters, and  is the

error tolerance.

Training Set Size and Curse of Dimensionality

1D: 4 inputs 2D: 16 inputs 3D: 64 inputs

  • As the dimensionality of the input grows, exponentially more inputs are needed to maintain the same density in unit space.
  • In other words, the sampling density of N inputs in

m-dimensional space is proportional to N 1 /m.

  • One way to overcome this is to use prior knowledge about the function.

Cross-Validation

Use of validation set (not used during training, used for measuring generalizability).

  • Model selection
  • Early stopping
  • Hold-out method : multiple cross-validation, leave-one-out method, etc. 41

Virtues and Limitations of Backprop

  • Connectionism : biological metaphor, local computation, graceful degradation, paralellism. (Some limitations exist regarding the biological plausibility of backprop.)
  • Feature detection : hidden neurons perform feature detection.
  • Function approximation : a form of nested sigmoid.
  • Computational complexity : computation is polynomial in the number of adjustable parameters, thus it can be said to be efficient.
  • Sensitivity analysis : sensitivity SFω = ∂F /F∂ω/ω can be estimated efficiently.
  • Robustness : disturbances can only cause small estimation errors.
  • Convergence : stochastic approximation, and it can be slow.
  • Local minima and scaling issues

42

Heuristic for Accelerating Convergence

Learning rate adaptation

  • Separate learning rate for each tunable weight.
  • Each learning rate is allowed to adjust after each iteration.
  • If the derivative of the cost function has the same sign for several iterations, increase the learning rate.
  • If the derivative of the cost function alternates the sign over several iterations, decrease the learning rate.

Summary

  • Backprop for MLP is local and efficient (in calculating the partial derivative).
  • Backprop can handle nonlinear mappings.