Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Ch22 Presn PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

22

Practical Training Issues

1
22 Network Training Steps

Collect/Preprocess Select Network Select Training


Data Type/Architecture Algorithm

Initialize Weights
Analyze Network &
Performance Train Network

Use Network

2
22 Selection of Data

Data must adequately cover the relevant regions of the


input space (to avoid extrapolation).
Divide the data into training, validation and testing subsets
(70%, 15%, 15%).
Each of the subsets must cover the same parts of the input
space.
The amount of data required depends on the complexity of
the function being approximated (or the complexity of the
decision boundary).
Post-training analysis may be needed to determine the
adequacy of the data.

3
22 Determination of Input Range

4
22 Data Preprocessing

Normalize inputs/targets to the range [-1,1].


n m in max min
p = 2 (p p )./ (p p ) 1

Normalize inputs/targets to zero mean and unity variance.


n m e an s td
p = (p p )./p

Nonlinear transformations.

pt = 1 / p p t = exp(p )

Feature extraction (dimensionality reduction).


Principal components
5
22 Coding Targets (Pattern Classification)

There are three common ways to code targets. Assume that


we have N classes.
1) You can have a scalar target that takes on N possible
values (e.g., 1, 2, , N)
2) You can code the target in binary code. This requires P
output neurons, where 2P is greater than or equal to N.
3) You can have N neurons in the output layer. The targets
will be vectors whose elements are all equal to zero, except
for the neuron that corresponds to the correct class.
Method 3) generally produces the best results.

6
22 Importance of Transfer Function

When coding the targets, we need to consider the output


layer transfer function.
For pattern recognition problems, we would typically use
log-sigmoid or tangent-sigmoid.
If we use the tangent-sigmoid in the last layer, which is
more common, then we might consider assigning target
values to -1 or 1.
This tends to cause training difficulties (saturation of the
sigmoid function).
It is better to assign target values at the point where the
second derivative of the sigmoid function is maximum.
This occurs when the net input is -1 and 1, which
corresponds to output values of -0.76 and +0.76.

7
22 Softmax Transfer Function

If the network outputs should correspond to probabilities


of belonging to a certain class, the softmax transfer
function can be used.

exp (n )
ai = f (n i ) = -
----
-----------------i------
S

exp ( n j)
j=1

8
22 Missing Data

Replace the missing values in the input vector with the


average value for that element of the input. Add an
additional variable to the input vector as a flag to indicate
missing data.
For missing elements of the target vectors, do not include
them in the calculation of squared error.

9
22 Problem Types
Fitting (nonlinear regression). Map between a set of inputs and a
corresponding set of targets. (e.g., estimate home prices from tax rate,
pupil/teacher ratio, etc.; estimate emission levels from fuel
consumption and speed; predict body fat level from body
measurements.)
Pattern recognition (classification). Classify inputs into a set of target
categories. (e.g., recognize the vineyard from a chemical analysis of
the wine; classify a tumor as benign or malignant, from uniformity of
cell size, clump thickness and mitosis.)
Clustering (segmentation) Group data by similarity. (e.g., group
customers according to buying patterns, group genes with related
expression patterns.)
Prediction (time series analysis, system identification, filtering or
dynamic modeling). Predict the future value of some time series. (e.g.,
predict the future value of some stock; predict the future value of the
concentration of some chemical; predict outages on the electric grid.)
10
22 Choice of Network Architecture

Fitting
Multilayer networks with sigmoid hidden layers and linear output layers.
Radial basis networks
Pattern Recognition
Multilayer networks with sigmoid hidden layers and sigmoid output
layers.
Radial basis networks.
Clustering
Self-organizing feature map
Prediction
Focused time-delay neural network
NARX network

11
22 Prediction Networks
Inputs Layer 1 Layer 2

1
p (t)
T a1(t) a2(t)
Focused D
L
IW1,1
1 1
n1(t)
1
S x1
LW2,1
2 1
2
n (t) S2x1
S x (R d) S xS

Time Delay
2
S x1
1 b
1 1
S x1 1 b2
R1 S1x1 S1 S2
2
S x1

Inputs Layer 1 Layer 2

p1(t) n1(t) a1(t) a2(t)


T
D IW1,1 LW
2,1
2
L 1 S1x1 2 1
n (t) S2x1
S xR S xS
NARX
1
R x1 S2x1
1 b
1
S1x1 1 b
2

1 2
S1
2
R S1x1 S x1 S
T
D LW1,3
L

12
22 Architecture Specifics

Number of layers/neurons
For multilayer network, start with two layers. Increase number of layers if
result is not satisfactory.
Use a reasonably large number of neurons in the hidden layer (20). Use
early stopping or Bayesian regularization to prevent overfitting.
Number of neurons in output layer = number of targets. You can use
multiple networks instead of multiple outputs.
Input selection
Sensitivity analysis (see later slide)
Bayesian regularization with separate for each column of the input
weight matrix.

13
22 Weight Initialization

For Multilayer Networks

Random weights. Uniformly distributed between -0.5 and


0.5, if the inputs are normalized to fall between -1 and 1.
Random direction for weights, with magnitude set to

i w = 0 .7 ( )
S 1 1/ R

and biases randomly distributed between

iw and iw .

14
22 Weight Initialization

For Competitive Networks


Small random numbers
Randomly selected input vectors
Principal components of the input vectors

15
22 Choice of Training Algorithm

For medium sized networks (several hundred weights)


used for fitting or prediction problems, use the Levenberg-
Marquardt algorithm (trainlm).
For large networks (thousands of weights) used for fitting
or prediction problems, or networks used for pattern
recognition problems, conjugate gradient algorithms, such
as the scaled conjugate gradient algorithm (trainscg) are
generally faster.
Of the sequential algorithms, the extended Kalman filter
algorithm are generally fastest.

16
22 Stopping Criteria

Norm of the gradient (of the mean squared error) less than
a pre-specified amount (for example, 10-6).
Early stopping because the validation error increases.
Maximum number of iterations reached.
Mean square error drops below a specified threshold (not
generally a useful method).
Mean square error curve (on a log-log scale) becomes flat
for some time (user stop).

17
22 Typical Training Curve
3
10

2
10
Sum Square Error

1
10

0
10

1
10

2
10

3
10
0 1 2 3
10 10 10 10

Iteration Number
18
22 Competitive Network Stopping Criteria

Stop when a specified number of iterations has been


reached.
Learning rate and neighborhood size (SOM) are decreased
during training, so that they reach their smallest values
when the maximum number of iterations have been
reached.
Post-training analysis is used to determine if retraining is
required.

19
22 Choice of Performance Function
Q
1 T
Mean Square Error F ( x) = -----
-
---
--
(t q a q ) (t q a q )
M
QS
q=1

M
Q S
1 2
-
----
------
F (x ) =
QS
M ( ti, q a i, q )
q = 1i = 1

M
Q S
1 K
Minkowski error F (x ) = ----M
-
---- --
t i , q a i, q
QS
q = 1i = 1

M
Q S
a i, q
Cross-Entropy F ( x) = t i, q --t--i--, --q-
ln
q = 1i = 1

20
22 Committees of Networks

Restart training at 5 to 10 different initial conditions to be


sure to reach a global minimum.
You can also train several different networks with different
initial conditions and different divisions of the data into
training and validation sets. This produces a committee of
networks.
Take the average of the committee outputs to produce a
more accurate fit than any of the individual networks.
For pattern recognition problems, you can take a vote of
the committee of networks to produce a more accurate
classification.

21
22 Post-Training Analysis

Fitting
Pattern Recognition
Clustering
Prediction

22
22 Fitting
Regression Analysis (Outputs vs Targets)
Q Q

( t q t ) (a q a ) t = tq
a q = mtq + c + q q= 1
m = --------------
Q
--------------------------------- q=1

2 Q
c = am t ( tq t ) a = aq
q= 1
q=1

R Value (-1<R<1) Q
Q 1
st = -------------
Q1
( tq t)
( t q t ) (a q a ) q=1
q= 1
R = ------------------------1-----------------------
( Q ) s t sa Q
1
sa = -------------
Q 1
( aq a )
q= 1
23
22 Sample Regression Plot
50

R = 0.965
40
R2 = 0.931

30

a
20

10

0
0 5 10 15 20 25 30 35 40 45 50

t
24
22 Error Histogram

140

120

100

80

60

40

20

0
8 6 4 2 0 2 4 6 8 10 12

e=t-a
25
22 Pattern Recognition

False Positives
Confusion Matrix
(Type I Error)

47 1 97.9%
1
Output Class 22.0% 0.5% 2.1%

4 162 97.6%
2
1.9% 75.7% 2.4%

92.2% 99.4% 97.7%


7.8% 0.6% 2.3%

False Negatives 1 2
(Type II Error) Target Class

26
22 Pattern Recognition
Receiver Operating Characteristic (ROC) Curve

0.9

0.8

0.7
True Positive Rate

0.6

0.5

0.4

0.3

0.2

0.1

0
0 0.2 0.4 0.6 0.8 1
False Positive Rate
27
22 Clustering (SOM)

Quantization Error. The average distance between each


input vector and the closest prototype vector.
Topographic Error. The proportion of all input vectors for
which the closest prototype vector and the next closest
prototype vector are not neighbors in the feature map
topology.
Distortion
Q S
Prototype closest to the input vector.
cq = arg min j { jw p q }
2
Ed = h ic iw p q
q
q = 1i = 1

2
iw jw
hi,j = neighborhood function h ij = exp ------------------
----------
2d 2

28
22 Prediction
Autocorrelation Function of Prediction Errors.
Q
1
--
---
-------
R e ( ) =
Q e (t ) e ( t + )
t=1
Confidence Intervals.
2R ( 0) 2 R e (0 )
-
----
----
e--------
< R e( ) < ----------------
-
Q Q
0.2 0.03

Before After
0.02
0.1

0.01

0.1
40 20 0 20 40 40 20 0 20 40

29
22 Prediction
Cross-correlation Between Prediction Errors and Input.
Q
1
R pe ( ) = ------------ p ( t ) e( t + )
Q
t= 1
Confidence Intervals.
2 R ( 0 ) R (0 ) 2 R ( 0 ) R (0 )
---------------------------------------- < R pe ( ) < ----------------------------------------
e p e p
Q Q
0.2 0.02

Before After
0.01

0.1

0.01

0.1 0.02
40 20 0 20 40 40 20 0 20 40

30
22 Overfitting and Extrapolation

If, after a network has been trained, the test set


performance is not adequate, then there are usually
four possible causes:

the network has reached a local minimum,


the network does not have enough neurons to fit the data,
the network is overfitting, or
the network is extrapolating.

31
22 Diagnosing Problems

The local minimum problem can almost always be


overcome by retraining the network with five to ten
random sets of initial weights.
If the validation error is much larger than the training error,
then overfitting has probably occurred.
If the validation, training and test errors are all similar in
size, but the errors are too large, then the network is not
powerful enough to fit the data. Add neurons.
If the validation and training errors are similar in size, but
the test errors are significantly larger, then the network
may be extrapolating.
If training, validation and test errors are similar, and the
errors are small enough, then we can put the multilayer
network to use.
32
22 Novelty Detection

To detect extrapolation, train a companion competitive


network to cluster the input vectors of the training set.
When an input is applied to the multilayer network, the
same input is applied to the companion competitive
network.
When the distance of the input vector to the nearest
prototype vector of the competitive network is larger than
the distance from the prototype to the most distant member
of its cluster of inputs in the training set, we can suspect
extrapolation.

33
22 Sensitivity Analysis
Check for important inputs.

m F
s i ---------
m
n i
1 1
S S
ni
1
ni
1
----F
--- = -----F---
-------- 1
--------
pj n i
1 pj
= si
pj
i=1 i =1
R
1 1 1
ni = wi, j p j + b i
j=1
1 1
S S
ni
1
--F--
--- F--
------ -------- 1 1
pj
= n i

1 p
j
= s i wi, j
i=1 i= 1


---F
T
--- = ( W1 ) s1
p
34

You might also like