Neural Network Design: 2nd Edition
Neural Network Design: 2nd Edition
Neural Network Design: 2nd Edition
Network
Design
2nd Edition
Hagan
Demuth
Beale
De Jess
Copyright by Martin T. Hagan and Howard B. Demuth. All rights reserved. No part of the book
may be reproduced, stored in a retrieval system, or transcribed in any form or by any means electronic, mechanical, photocopying, recording or otherwise - without the prior permission of
Hagan and Demuth.
MTH
To Janet, Thomas, Daniel, Mom and Dad
HBD
To Hal, Katherine, Kimberly and Mary
MHB
To Leah, Valerie, Asia, Drake, Coral and Morgan
ODJ
To: Marisela, Mara Victoria, Manuel, Mam y Pap.
Contents
Preface
Introduction
Objectives
History
Applications
Biological Inspiration
Further Reading
1-1
1-2
1-5
1-8
1-10
2-1
2-2
2-2
2-2
2-2
2-3
2-7
2-9
2-9
2-10
2-13
2-16
2-20
2-22
2-23
An Illustrative Example
Objectives
Theory and Examples
Problem Statement
Perceptron
Two-Input Case
Pattern Recognition Example
Hamming Network
Feedforward Layer
Recurrent Layer
Hopfield Network
Epilogue
Exercises
3-1
3-2
3-2
3-3
3-4
3-5
3-8
3-8
3-9
3-12
3-15
3-16
ii
4-1
4-2
4-2
4-3
4-5
4-8
4-8
4-9
4-10
4-12
4-13
4-15
4-15
4-16
4-18
4-20
4-21
4-33
4-34
4-36
5-1
5-2
5-2
5-4
5-5
5-6
5-7
5-7
5-8
5-9
5-10
5-14
5-17
5-26
5-27
5-28
iii
6-1
6-2
6-2
6-3
6-6
6-10
6-13
6-15
6-17
6-28
6-29
6-30
7-1
7-2
7-3
7-4
7-5
7-7
7-10
7-12
17-4
7-16
7-29
7-30
7-31
iv
8-1
8-2
8-2
8-4
8-5
8-7
8-9
8-10
8-11
8-12
8-13
8-20
8-22
8-34
8-35
8-36
10
Performance Optimization
Objectives
Theory and Examples
Steepest Descent
Stable Learning Rates
Minimizing Along a Line
Newtons Method
Conjugate Gradient
Summary of Results
Solved Problems
Epilogue
Further Reading
Exercises
9-1
9-2
9-2
9-6
9-8
9-10
9-15
9-21
9-23
9-37
9-38
9-39
Widrow-Hoff Learning
Objectives
Theory and Examples
ADALINE Network
Single ADALINE
Mean Square Error
LMS Algorithm
Analysis of Convergence
Adaptive Filtering
Adaptive Noise Cancellation
Echo Cancellation
Summary of Results
Solved Problems
Epilogue
Further Reading
Exercises
10-1
10-2
10-2
10-3
10-4
10-7
10-9
10-13
10-15
10-21
10-22
10-24
10-40
10-41
10-42
11
12
Backpropagation
Objectives
Theory and Examples
Multilayer Perceptrons
Pattern Classification
Function Approximation
The Backpropagation Algorithm
Performance Index
Chain Rule
Backpropagating the Sensitivities
Summary
Example
Batch vs. Incremental Training
Using Backpropagation
Choice of Network Architecture
Convergence
Generalization
Summary of Results
Solved Problems
Epilogue
Further Reading
Exercises
11-1
11-2
11-2
11-3
11-4
11-7
11-8
11-9
11-11
11-13
11-14
11-17
11-18
11-18
11-20
11-22
11-25
11-27
11-41
11-42
11-44
Variations on Backpropagation
Objectives
Theory and Examples
Drawbacks of Backpropagation
Performance Surface Example
Convergence Example
Heuristic Modifications of Backpropagation
Momentum
Variable Learning Rate
Numerical Optimization Techniques
Conjugate Gradient
Levenberg-Marquardt Algorithm
Summary of Results
Solved Problems
Epilogue
Further Reading
Exercises
vi
12-1
12-2
12-3
12-3
12-7
12-9
12-9
12-12
12-14
12-14
12-19
12-28
12-32
12-46
12-47
12-50
13
14
Generalization
Objectives
Theory and Examples
Problem Statement
Methods for Improving Generalization
Estimating Generalization Error
Early Stopping
Regularization
Bayesian Analysis
Bayesian Regularization
Relationship Between Early Stopping
and Regularization
Summary of Results
Solved Problems
Epilogue
Further Reading
Exercises
13-1
13-2
13-2
13-5
13-6
13-6
13-8
13-10
13-12
13-19
13-29
13-32
13-44
13-45
13-47
Dynamic Networks
Objectives
Theory and Examples
Layered Digital Dynamic Networks
Example Dynamic Networks
Principles of Dynamic Learning
Dynamic Backpropagation
Preliminary Definitions
Real Time Recurrent Learning
Backpropagation-Through-Time
Summary and Comments on
Dynamic Training
Summary of Results
Solved Problems
Epilogue
Further Reading
Exercises
vii
D
14-1
14-2
14-3
14-5
14-8
14-12
14-12
14-12
14-22
14-30
14-34
14-37
14-46
14-47
14-48
15
16
Associative Learning
Objectives
Theory and Examples
Simple Associative Network
Unsupervised Hebb Rule
Hebb Rule with Decay
Simple Recognition Network
Instar Rule
Kohonen Rule
Simple Recall Network
Outstar Rule
Summary of Results
Solved Problems
Epilogue
Further Reading
Exercises
15-1
15-2
15-3
15-5
15-7
15-9
15-11
15-15
15-16
15-17
15-21
15-23
15-34
15-35
15-37
Competitive Networks
Objectives
Theory and Examples
Hamming Network
Layer 1
Layer 2
Competitive Layer
Competitive Learning
Problems with Competitive Layers
Competitive Layers in Biology
Self-Organizing Feature Maps
Improving Feature Maps
Learning Vector Quantization
LVQ Learning
Improving LVQ Networks (LVQ2)
Summary of Results
Solved Problems
Epilogue
Further Reading
Exercises
viii
16-1
16-2
16-3
16-3
16-4
16-5
16-7
16-9
16-10
16-12
16-15
16-16
16-18
16-21
16-22
16-24
16-37
16-38
16-39
17
18
17-1
17-2
17-2
17-4
17-6
17-9
17-10
17-11
17-18
17-23
17-25
17-26
17-27
17-30
17-35
17-36
17-38
Grossberg Network
Objectives
Theory and Examples
Biological Motivation: Vision
Illusions
Vision Normalization
Basic Nonlinear Model
Two-Layer Competitive Network
Layer 1
Layer 2
Choice of Transfer Function
Learning Law
Relation to Kohonen Law
Summary of Results
Solved Problems
Epilogue
Further Reading
Exercises
ix
18-1
18-2
18-3
18-4
18-8
18-9
18-12
18-13
18-17
18-20
18-22
18-24
18-26
18-30
18-42
18-43
18-45
19
20
19-1
19-2
19-2
19-4
19-6
19-10
19-13
19-17
19-17
19-18
19-20
19-21
19-21
19-21
19-23
19-25
19-30
19-45
19-46
19-48
Stability
Objectives
Theory and Examples
Recurrent Networks
Stability Concepts
Definitions
Lyapunov Stability Theorem
Pendulum Example
LaSalles Invariance Theorem
Definitions
Theorem
Example
Comments
Summary of Results
Solved Problems
Epilogue
Further Reading
Exercises 30
x
20-1
20-2
20-2
20-3
20-4
20-5
20-6
20-12
20-12
20-13
20-14
20-18
20-19
20-21
20-28
20-29
21
22
Hopfield Network
Objectives
Theory and Examples
Hopfield Model
Lyapunov Function
Invariant Sets
Example
Hopfield Attractors
Effect of Gain
Hopfield Design
Content-Addressable Memory
Hebb Rule
Lyapunov Surface
Summary of Results
Solved Problems
Epilogue
Further Reading
Exercises
21-1
21-2
21-3
21-5
21-7
21-7
21-11
21-12
21-16
21-16
21-18
21-22
21-24
21-26
21-36
21-37
21-40
22-1
22-2
22-3
22-3
22-5
22-8
22-13
22-13
22-14
22-14
22-16
22-18
22-18
22-18
22-21
22-23
22-24
22-27
22-28
22-30
22-31
23
24
25
23-1
23-2
23-2
23-3
23-4
23-5
23-7
23-10
23-11
23-12
24-1
24-2
24-2
24-3
24-5
24-7
24-9
24-12
24-13
24-14
xii
25-1
25-2
25-2
25-3
25-6
25-7
25-7
25-10
25-11
25-12
26
27
26-1
26-2
26-2
26-4
26-5
26-6
26-7
26-11
26-12
26-13
xiii
27-1
27-2
27-2
27-3
27-4
27-6
27-8
27-13
27-14
27-15
Appendices
A
Bibliography
Notation
Software
Index
xiv
Preface
This book gives an introduction to basic neural network architectures and
learning rules. Emphasis is placed on the mathematical analysis of these
networks, on methods of training them and on their application to practical
engineering problems in such areas as nonlinear regression, pattern recognition, signal processing, data mining and control systems.
Every effort has been made to present material in a clear and consistent
manner so that it can be read and applied with ease. We have included
many solved problems to illustrate each topic of discussion. We have also
included a number of case studies in the final chapters to demonstrate
practical issues that arise when using neural networks on real world problems.
Since this is a book on the design of neural networks, our choice of topics
was guided by two principles. First, we wanted to present the most useful
and practical neural network architectures, learning rules and training
techniques. Second, we wanted the book to be complete in itself and to flow
easily from one chapter to the next. For this reason, various introductory
materials and chapters on applied mathematics are included just before
they are needed for a particular subject. In summary, we have chosen some
topics because of their practical importance in the application of neural
networks, and other topics because of their importance in explaining how
neural networks operate.
We have omitted many topics that might have been included. We have not,
for instance, made this book a catalog or compendium of all known neural
network architectures and learning rules, but have instead concentrated
on the fundamental concepts. Second, we have not discussed neural network implementation technologies, such as VLSI, optical devices and parallel computers. Finally, we do not present the biological and psychological
foundations of neural networks in any depth. These are all important topics, but we hope that we have done the reader a service by focusing on those
topics that we consider to be most useful in the design of neural networks
and by treating those topics in some depth.
This book has been organized for a one-semester introductory course in
neural networks at the senior or first-year graduate level. (It is also suitable for short courses, self-study and reference.) The reader is expected to
have some background in linear algebra, probability and differential equations.
P-1
Preface
2
+2
Each chapter of the book is divided into the following sections: Objectives,
Theory and Examples, Summary of Results, Solved Problems, Epilogue,
Further Reading and Exercises. The Theory and Examples section comprises the main body of each chapter. It includes the development of fundamental ideas as well as worked examples (indicated by the icon shown here in
the left margin). The Summary of Results section provides a convenient
listing of important equations and concepts and facilitates the use of the
book as an industrial reference. About a third of each chapter is devoted to
the Solved Problems section, which provides detailed examples for all key
concepts.
The following figure illustrates the dependencies among the chapters.
Introduction
Architectures
Illustrative
Example
Supervised
Hebb
Peformance 9
Optimization
Associative 15
Learning
Widrow-Hoff
Perceptron 4
Learning Rule
10
Variations on 12
Backpropagation
Generalization
Linear
Transformations
for Neural
Networks
Dynamic
Networks
13
14
Radial Basis 17
Networks
Case Study 23
Function
Approximation
Competitive 16
Learning
11
Backpropagation
Signal and 5
Weight Vector
Spaces
Case Study 24
Probability
Estimation
Performance 8
Surfaces
Case Study 25
Pattern
Recognition
Grossberg
18
19
ART
Stability
Hopfield
20
21
22
Practical Training
Case Study 27
Prediction
Case Study 26
Clustering
Chapters 1 through 6 cover basic concepts that are required for all of the
remaining chapters. Chapter 1 is an introduction to the text, with a brief
historical background and some basic biology. Chapter 2 describes the baP-2
Preface
Software
MATLAB is not essential for using this book. The computer exercises can
be performed with any available programming language, and the Neural
Network Design Demonstrations, while helpful, are not critical to understanding the material covered in this book.
2+2
ans =
4
However, we have made use of the MATLAB software package to supplement the textbook. This software is widely available and, because of its matrix/vector notation and graphics, is a convenient environment in which to
experiment with neural networks. We use MATLAB in two different ways.
First, we have included a number of exercises for the reader to perform in
MATLAB. Many of the important features of neural networks become apparent only for large-scale problems, which are computationally intensive
and not feasible for hand calculations. With MATLAB, neural network algorithms can be quickly implemented, and large-scale problems can be
tested conveniently. These MATLAB exercises are identified by the icon
shown here to the left. (If MATLAB is not available, any other programming language can be used to perform the exercises.)
The second way in which we use MATLAB is through the Neural Network
Design Demonstrations, which can be downloaded from the website
hagan.okstate.edu/nnd.html. These interactive demonstrations illustrate
important concepts in each chapter. After the software has been loaded into
the MATLAB directory on your computer (or placed on the MATLAB path),
it can be invoked by typing nnd at the MATLAB prompt. All
demonstrations are easily accessible from a master menu. The icon shown
here to the left identifies references to these demonstrations in the text.
The demonstrations require MATLAB or the student edition of MATLAB,
version 2010a or later. See Appendix C for specific information on using the
demonstration software.
Overheads
As an aid to instructors who are using this text, we have prepared a
companion set of overheads. Transparency masters (in Microsoft
Powerpoint format or PDF) for each chapter are available on the web at
hagan.okstate.edu/nnd.html.
P-4
Acknowledgments
Acknowledgments
We are deeply indebted to the reviewers who have given freely of their time
to read all or parts of the drafts of this book and to test various versions of
the software. In particular we are most grateful to Professor John Andreae,
University of Canterbury; Dan Foresee, AT&T; Dr. Carl Latino, Oklahoma
State University; Jack Hagan, MCI; Dr. Gerry Andeen, SRI; and Joan Miller and Margie Jenks, University of Idaho. We also had constructive inputs
from our graduate students in ECEN 5733 at Oklahoma State University,
ENEL 621 at the University of Canterbury, INSA 0506 at the Institut National des Sciences Appliques and ECE 5120 at the University of Colorado, who read many drafts, tested the software and provided helpful
suggestions for improving the book over the years. We are also grateful to
the anonymous reviewers who provided several useful recommendations.
We wish to thank Dr. Peter Gough for inviting us to join the staff in the
Electrical and Electronic Engineering Department at the University of
Canterbury, Christchurch, New Zealand, and Dr. Andre Titli for inviting
us to join the staff at the Laboratoire d'Analyse et d'Architecture des
Systms, Centre National de la Recherche Scientifique, Toulouse, France.
Sabbaticals from Oklahoma State University and a years leave from the
University of Idaho gave us the time to write this book. Thanks to Texas
Instruments, Halliburton, Cummins, Amgen and NSF, for their support of
our neural network research. Thanks to The Mathworks for permission to
use material from the Neural Network Toolbox.
P-5
Objectives
Introduction
Objectives
1-1
History
1-2
Applications
1-5
Biological Inspiration
1-8
Further Reading
1-10
Objectives
As you read these words you are using a complex biological neural network.
You have a highly interconnected set of some 1011 neurons to facilitate your
reading, breathing, motion and thinking. Each of your biological neurons,
a rich assembly of tissue and chemistry, has the complexity, if not the
speed, of a microprocessor. Some of your neural structure was with you at
birth. Other parts have been established by experience.
Scientists have only just begun to understand how biological neural networks operate. It is generally understood that all biological neural functions, including memory, are stored in the neurons and in the connections
between them. Learning is viewed as the establishment of new connections
between neurons or the modification of existing connections. This leads to
the following question: Although we have only a rudimentary understanding of biological neural networks, is it possible to construct a small set of
simple artificial neurons and perhaps train them to serve a useful function? The answer is yes. This book, then, is about artificial neural networks.
The neurons that we consider here are not biological. They are extremely
simple abstractions of biological neurons, realized as elements in a program or perhaps as circuits made of silicon. Networks of these artificial
neurons do not have a fraction of the power of the human brain, but they
can be trained to perform useful functions. This book is about such neurons, the networks that contain them and their training.
1-1
1 Introduction
History
The history of artificial neural networks is filled with colorful, creative individuals from a variety of fields, many of whom struggled for decades to
develop concepts that we now take for granted. This history has been documented by various authors. One particularly interesting book is Neurocomputing: Foundations of Research by John Anderson and Edward
Rosenfeld. They have collected and edited a set of some 43 papers of special
historical interest. Each paper is preceded by an introduction that puts the
paper in historical perspective.
Histories of some of the main neural network contributors are included at
the beginning of various chapters throughout this text and will not be repeated here. However, it seems appropriate to give a brief overview, a sample of the major developments.
At least two ingredients are necessary for the advancement of a technology:
concept and implementation. First, one must have a concept, a way of
thinking about a topic, some view of it that gives a clarity not there before.
This may involve a simple idea, or it may be more specific and include a
mathematical description. To illustrate this point, consider the history of
the heart. It was thought to be, at various times, the center of the soul or a
source of heat. In the 17th century medical practitioners finally began to
view the heart as a pump, and they designed experiments to study its
pumping action. These experiments revolutionized our view of the circulatory system. Without the pump concept, an understanding of the heart was
out of grasp.
Concepts and their accompanying mathematics are not sufficient for a
technology to mature unless there is some way to implement the system.
For instance, the mathematics necessary for the reconstruction of images
from computer-aided tomography (CAT) scans was known many years before the availability of high-speed computers and efficient algorithms finally made it practical to implement a useful CAT system.
The history of neural networks has progressed through both conceptual innovations and implementation developments. These advancements, however, seem to have occurred in fits and starts rather than by steady
evolution.
Some of the background work for the field of neural networks occurred in
the late 19th and early 20th centuries. This consisted primarily of interdisciplinary work in physics, psychology and neurophysiology by such scientists as Hermann von Helmholtz, Ernst Mach and Ivan Pavlov. This early
work emphasized general theories of learning, vision, conditioning, etc.,
and did not include specific mathematical models of neuron operation.
1-2
History
The modern view of neural networks began in the 1940s with the work of
Warren McCulloch and Walter Pitts [McPi43], who showed that networks
of artificial neurons could, in principle, compute any arithmetic or logical
function. Their work is often acknowledged as the origin of the neural network field.
McCulloch and Pitts were followed by Donald Hebb [Hebb49], who proposed that classical conditioning (as discovered by Pavlov) is present because of the properties of individual neurons. He proposed a mechanism for
learning in biological neurons (see Chapter 7).
The first practical application of artificial neural networks came in the late
1950s, with the invention of the perceptron network and associated learning rule by Frank Rosenblatt [Rose58]. Rosenblatt and his colleagues built
a perceptron network and demonstrated its ability to perform pattern recognition. This early success generated a great deal of interest in neural network research. Unfortunately, it was later shown that the basic perceptron
network could solve only a limited class of problems. (See Chapter 4 for
more on Rosenblatt and the perceptron learning rule.)
At about the same time, Bernard Widrow and Ted Hoff [WiHo60] introduced a new learning algorithm and used it to train adaptive linear neural
networks, which were similar in structure and capability to Rosenblatts
perceptron. The Widrow-Hoff learning rule is still in use today. (See Chapter 10 for more on Widrow-Hoff learning.)
Unfortunately, both Rosenblatts and Widrows networks suffered from the
same inherent limitations, which were widely publicized in a book by Marvin Minsky and Seymour Papert [MiPa69]. Rosenblatt and Widrow were
aware of these limitations and proposed new networks that would overcome them. However, they were not able to successfully modify their learning algorithms to train the more complex networks.
Many people, influenced by Minsky and Papert, believed that further research on neural networks was a dead end. This, combined with the fact
that there were no powerful digital computers on which to experiment,
caused many researchers to leave the field. For a decade neural network research was largely suspended.
Some important work, however, did continue during the 1970s. In 1972
Teuvo Kohonen [Koho72] and James Anderson [Ande72] independently
and separately developed new neural networks that could act as memories.
(See Chapter 15 and Chapter 16 for more on Kohonen networks.) Stephen
Grossberg [Gros76] was also very active during this period in the investigation of self-organizing networks. (See Chapter 18 and Chapter 19.)
Interest in neural networks had faltered during the late 1960s because of
the lack of new ideas and powerful computers with which to experiment.
During the 1980s both of these impediments were overcome, and research
in neural networks increased dramatically. New personal computers and
1-3
1 Introduction
1-4
Applications
Applications
A newspaper article described the use of neural networks in literature research by Aston University. It stated that the network can be taught to
recognize individual writing styles, and the researchers used it to compare
works attributed to Shakespeare and his contemporaries. A popular science television program documented the use of neural networks by an Italian research institute to test the purity of olive oil. Google uses neural
networks for image tagging (automatically identifying an image and assigning keywords), and Microsoft has developed neural networks that can
help convert spoken English speech into spoken Chinese speech. Researchers at Lund University and Skne University Hospital in Sweden have
used neural networks to improve long-term survival rates for heart transplant recipients by identifying optimal recipient and donor matches. These
examples are indicative of the broad range of applications that can be found
for neural networks. The applications are expanding because neural networks are good at solving problems, not just in engineering, science and
mathematics, but in medicine, business, finance and literature as well.
Their application to a wide variety of problems in many fields makes them
very attractive. Also, faster computers and faster algorithms have made it
possible to use neural networks to solve complex industrial problems that
formerly required too much computation.
The following note and Table of Neural Network Applications are reproduced here from the Neural Network Toolbox for MATLAB with the permission of the MathWorks, Inc.
A 1988 DARPA Neural Network Study [DARP88] lists various neural network applications, beginning with the adaptive channel equalizer in about
1984. This device, which is an outstanding commercial success, is a singleneuron network used in long distance telephone systems to stabilize voice
signals. The DARPA report goes on to list other commercial applications,
including a small word recognizer, a process monitor, a sonar classifier and
a risk analysis system.
Thousands of neural networks have been applied in hundreds of fields in
the many years since the DARPA report was written. A list of some of those
applications follows.
Aerospace
High performance aircraft autopilots, flight path simulations,
aircraft control systems, autopilot enhancements, aircraft component simulations, aircraft component fault detectors
1-5
1 Introduction
Automotive
Automobile automatic guidance systems, fuel injector control,
automatic braking systems, misfire detection, virtual emission
sensors, warranty activity analyzers
Banking
Check and other document readers, credit application evaluators, cash forecasting, firm classification, exchange rate forecasting, predicting loan recovery rates, measuring credit risk
Defense
Weapon steering, target tracking, object discrimination, facial
recognition, new kinds of sensors, sonar, radar and image signal processing including data compression, feature extraction
and noise suppression, signal/image identification
Electronics
Code sequence prediction, integrated circuit chip layout, process control, chip failure analysis, machine vision, voice synthesis, nonlinear modeling
Entertainment
Animation, special effects, market forecasting
Financial
Real estate appraisal, loan advisor, mortgage screening, corporate bond rating, credit line use analysis, portfolio trading program, corporate financial analysis, currency price prediction
Insurance
Policy application evaluation, product optimization
Manufacturing
Manufacturing process control, product design and analysis,
process and machine diagnosis, real-time particle identification, visual quality inspection systems, beer testing, welding
quality analysis, paper quality prediction, computer chip quality analysis, analysis of grinding operations, chemical product
design analysis, machine maintenance analysis, project bidding, planning and management, dynamic modeling of chemical process systems
1-6
Applications
Medical
Breast cancer cell analysis, EEG and ECG analysis, prosthesis
design, optimization of transplant times, hospital expense reduction, hospital quality improvement, emergency room test
advisement
Oil and Gas
Exploration, smart sensors, reservoir modeling, well treatment
decisions, seismic interpretation
Robotics
Trajectory control, forklift robot, manipulator controllers, vision systems, autonomous vehicles
Speech
Speech recognition, speech compression, vowel classification,
text to speech synthesis
Securities
Market analysis, automatic bond rating, stock trading advisory
systems
Telecommunications
Image and data compression, automated information services,
real-time translation of spoken language, customer payment
processing systems
Transportation
Truck brake diagnosis systems, vehicle scheduling, routing
systems
Conclusion
The number of neural network applications, the money that has been invested in neural network software and hardware, and the depth and
breadth of interest in these devices is enormous.
1-7
1 Introduction
Biological Inspiration
The artificial neural networks discussed in this text are only remotely related to their biological counterparts. In this section we will briefly describe
those characteristics of brain function that have inspired the development
of artificial neural networks.
The brain consists of a large number (approximately 1011) of highly connected elements (approximately 104 connections per element) called neurons. For our purposes these neurons have three principal components: the
dendrites, the cell body and the axon. The dendrites are tree-like receptive
networks of nerve fibers that carry electrical signals into the cell body. The
cell body effectively sums and thresholds these incoming signals. The axon
is a single long fiber that carries the signal from the cell body out to other
neurons. The point of contact between an axon of one cell and a dendrite of
another cell is called a synapse. It is the arrangement of neurons and the
strengths of the individual synapses, determined by a complex chemical
process, that establishes the function of the neural network. Figure 1.1 is
a simplified schematic diagram of two biological neurons.
Dendrites
Axon
Cell Body
Synapse
Biological Inspiration
it has been shown that if a young cat is denied use of one eye during a critical window of time, it will never develop normal vision in that eye. Linguists have discovered that infants over six months of age can no longer
discriminate certain speech sounds, unless they were exposed to them earlier in life [WeTe84].
Neural structures continue to change throughout life. These later changes
tend to consist mainly of strengthening or weakening of synaptic junctions.
For instance, it is believed that new memories are formed by modification
of these synaptic strengths. Thus, the process of learning a new friends
face consists of altering various synapses. Neuroscientists have discovered
[MaGa2000], for example, that the hippocampi of London taxi drivers are
significantly larger than average. This is because they must memorize a
large amount of navigational informationa process that takes more than
two years.
Artificial neural networks do not approach the complexity of the brain.
There are, however, two key similarities between biological and artificial
neural networks. First, the building blocks of both networks are simple
computational devices (although artificial neurons are much simpler than
biological neurons) that are highly interconnected. Second, the connections
between neurons determine the function of the network. The primary objective of this book will be to determine the appropriate connections to solve
particular problems.
It is worth noting that even though biological neurons are very slow when
compared to electrical circuits (10-3 s compared to 10-10 s), the brain is
able to perform many tasks much faster than any conventional computer.
This is in part because of the massively parallel structure of biological neural networks; all of the neurons are operating at the same time. Artificial
neural networks share this parallel structure. Even though most artificial
neural networks are currently implemented on conventional digital computers, their parallel structure makes them ideally suited to implementation using VLSI, optical devices and parallel processors.
In the following chapter we will introduce our basic artificial neuron and
will explain how we can combine such neurons to form networks. This will
provide a background for Chapter 3, where we take our first look at neural
networks in action.
1-9
1 Introduction
Further Reading
[Ande72]
J. A. Anderson, A simple neural network generating an interactive memory, Mathematical Biosciences, Vol. 14, pp.
197220, 1972.
Anderson proposed a linear associator model for associative memory. The model was trained, using a generalization of the Hebb postulate, to learn an association between
input and output vectors. The physiological plausibility of
the network was emphasized. Kohonen published a closely
related paper at the same time [Koho72], although the two
researchers were working independently.
[AnRo88]
J. A. Anderson and E. Rosenfeld, Neurocomputing: Foundations of Research, Cambridge, MA: MIT Press, 1989.
Neurocomputing is a fundamental reference book. It contains over forty of the most important neurocomputing
writings. Each paper is accompanied by an introduction
that summarizes its results and gives a perspective on the
position of the paper in the history of the field.
[DARP88]
DARPA Neural Network Study, Lexington, MA: MIT Lincoln Laboratory, 1988.
This study is a compendium of knowledge of neural networks as they were known to 1988. It presents the theoretical foundations of neural networks and discusses their
current applications. It contains sections on associative
memories, recurrent networks, vision, speech recognition,
and robotics. Finally, it discusses simulation tools and implementation technology.
[Gros76]
S. Grossberg, Adaptive pattern classification and universal recoding: I. Parallel development and coding of neural
feature detectors, Biological Cybernetics, Vol. 23, pp. 121
134, 1976.
Grossberg describes a self-organizing neural network
based on the visual system. The network, which consists of
short-term and long-term memory mechanisms, is a continuous-time competitive network. It forms a basis for the
adaptive resonance theory (ART) networks.
1-10
Further Reading
[Gros80]
[Hebb 49]
[Hopf82]
[Koho72]
T. Kohonen, Correlation matrix memories, IEEE Transactions on Computers, vol. 21, pp. 353359, 1972.
Kohonen proposed a correlation matrix model for associative memory. The model was trained, using the outer product rule (also known as the Hebb rule), to learn an
association between input and output vectors. The mathematical structure of the network was emphasized. Anderson published a closely related paper at the same time
[Ande72], although the two researchers were working independently.
[MaGa00]
1 Introduction
erage. This study demonstrated that the posterior hippocampi of London taxi drivers were significantly larger
relative to those of control subjects.
[McPi43]
[MiPa69]
[Rose58]
[RuMc86]
D. E. Rumelhart and J. L. McClelland, eds., Parallel Distributed Processing: Explorations in the Microstructure of
Cognition, Vol. 1, Cambridge, MA: MIT Press, 1986.
One of the two key influences in the resurgence of interest
in the neural network field during the 1980s. Among other
topics, it presents the backpropagation algorithm for training multilayer networks.
[WeTe84]
J. F. Werker and R. C. Tees, Cross-language speech perception: Evidence for perceptual reorganization during the
first year of life, Infant Behavior and Development, Vol. 7,
pp. 49-63, 1984.
1-12
Further Reading
B. Widrow and M. E. Hoff, Adaptive switching circuits,1960 IRE WESCON Convention Record, New York:
IRE Part 4, pp. 96104, 1960.
This seminal paper describes an adaptive perceptron-like
network that can learn quickly and accurately. The authors
assume that the system has inputs and a desired output
classification for each input, and that the system can calculate the error between the actual and desired output. The
weights are adjusted, using a gradient descent method, so
as to minimize the mean square error. (Least Mean Square
error or LMS algorithm.)
This paper is reprinted in [AnRo88].
1-13
Objectives
2-1
2-2
Notation
2-2
Neuron Model
2-2
Single-Input Neuron
2-2
Transfer Functions
2-3
Multiple-Input Neuron
2-7
Network Architectures
2-9
A Layer of Neurons
2-9
2-10
Recurrent Networks
2-13
Summary of Results
2-16
Solved Problems
2-20
Epilogue
2-22
Exercises
2-23
Objectives
In Chapter 1 we presented a simplified description of biological neurons
and neural networks. Now we will introduce our simplified mathematical
model of the neuron and will explain how these artificial neurons can be interconnected to form a variety of network architectures. We will also illustrate the basic operation of these networks through some simple examples.
The concepts and notation introduced in this chapter will be used throughout this book.
This chapter does not cover all of the architectures that will be used in this
book, but it does present the basic building blocks. More complex architectures will be introduced and discussed as they are needed in later chapters.
Even so, a lot of detail is presented here. Please note that it is not necessary
for the reader to memorize all of the material in this chapter on a first reading. Instead, treat it as a sample to get you started and a resource to which
you can return.
2-1
Neuron Model
Single-Input Neuron
Weight
Bias
Net Input
Transfer Function
A single-input neuron is shown in Figure 2.1. The scalar input p is multiplied by the scalar weight w to form wp , one of the terms that is sent to the
summer. The other input, 1 , is multiplied by a bias b and then passed to
the summer. The summer output n , often referred to as the net input, goes
into a transfer function f , which produces the scalar neuron output a .
(Some authors use the term activation function rather than transfer function and offset rather than bias.)
If we relate this simple model back to the biological neuron that we discussed in Chapter 1, the weight w corresponds to the strength of a synapse,
the cell body is represented by the summation and the transfer function,
and the neuron output a represents the signal on the axon.
2-2
Neuron Model
General Neuron
Inputs
1
a = f (wp + b)
Figure 2.1 Single-Input Neuron
The neuron output is calculated as
a = f wp + b .
If, for instance, w = 3 , p = 2 and b = 1.5 , then
a = f 3 2 1.5 = f 4.5
The actual output depends on the particular transfer function that is chosen. We will discuss transfer functions in the next section.
The bias is much like a weight, except that it has a constant input of 1.
However, if you do not want to have a bias in a particular neuron, it can be
omitted. We will see examples of this in Chapters 3, 7 and 16.
Note that w and b are both adjustable scalar parameters of the neuron.
Typically the transfer function is chosen by the designer and then the parameters w and b will be adjusted by some learning rule so that the neuron input/output relationship meets some specific goal (see Chapter 4 for
an introduction to learning rules). As described in the following section, we
have different transfer functions for different purposes.
Transfer Functions
The transfer function in Figure 2.1 may be a linear or a nonlinear function
of n . A particular transfer function is chosen to satisfy some specification
of the problem that the neuron is attempting to solve.
A variety of transfer functions have been included in this book. Three of the
most commonly used functions are discussed below.
Hard Limit
Transfer Function
The hard limit transfer function, shown on the left side of Figure 2.2, sets
the output of the neuron to 0 if the function argument is less than 0, or 1 if
its argument is greater than or equal to 0. We will use this function to create neurons that classify inputs into two distinct categories. It will be used
extensively in Chapter 4.
2-3
+1
+1
n
-b/w
-1
-1
a = hardlim (n)
a = hardlim (wp + b)
Single-Input hardlim Neuron
(2.1)
a
+b
+1
n
-b/w
0
-1
a = purelin (n)
Linear Transfer Function
a = purelin (wp + b)
Single-Input purelin Neuron
2-4
Neuron Model
a
+1
+1
n
-b/w
-1
-1
a = logsig (n)
a = logsig (wp + b)
(2.2)
2-5
Name
Input/Output Relation
Hard Limit
a = 0
n0
a = 1
n0
a = 1
n0
a = +1
n0
Linear
Symmetric Saturating
Linear
hardlims
purelin
a = 0
n0
a = n
0n1
a = 1
n1
a = 1
n 1
a = n
1 n 1
a = 1
n1
Log-Sigmoid
1
a = --------------n
1+e
Hyperbolic Tangent
Sigmoid
e e
a = ----------------n
n
e +e
a = 0
Positive Linear
a = n
satlin
satlins
logsig
tansig
n0
poslin
0n
a = 1
a = 0
2-6
MATLAB
Function
hardlim
a = n
Saturating Linear
Competitive
Icon
compet
Neuron Model
Multiple-Input Neuron
Weight Matrix
Typically, a neuron has more than one input. A neuron with R inputs is
shown in Figure 2.5. The individual inputs p 1 ,p 2 ,... ,p R are each weighted by
corresponding elements w 1 1 ,w 1 2 ,... ,w 1 R of the weight matrix W .
w1, 1
w1, R
1
a = f (Wp + b)
Figure 2.5 Multiple-Input Neuron
The neuron has a bias b , which is summed with the weighted inputs to
form the net input n :
n = w 1 1 p 1 + w 1 2 p 2 + ... + w 1 R p R + b .
(2.3)
(2.4)
where the matrix W for the single neuron case has only one row.
Now the neuron output can be written as
a = f Wp + b .
(2.5)
Weight Indices
We have adopted a particular convention in assigning the indices of the elements of the weight matrix. The first index indicates the particular neuron destination for that weight. The second index indicates the source of
the signal fed to the neuron. Thus, the indices in w 1 2 say that this weight
represents the connection to the first (and only) neuron from the second
source. Of course, this convention is more useful if there is more than one
neuron, as will be the case later in this chapter.
2-7
Abbreviated Notation
We would like to draw networks with several neurons, each having several
inputs. Further, we would like to have more than one layer of neurons. You
can imagine how complex such a network might appear if all the lines were
drawn. It would take a lot of ink, could hardly be read, and the mass of detail might obscure the main features. Thus, we will use an abbreviated notation. A multiple-input neuron using this notation is shown in Figure 2.6.
Input
Multiple-Input Neuron
p
Rx1
1
R
W
1xR
a
n
1x1
b
1x1
1x1
1
a = f (Wp + b)
2-8
Network Architectures
Network Architectures
Commonly one neuron, even with many inputs, may not be sufficient. We
might need five or ten, operating in parallel, in what we will call a layer.
This concept of a layer is discussed below.
A Layer of Neurons
Layer
Inputs
p1
w1,1
Layer of S Neurons
n1
p3
pR
wS, R
a1
b1
p2
n2
a2
b2
nS
aS
bS
1
a = f(Wp + b)
Figure 2.7 Layer of S Neurons
The layer includes the weight matrix, the summers, the bias vector b , the
transfer function boxes and the output vector a . Some authors refer to the
inputs as another layer, but we will not do that here.
Each element of the input vector p is connected to each neuron through the
weight matrix W . Each neuron has a bias b i , a summer, a transfer function f and an output a i . Taken together, the outputs form the output vector
a.
It is common for the number of inputs to a layer to be different from the
number of neurons (i.e., R S ).
You might ask if all the neurons in a layer must have the same transfer
function. The answer is no; you can define a single (composite) layer of neurons having different transfer functions by combining two of the networks
2-9
shown above in parallel. Both networks would have the same inputs, and
each network would create some of the outputs.
The input vector elements enter the network through the weight matrix
W:
w 1 1 w 1 2 w 1 R
w 2 1 w 2 2 w 2 R
W =
w S 1 w S 2 w S R
(2.6)
Input
p
Rx1
1
R
Layer of S Neurons
W
SxR
a
n
Sx1
b
Sx1
Sx1
S
a = f(Wp + b)
2-10
Network Architectures
Layer Superscript
Inputs
First Layer
w 11,1
p1
p2
f1
a11
w 21,1
b11
n12
p3
pR
n11
Second Layer
f1
a12
1 1
S ,R
n1S 1
f1
bS
1 1
n22
b22
a1S 1
w 2S 2, S 1
n2S 2
w 31,1
f2
a31
f3
b31
n31
a22
n32
a32
f3
b32
a2S 2
bS
2 2
a1 = f 1 (W1p + b1)
a21
f2
b21
b12
n21
Third Layer
w 3S 3, S 2
a2 = f 2 (W2a1 + b2)
n3S 3
f3
a3S 3
b3S 3
a3 = f 3 (W3a2 + b3)
A layer whose output is the network output is called an output layer. The
other layers are called hidden layers. The network shown above has an output layer (layer 3) and two hidden layers (layers 1 and 2).
The same three-layer network discussed previously also can be drawn using our abbreviated notation, as shown in Figure 2.10.
2-11
Input
First Layer
p
Rx1
1
R
W1
S1 x R
Second Layer
a1
n1
f1
S1 x 1
S1 x 1
b1
S1 x 1
S1
a1 = f 1 (W1p + b1)
W2
S2 x S1
a2
n2
S2 x 1
f2
S2 x 1
b2
S2 x 1
Third Layer
S2
a2 = f 2 (W2a1 + b2)
W3
S3 x S2
a3
n3
S3 x 1
f3
S3 x 1
b3
S3 x 1
S3
a3 = f 3 (W3a2 + b3)
Network Architectures
than those without, and that is true. Note, for instance, that a neuron without a bias will always have a net input n of zero when the network inputs
p are zero. This may not be desirable and can be avoided by the use of a
bias. The effect of the bias is discussed more fully in Chapters 3, 4 and 5.
In later chapters we will omit a bias in some examples or demonstrations.
In some cases this is done simply to reduce the number of network parameters. With just two variables, we can plot system convergence in a two-dimensional plane. Three or more variables are difficult to display.
Recurrent Networks
Delay
Delay
u(t)
a(t)
a(0)
a(t) = u(t - 1)
Figure 2.11 Delay Block
The delay output a t is computed from its input u t according to
at = u t 1 .
(2.7)
Thus the output is the input delayed by one time step. (This assumes that
time is updated in discrete steps and takes on only integer values.) Eq. (2.7)
requires that the output be initialized at time t = 0 . This initial condition
is indicated in Figure 2.11 by the arrow coming into the bottom of the delay
block.
Integrator
Another related building block, which we will use for the continuous-time
recurrent networks in Chapters 1821, is the integrator, which is shown in
Figure 2.12.
2-13
Integrator
a(t)
u(t)
a(0)
t
0 u d + a 0 .
(2.8)
The initial condition a 0 is indicated by the arrow coming into the bottom
of the integrator block.
Recurrent Network
Initial
Condition
Recurrent Layer
Sx1
SxS
1
S
n(t + 1)
a(t + 1)
Sx1
Sx1
b
Sx1
a(0) = p
S
a(t + 1) = satlins (Wa(t) + b)
2-14
a(t)
Sx1
Network Architectures
In this particular network the vector p supplies the initial conditions (i.e.,
a 0 = p ). Then future outputs of the network are computed from previous
outputs:
a 1 = satlins Wa 0 + b , a 2 = satlins Wa 1 + b , . . .
Recurrent networks are potentially more powerful than feedforward networks and can exhibit temporal behavior. These types of networks are discussed in Chapters 3, 14 and 1821.
2-15
Summary of Results
Single-Input Neuron
General Neuron
Inputs
1
a = f (wp + b)
Multiple-Input Neuron
Inputs Multiple-Input Neuron
p1
p2
p3
pR
w1, 1
w1, R
1
a = f (Wp + b)
Input
Multiple-Input Neuron
p
Rx1
1
R
W
1xR
a
n
1x1
b
1x1
1
a = f (Wp + b)
2-16
1x1
Summary of Results
Transfer Functions
Name
Input/Output Relation
Hard Limit
a = 0
n0
a = 1
n0
a = 1
n0
a = +1
n0
Linear
Saturating Linear
Symmetric Saturating
Linear
n0
a = n
0n1
a = 1
n1
a = 1
n 1
a = n
1 n 1
a = 1
n1
1
a = --------------n
1+e
Hyperbolic Tangent
Sigmoid
e e
a = ----------------n
n
e +e
Competitive
a = 0
a = n
hardlims
satlin
satlins
logsig
tansig
n0
poslin
0n
a = 1
a = 0
2-17
Function
purelin
a = 0
MATLAB
hardlim
a = n
Log-Sigmoid
Positive Linear
Icon
compet
Layer of Neurons
Layer of S Neurons
Input
p
Rx1
SxR
Sx1
b
Sx1
Sx1
f
S
a = f(Wp + b)
First Layer
p
Rx1
1
R
W1
S1 x R
Second Layer
a1
n1
S1 x 1
f1
S1 x 1
b1
S1 x 1
S1
a1 = f 1 (W1p + b1)
Third Layer
a2
W2
n2
S2 x S1
S2 x 1
f2
S2 x 1
b2
S2 x 1
S2
a2 = f 2 (W2a1 + b2)
W3
S3 x S2
Delay
u(t)
a(t)
a(0)
a(t) = u(t - 1)
2-18
n3
S3 x 1
f3
b3
S3 x 1
S3
a3 = f 3 (W3a2 + b3)
Delay
a3
S3 x 1
Summary of Results
Integrator
Integrator
a(t)
u(t)
a(0)
t
Recurrent Network
Initial
Condition
Recurrent Layer
Sx1
SxS
1
S
n(t + 1)
a(t + 1)
Sx1
Sx1
b
Sx1
a(0) = p
a(t)
Sx1
S
a(t + 1) = satlins (Wa(t) + b)
2-19
Solved Problems
P2.1 The input to a single-input neuron is 2.0, its weight is 2.3 and its
bias is -3.
i. What is the net input to the transfer function?
ii. What is the neuron output?
i. The net input is given by:
n = wp + b = 2.3 2 + 3 = 1.6
ii. The output cannot be determined because the transfer function is not
specified.
P2.2 What is the output of the neuron of P2.1 if it has the following
transfer functions?
i. Hard limit
ii. Linear
iii. Log-sigmoid
i. For the hard limit transfer function:
a = hardlim 1.6 = 1.0
ii. For the linear transfer function:
a = purelin 1.6 = 1.6
iii. For the log-sigmoid transfer function:
1
- = 0.8320
a = logsig 1.6 = ----------------- 1.6
1+e
2+2
ans =
4
Verify this result using MATLAB and the function logsig, which is in the
MININNET directory (see Appendix B).
P2.3 Given a two-input neuron with the following parameters: b = 1.2 ,
T
W = 3 2 and p = 5 6 , calculate the neuron output for the following transfer functions:
i. A symmetrical hard limit transfer function
ii. A saturating linear transfer function
2-20
Solved Problems
2-21
Epilogue
This chapter has introduced a simple artificial neuron and has illustrated
how different neural networks can be created by connecting groups of neurons in various ways. One of the main objectives of this chapter has been to
introduce our basic notation. As the networks are discussed in more detail
in later chapters, you may wish to return to Chapter 2 to refresh your memory of the appropriate notation.
This chapter was not meant to be a complete presentation of the networks
we have discussed here. That will be done in the chapters that follow. We
will begin in Chapter 3, which will present a simple example that uses
some of the networks described in this chapter, and will give you an opportunity to see these networks in action. The networks demonstrated in
Chapter 3 are representative of the types of networks that are covered in
the remainder of this text.
2-22
Exercises
Exercises
E2.1 A single input neuron has a weight of 1.3 and a bias of 3.0. What possible
kinds of transfer functions, from Table 2.1, could this neuron have, if its
output is given below. In each case, give the value of the input that would
produce these outputs.
i. 1.6
ii. 1.0
iii. 0.9963
iv. -1.0
E2.2 Consider a single-input neuron with a bias. We would like the output to be
-1 for inputs less than 3 and +1 for inputs greater than or equal to 3.
i. What kind of a transfer function is required?
ii. What bias would you suggest? Is your bias in any way related to the
input weight? If yes, how?
2+2
ans =
4
iii. Summarize your network by naming the transfer function and stating the bias and the weight. Draw a diagram of the network. Verify
the network performance using MATLAB.
E2.3 Given a two-input neuron with the following weight matrix and input vecT
2-23
General Neuron
Input
b
1
a = f (wp + b)
Figure P15.1 General Neuron
Sketch the neuron response (plot a versus p for -2<p<2) for the following
cases.
i. w = 1 , b = 1 , f = hardlims .
ii. w = 1 , b = 1 , f = hardlims .
iii. w = 2 , b = 3 , f = purelin .
iv. w = 2 , b = 3 , f = satlins .
v. w = 2 , b = 1 , f = poslin .
2-24
Exercises
Input
w11,1
n11
Linear Layer
a11
2
w21,1
b11
w12,1
a12
n2
b2
a21
b21
w 1,2
n21
1
a = satlin(W p + b )
1
a = purelin(W a + b )
2
w 1 1 = 2 , w 2 1 = 1 , b 1 = 2 , b 2 = 1 , w 1 1 = 1 , w 1 2 = 1 , b 1 = 0
Sketch the following responses (plot the indicated variable versus p for
3 p 3 ).
1
i. n 1 .
1
ii. a 1 .
1
iii. n 2
1
iv. a 2 .
2
v. n 1 .
2
vi. a 1 .
2-25
Objectives
An Illustrative Example
Objectives
3-1
3-2
Problem Statement
3-2
Perceptron
3-3
Two-Input Case
3-4
3-5
Hamming Network
3-8
Feedforward Layer
3-9
Recurrent Layer
3-10
Hopfield Network
3-12
Epilogue
3-15
Exercises
3-16
Objectives
Think of this chapter as a preview of coming attractions. We will take a
simple pattern recognition problem and show how it can be solved using
three different neural network architectures. It will be an opportunity to
see how the architectures described in the previous chapter can be used to
solve a practical (although extremely oversimplified) problem. Do not expect to completely understand these three networks after reading this
chapter. We present them simply to give you a taste of what can be done
with neural networks, and to demonstrate that there are many different
types of networks that can be used to solve a given problem.
The three networks presented in this chapter are representative of the
types of networks discussed in the remaining chapters: feedforward networks (represented here by the perceptron), competitive networks (represented here by the Hamming network) and recurrent associative memory
networks (represented here by the Hopfield network).
3-1
3 An Illustrative Example
Neural
Network
Sensors
Sorter
Apples
Oranges
As each fruit passes through the sensors it can be represented by a threedimensional vector. The first element of the vector will represent shape,
the second element will represent texture and the third element will represent weight:
3-2
Perceptron
shape
p = texture .
weight
(3.1)
(3.2)
p2 =
1
1 .
1
(3.3)
The neural network will receive one three-dimensional input vector for
each fruit on the conveyer and must make a decision as to whether the fruit
is an orange p 1 or an apple p 2 .
Now that we have defined this simple (trivial?) pattern recognition problem, lets look briefly at three different neural networks that could be used
to solve it. The simplicity of our problem will facilitate our understanding
of the operation of the networks.
Perceptron
The first network we will discuss is the perceptron. Figure 3.1 illustrates a
single-layer perceptron with a symmetric hard limit transfer function hardlims.
Inputs
p
Rx1
1
R
Sym. Hard
- Title
Limit
- Layer
W
SxR
a
Sx1
n
Sx1
b
Sx1
- Exp (Wp
a = hardlims
+ b)
Figure 3.1 Single-Layer Perceptron
3-3
3 An Illustrative Example
Two-Input Case
Before we use the perceptron to solve the orange and apple recognition
problem (which will require a three-input perceptron, i.e., R = 3 ), it is useful to investigate the capabilities of a two-input/single-neuron perceptron
( R = 2 ), which can be easily analyzed graphically. The two-input perceptron is shown in Figure 3.2.
Inputs
Two-Input Neuron
p1
w1,1
p2
w1,2
1
a = hardlims (Wp + b)
Figure 3.2 Two-Input/Single-Neuron Perceptron
Single-neuron perceptrons can classify input vectors into two categories.
For example, for a two-input perceptron, if w 1 1 = 1 and w 1 2 = 1 then
a = hardlims n = hardlims 1 1 p + b .
(3.4)
Therefore, if the inner product of the weight matrix (a single row vector in
this case) with the input vector is greater than or equal to b , the output
will be 1. If the inner product of the weight vector and the input is less than
b , the output will be 1 . This divides the input space into two parts. Figure 3.3 illustrates this for the case where b = 1 . The blue line in the figure represents all points for which the net input n is equal to 0:
n = 1 1 p 1 = 0 .
(3.5)
Notice that this decision boundary will always be orthogonal to the weight
matrix, and the position of the boundary can be shifted by changing b . (In
the general case, W is a matrix consisting of a number of row vectors, each
of which will be used in an equation like Eq. (3.5). There will be one boundary for each row of W . See Chapter 4 for more on this topic.) The shaded
region contains all input vectors for which the output of the network will
be 1. The output will be 1 for all other input vectors.
3-4
Perceptron
p2
W
n>0
n<0
3
1
-1
p1
(3.6)
Because the boundary must be linear, the single-layer perceptron can only
be used to recognize patterns that are linearly separable (can be separated
by a linear boundary). These concepts will be discussed in more detail in
Chapter 4.
p1
a = hardlims w 1 1 w 1 2 w 1 3 p 2 + b .
p3
(3.7)
We want to choose the bias b and the elements of the weight matrix so that
the perceptron will be able to distinguish between apples and oranges. For
example, we may want the output of the perceptron to be 1 when an apple
is input and 1 when an orange is input. Using the concept illustrated in
Figure 3.3, lets find a linear boundary that can separate oranges and ap-
3-5
3 An Illustrative Example
ples. The two prototype vectors (recall Eq. (3.2) and Eq. (3.3)) are shown in
Figure 3.4. From this figure we can see that the linear boundary that divides these two vectors symmetrically is the p 1 p 3 plane.
p3
p2
p1
p2 (apple)
p1 (orange)
(3.8)
or
p1
0 1 0 p2 + 0 = 0 .
p3
(3.9)
(3.10)
The weight matrix is orthogonal to the decision boundary and points toward the region that contains the prototype pattern p 2 (apple) for which we
want the perceptron to produce an output of 1. The bias is 0 because the
decision boundary passes through the origin.
Now lets test the operation of our perceptron pattern classifier. It classifies
perfect apples and oranges correctly since
3-6
Perceptron
Orange:
a = hardlims 0 1 0 1 + 0 = 1 orange ,
(3.11)
Apple:
a = hardlims 0 1 0 1 + 0 = 1 apple .
3
(3.12)
But what happens if we put a not-so-perfect orange into the classifier? Lets
say that an orange with an elliptical shape is passed through the sensors.
The input vector would then be
1
p = 1 .
1
(3.13)
a = hardlims 0 1 0 1 + 0 = 1 orange .
(3.14)
In fact, any input vector that is closer to the orange prototype vector than
to the apple prototype vector (in Euclidean distance) will be classified as an
orange (and vice versa).
To experiment with the perceptron network and the apple/orange classification problem, use the Neural Network Design Demonstration Perceptron
Classification (nnd3pc).
This example has demonstrated some of the features of the perceptron network, but by no means have we exhausted our investigation of perceptrons.
This network, and variations on it, will be examined in Chapters 4 through
13. Lets consider some of these future topics.
In the apple/orange example we were able to design a network graphically,
by choosing a decision boundary that clearly separated the patterns. What
about practical problems, with high dimensional input spaces? In Chapters
4, 7, 10 and 11 we will introduce learning algorithms that can be used to
3-7
3 An Illustrative Example
Hamming Network
The next network we will consider is the Hamming network [Lipp87]. It
was designed explicitly to solve binary pattern recognition problems
(where each element of the input vector has only two possible values in
our example 1 or 1 ). This is an interesting network, because it uses both
feedforward and recurrent (feedback) layers, which were both described in
Chapter 2. Figure 3.5 shows the standard Hamming network. Note that
the number of neurons in the first layer is the same as the number of neurons in the second layer.
The objective of the Hamming network is to decide which prototype vector
is closest to the input vector. This decision is indicated by the output of the
recurrent layer. There is one neuron in the recurrent layer for each prototype pattern. When the recurrent layer converges, there will be only one
neuron with nonzero output. This neuron indicates the prototype pattern
that is closest to the input vector. Now lets investigate the two layers of the
Hamming network in detail.
Feedforward Layer
p
Rx1
1
R
W1
SxR
n1
a1
Sx1
Sx1
b1
Sx1
Recurrent Layer
n2(t + 1)
W
SxS
- Exp 1(W
- 1 p + b 1)
a1 = purelin
a2(t + 1)
Sx1
Sx1
S
a2(0) = a1
3-8
a2(t)
Sx1
Hamming Network
Feedforward Layer
The feedforward layer performs a correlation, or inner product, between
each of the prototype patterns and the input pattern (as we will see in Eq.
(3.17)). In order for the feedforward layer to perform this correlation, the
rows of the weight matrix in the feedforward layer, represented by the con1
nection matrix W , are set to the prototype patterns. For our apple and orange example this would mean
W1 =
p 1T
p 2T
= 1 1 1 .
1 1 1
(3.15)
The feedforward layer uses a linear transfer function, and each element of
the bias vector is equal to R , where R is the number of elements in the input vector. For our example the bias vector would be
b1 = 3 .
3
(3.16)
With these choices for the weight matrix and bias vector, the output of the
feedforward layer is
T
a = W p+b =
p1 p + 3
.
p+ 3 =
T
T
3
p2
p2 p + 3
p1
(3.17)
Note that the outputs of the feedforward layer are equal to the inner products of each prototype pattern with the input, plus R . For two vectors of
equal length (norm), their inner product will be largest when the vectors
point in the same direction, and will be smallest when they point in opposite directions. (We will discuss this concept in more depth in Chapters 5,
8 and 9.) By adding R to the inner product we guarantee that the outputs
of the feedforward layer can never be negative. This is required for proper
operation of the recurrent layer.
This network is called the Hamming network because the neuron in the
feedforward layer with the largest output will correspond to the prototype
pattern that is closest in Hamming distance to the input pattern. (The
Hamming distance between two vectors is equal to the number of elements
that are different. It is defined only for binary vectors.) We leave it to the
reader to show that the outputs of the feedforward layer are equal to 2R
minus twice the Hamming distances from the prototype patterns to the input pattern.
3-9
3 An Illustrative Example
Recurrent Layer
The recurrent layer of the Hamming network is what is known as a competitive layer. The neurons in this layer are initialized with the outputs of
the feedforward layer, which indicate the correlation between the prototype patterns and the input vector. Then the neurons compete with each
other to determine a winner. After the competition, only one neuron will
have a nonzero output. The winning neuron indicates which category of input was presented to the network (for our example the two categories are
apples and oranges). The equations that describe the competition are:
a2 0 = a
(Initial Condition),
(3.18)
and
a 2 t + 1 = poslin W 2 a 2 t .
(3.19)
(Dont forget that the superscripts here indicate the layer number, not a
power of 2.) The poslin transfer function is linear for positive values and
zero for negative values. The weight matrix W2 has the form
W2 =
1 ,
1
(3.20)
where is some number less than 1 S 1 , and S is the number of neurons in the recurrent layer. (Can you show why must be less than
1 S 1 ?)
An iteration of the recurrent layer proceeds as follows:
2
2
a t a 2 t
a 2 t + 1 = poslin 1 a 2 t = poslin 1
2
2
1
a 2 t a 1 t
(3.21)
Each element is reduced by the same fraction of the other. The larger element will be reduced by less, and the smaller element will be reduced by
more, therefore the difference between large and small will be increased.
The effect of the recurrent layer is to zero out all neuron outputs, except the
one with the largest initial value (which corresponds to the prototype pattern that is closest in Hamming distance to the input).
To illustrate the operation of the Hamming network, consider again the oblong orange that we used to test the perceptron:
3-10
Hamming Network
1
p = 1 .
1
(3.22)
(3.23)
which will then become the initial condition for the recurrent layer.
The weight matrix for the recurrent layer will be given by Eq. (3.20) with
= 1 2 (any number less than 1 would work). The first iteration of the recurrent layer produces
poslin 1 0.5
0.5 1
a 2 1 = poslin W 2 a 2 0 =
poslin 3 =
2
.
(3.24)
(3.25)
3
0
poslin 1 0.5
0.5 1
a 2 2 = poslin W 2 a 2 1 =
poslin 3 =
1.5
0
3
0
Since the outputs of successive iterations produce the same result, the network has converged. Prototype pattern number one, the orange, is chosen
as the correct match, since neuron number one has the only nonzero outT
1
put. (Recall that the first element of a was p 1 p + 3 .) This is the correct
choice, since the Hamming distance from the orange prototype to the input
pattern is 1, and the Hamming distance from the apple prototype to the input pattern is 2.
To experiment with the Hamming network and the apple/orange classification problem, use the Neural Network Design Demonstration Hamming
Classification (nnd3hamc).
3-11
3 An Illustrative Example
There are a number of networks whose operation is based on the same principles as the Hamming network; that is, where an inner product operation
(feedforward layer) is followed by a competitive dynamic layer. These competitive networks will be discussed in Chapters 15, 16, 18 and 19. They are
self-organizing networks, which can learn to adjust their prototype vectors
based on the inputs that have been presented.
Hopfield Network
The final network we will discuss in this brief preview is the Hopfield network. This is a recurrent network that is similar in some respects to the recurrent layer of the Hamming network, but which can effectively perform
the operations of both layers of the Hamming network. A diagram of the
Hopfield network is shown in Figure 3.6. (This figure is actually a slight
variation of the standard Hopfield network. We use this variation because
it is somewhat simpler to describe and yet demonstrates the basic concepts.)
The neurons in this network are initialized with the input vector, then the
network iterates until the output converges. When the network is operating correctly, the resulting output should be one of the prototype vectors.
Therefore, whereas in the Hamming network the nonzero neuron indicates
which prototype pattern is chosen, the Hopfield network actually produces
the selected prototype pattern at its output.
Initial
Condition
Recurrent Layer
Sx1
SxS
1
S
n(t + 1)
a(t + 1)
Sx1
Sx1
b
Sx1
a(0) = p
a(t)
Sx1
S
a(t + 1) = satlins (Wa(t) + b)
3-12
(3.26)
Hopfield Network
a t + 1 = satlins Wa t + b ,
(3.27)
where satlins is the transfer function that is linear in the range [-1, 1] and
saturates at 1 for inputs greater than 1 and at -1 for inputs less than -1.
The design of the weight matrix and the bias vector for the Hopfield network is a more complex procedure than it is for the Hamming network,
where the weights in the feedforward layer are the prototype patterns.
Hopfield design procedures will be discussed in detail in Chapter 21.
To illustrate the operation of the network, we have determined a weight
matrix and a bias vector that can solve our orange and apple pattern recognition problem. They are given in Eq. (3.28).
W =
0.2 0 0
0.9
b
=
0 1.2 0
0
0 0 0.2
0.9
(3.28)
Although the procedure for computing the weights and biases for the
Hopfield network is beyond the scope of this chapter, we can say a few
things about why the parameters in Eq. (3.28) work for the apple and orange example.
We want the network output to converge to either the orange pattern, p 1 ,
or the apple pattern, p 2 . In both patterns, the first element is 1 , and the
third element is 1 . The difference between the patterns occurs in the second element. Therefore, no matter what pattern is input to the network, we
want the first element of the output pattern to converge to 1 , the third element to converge to 1 , and the second element to go to either 1 or 1 ,
whichever is closer to the second element of the input vector.
The equations of operation of the Hopfield network, using the parameters
given in Eq. (3.28), are
a 1 t + 1 = satlins 0.2a 1 t + 0.9
a 2 t + 1 = satlins 1.2a 2 t
a 3 t + 1 = satlins 0.2a 3 t 0.9
(3.29)
3-13
3 An Illustrative Example
(It should be noted that this is not the only (W, b) pair that could be used.
You might want to try some others. See if you can discover what makes
these work.)
Lets again take our oblong orange to test the Hopfield network. The outputs of the Hopfield network for the first three iterations would be
1
0.7
1
1
a 0 = 1 , a 1 = 1 , a 2 = 1 , a 3 = 1
1
1
1
1
(3.30)
The network has converged to the orange pattern, as did both the Hamming
network and the perceptron, although each network operated in a different
way. The perceptron had a single output, which could take on values of -1
(orange) or 1 (apple). In the Hamming network the single nonzero neuron indicated which prototype pattern had the closest match. If the first neuron
was nonzero, that indicated orange, and if the second neuron was nonzero,
that indicated apple. In the Hopfield network the prototype pattern itself
appears at the output of the network.
To experiment with the Hopfield network and the apple/orange classification problem, use the Neural Network Design Demonstration Hopfield Classification (nnd3hopc).
As with the other networks demonstrated in this chapter, do not expect to
feel completely comfortable with the Hopfield network at this point. There
are a number of questions that we have not discussed. For example, How
do we know that the network will eventually converge? It is possible for
recurrent networks to oscillate or to have chaotic behavior. In addition, we
have not discussed general procedures for designing the weight matrix and
the bias vector. These topics will be discussed in detail in Chapters 20 and
21.
3-14
Epilogue
Epilogue
The three networks that we have introduced in this chapter demonstrate
many of the characteristics that are found in the architectures which are
discussed throughout this book.
Feedforward networks, of which the perceptron is one example, are presented in Chapters 4, 7, 11, 12, 13 and 17. In these networks, the output is
computed directly from the input in one pass; no feedback is involved.
Feedforward networks are used for pattern recognition, as in the apple and
orange example, and also for function approximation (see Chapter 11).
Function approximation applications are found in such areas as adaptive
filtering (see Chapter 10) and automatic control.
Competitive networks, represented here by the Hamming network, are
characterized by two properties. First, they compute some measure of distance between stored prototype patterns and the input pattern. Second,
they perform a competition to determine which neuron represents the prototype pattern closest to the input. In the competitive networks that are
discussed in Chapters 16, 18 and 19, the prototype patterns are adjusted
as new inputs are applied to the network. These adaptive networks learn
to cluster the inputs into different categories.
Recurrent networks, like the Hopfield network, were originally inspired by
statistical mechanics. They have been used as associative memories, in
which stored data is recalled by association with input data, rather than by
an address. They have also been used to solve a variety of optimization
problems. We will discuss these recurrent networks in Chapters 20 and 21.
We hope this chapter has piqued your curiosity about the capabilities of
neural networks and has raised some questions. A few of the questions we
will answer in later chapters are:
1. How do we determine the weight matrix and bias for perceptron networks with many inputs, where it is impossible to visualize the decision
boundary? (Chapters 4 and 10)
2. If the categories to be recognized are not linearly separable, can we extend the standard perceptron to solve the problem? (Chapters 11, 12
and 13)
3. Can we learn the weights and biases of the Hamming network when we
dont know the prototype patterns? (Chapters 16, 18 and 19)
4. How do we determine the weight matrix and bias vector for the
Hopfield network? (Chapter 21)
5. How do we know that the Hopfield network will eventually converge?
(Chapters 20 and 21)
3-15
3 An Illustrative Example
Exercises
E3.1 In this chapter we have designed three different neural networks to distinguish between apples and oranges, based on three sensor measurements
(shape, texture and weight). Suppose that we want to distinguish between
bananas and pineapples:
p1 =
1
1 (Banana)
1
1
p 2 = 1 (Pineapple)
1
i. Design a perceptron to recognize these patterns.
ii. Design a Hamming network to recognize these patterns.
iii. Design a Hopfield network to recognize these patterns.
iv. Test the operation of your networks by applying several different input patterns. Discuss the advantages and disadvantages of each
network.
E3.2 Consider the following prototype patterns.
p1 =
1 ,p = 2
2
0.5
1
Exercises
v. Calculate the network output for the Hamming network with the input vector given in part iii, showing all steps. Does the Hamming
network produce the same decision as the perceptron? Explain why
or why not. Which network is better suited to this problem? Explain.
E3.3 Consider a Hopfield network, with the following weight and bias.
W =
1 1 , b = 0
1 1
0
Inputs
p
Rx1
1
R
Sym. Hard
- Title
Limit
- Layer
W
SxR
a
Sx1
1 1
1 1
b = 2
0
Sx1
b
Sx1
W =
- Exp (Wp
a = hardlims
+ b)
i. How many different classes can this network classify?
ii. Draw a diagram illustrating the regions corresponding to each
class. Label each region with the corresponding network output.
iii. Calculate the network output for the following input.
3-17
3 An Illustrative Example
p =
1
1
iv. Plot the input from part iii in your diagram from part ii, and verify
that it falls in the correctly labeled region.
E3.5 We want to design a perceptron network to output a 1 when either of these
two vectors are input to the network:
1 1
,
2
0
and to output a -1 when either of the following vectors are input to the network:
1 0
.
2
1
i. Find and sketch a decision boundary for a network that will solve
this problem.
ii. Find weights and biases that will produce the decision boundary
you found in part i. Show all work.
iii. Draw the network diagram using abreviated notation.
iv. For each of the four vectors given above, calculate the net input, n,
and the network output, a, for the network you have designed. Verify that your network solves the problem.
v. Are there other weights and biases that would solve the problem? If
so, would you consider your weights best? Explain.
E3.6 We have the folowing two prototype vectors:
. 1 1
1
1
i. Find and sketch a decision boundary for a perceptron network that
will recognize these two vectors.
ii. Find weights and bias that will produce the decision boundary you
found in part i.
iii. Draw the network diagram using abreviated notation.
3-18
Exercises
iv. For the vector given below, calculate the net input, n, and the network output, a, for the network you have designed. Does the network produce a good output? Explain.
0.5
0.5
v. Design a Hamming network to recognize the two vectors used in
part i.
vi. Calculate the network output for the Hamming network for the input vector given in part iv. Does the network produce a good output?
Explain.
vii. Design a Hopfield network to recognize the two vectors used in part
i.
viii. Calculate the network output for the Hopfield network for the input
vector given in part iv. Does the network produce a good output? Explain.
E3.7 We want to design a Hamming network to recognize the following prototype vectors:
1 1 1
.
1
1 1
i. Find the weight matrices and bias vectors for the Hamming network.
ii. Draw the network diagram.
iii. Apply the following input vector and calculate the total network response (iterating the second layer to convergence). Explain the
meaning of the final network output.
p = 1
0
iv. Sketch the decision boundaries for this network. Explain how you
determined the boundaries.
3-19
Objectives
4-1
4-2
Learning Rules
4-2
Perceptron Architecture
4-3
Single-Neuron Perceptron
4-5
Multiple-Neuron Perceptron
4-8
4-8
Test Problem
4-9
4-10
4-12
4-13
Proof of Convergence
4-15
Notation
4-15
Proof
4-16
Limitations
4-18
Summary of Results
4-20
Solved Problems
4-21
Epilogue
4-34
Further Reading
4-35
Exercises
4-37
Objectives
One of the questions we raised in Chapter 3 was: How do we determine the
weight matrix and bias for perceptron networks with many inputs, where
it is impossible to visualize the decision boundaries? In this chapter we
will describe an algorithm for training perceptron networks, so that they
can learn to solve classification problems. We will begin by explaining what
a learning rule is and will then develop the perceptron learning rule. We
will conclude by discussing the advantages and limitations of the singlelayer perceptron network. This discussion will lead us into future chapters.
4-1
Learning Rules
Learning Rule
4-2
Perceptron Architecture
Target
(4.1)
Reinforcement Learning
Reinforcement learning is similar to supervised learning, except that, instead of being provided with the correct output for each network input, the
algorithm is only given a grade. The grade (or score) is a measure of the network performance over some sequence of inputs. This type of learning is
currently much less common than supervised learning. It appears to be
most suited to control system applications (see [BaSu83], [WhSo92]).
Unsupervised Learning
Perceptron Architecture
Before we present the perceptron learning rule, lets expand our investigation of the perceptron network, which we began in Chapter 3. The general
perceptron network is shown in Figure 4.1.
The output of the network is given by
a = hardlim Wp + b .
(4.2)
4-3
Input
p
Rx1
SxR
Sx1
Sx1
b
Sx1
a = hardlim (Wp + b)
Figure 4.1 Perceptron Network
It will be useful in our development of the perceptron learning rule to be
able to conveniently reference individual elements of the network output.
Lets see how this can be done. First, consider the network weight matrix:
w 1 1 w 1 2 w 1 R
.
(4.3)
w 2 1 w 2 2 w 2 R
W =
w S 1 w S 2 w S R
We will define a vector composed of the elements of the ith row of W :
w i 1
=
w i 2
(4.4)
(4.5)
iw
w i R
Now we can partition the weight matrix:
1w
W =
2w
T
T
Sw
This allows us to write the ith element of the network output vector as
T
a i = hardlim n i = hardlim iw p + b i .
4-4
(4.6)
Perceptron Architecture
a = hardlim (n)
Recall that the hardlim transfer function (shown at left) is defined as:
a = hardlim n = 1 if n 0
0 otherwise.
n = Wp + b
(4.7)
Therefore, if the inner product of the ith row of the weight matrix with the
input vector is greater than or equal to b i , the output will be 1, otherwise
the output will be 0. Thus each neuron in the network divides the input
space into two regions. It is useful to investigate the boundaries between
these regions. We will begin with the simple case of a single-neuron perceptron with two inputs.
Single-Neuron Perceptron
Lets consider a two-input perceptron with one neuron, as shown in Figure
4.2.
Inputs
Two-Input Neuron
p1
w1,1
p2
w1,2
1
a = hardlim (Wp + b)
Figure 4.2 Two-Input/Single-Output Perceptron
The output of this network is determined by
a = hardlim n = hardlim Wp + b
T
= hardlim 1w p + b = hardlim w 1 1 p 1 + w 1 2 p 2 + b
Decision Boundary
(4.8)
The decision boundary is determined by the input vectors for which the net
input n is zero:
T
n = 1w p + b = w 1 1 p 1 + w 1 2 p 2 + b = 0 .
(4.9)
To make the example more concrete, lets assign the following values for
the weights and bias:
w 1 1 = 1 , w 1 2 = 1 , b = 1 .
4-5
(4.10)
n = 1w p + b = w 1 1 p 1 + w 1 2 p 2 + b = p 1 + p 2 1 = 0 .
(4.11)
This defines a line in the input space. On one side of the line the network
output will be 0; on the line and on the other side of the line the output will
be 1. To draw the line, we can find the points where it intersects the p 1 and
p 2 axes. To find the p 2 intercept set p 1 = 0 :
b
1
p 2 = ---------- = ------ = 1
w 1 2
1
if p 1 = 0
.
(4.12)
(4.13)
if p 2 = 0
T
a = hardlim 1w p + b = hardlim 1 1 2 1 = 1 .
(4.14)
Therefore, the network output will be 1 for the region above and to the right
of the decision boundary. This region is indicated by the shaded area in Figure 4.3.
p2
a=1
w Tp + b = 0 1
p1
a=0
4-6
Perceptron Architecture
We can also find the decision boundary graphically. The first step is to note
that the boundary is always orthogonal to 1w , as illustrated in the adjacent
figures. The boundary is defined by
1w
p+b = 0.
(4.15)
For all points on the boundary, the inner product of the input vector with
the weight vector is the same. This implies that these input vectors will all
have the same projection onto the weight vector, so they must lie on a line
orthogonal to the weight vector. (These concepts will be covered in more detail in Chapter 5.) In addition, any vector in the shaded region of Figure 4.3
will have an inner product greater than b , and vectors in the unshaded
region will have inner products less than b . Therefore the weight vector
1w will always point toward the region where the neuron output is 1.
After we have selected a weight vector with the correct angular orientation,
the bias value can be computed by selecting a point on the boundary and
satisfying Eq. (4.15).
2
+2
0 t = 0 p = 0 t = 0 p = 1 t = 0 p = 1 t = 1 .
p1 =
2
3
4
1
2
3
4
0
1
0
1
The figure to the left illustrates the problem graphically. It displays the input space, with each input vector labeled according to its target. The dark
circles indicate that the target is 1, and the light circles indicate that
the target is 0.
The first step of the design is to select a decision boundary. We want to
have a line that separates the dark circles and the light circles. There are
an infinite number of solutions to this problem. It seems reasonable to
choose the line that falls halfway between the two categories of inputs, as
shown in the adjacent figure.
Next we want to choose a weight vector that is orthogonal to the decision
boundary. The weight vector can be any length, so there are infinite possibilities. One choice is
1w
AND
= 2 ,
2
4-7
(4.16)
p + b = 2 2 1.5 + b = 3 + b = 0
0
b = 3 .
(4.17)
We can now test the network on one of the input/target pairs. If we apply
p 2 to the network, the output will be
T
a = hardlim 1w p 2 + b = hardlim 2 2 0 3
1
a = hardlim 1 = 0,
(4.18)
which is equal to the target output t 2 . Verify for yourself that all inputs are
correctly classified.
To experiment with decision boundaries, use the Neural Network Design
Demonstration Decision Boundaries (nnd4db).
Multiple-Neuron Perceptron
Note that for perceptrons with multiple neurons, as in Figure 4.1, there
will be one decision boundary for each neuron. The decision boundary for
neuron i will be defined by
iw
p + bi = 0 .
(4.19)
4-8
(4.20)
where p q is an input to the network and t q is the corresponding target output. As each input is applied to the network, the network output is compared to the target. The learning rule then adjusts the weights and biases
of the network in order to move the network output closer to the target.
Test Problem
In our presentation of the perceptron learning rule we will begin with a
simple test problem and will experiment with possible rules to develop
some intuition about how the rule should work. The input/target pairs for
our test problem are
1 t = 1 p = 1 t = 0 p = 0 t = 0 .
p1 =
2
3
1
2
3
2
2
1
The problem is displayed graphically in the adjacent figure, where the two
input vectors whose target is 0 are represented with a light circle , and
the vector whose target is 1 is represented with a dark circle . This is a
very simple problem, and we could almost obtain a solution by inspection.
This simplicity will help us gain some intuitive understanding of the basic
concepts of the perceptron learning rule.
The network for this problem should have two-inputs and one output. To
simplify our development of the learning rule, we will begin with a network
without a bias. The network will then have just two parameters, w 1 1 and
w 1 2 , as shown in Figure 4.4.
Inputs
No-Bias Neuron
p1
w1,1
p2
w1,2
a = hardlim(Wp)
Figure 4.4 Test Problem Network
1
By removing the bias we are left with a network whose decision boundary
must pass through the origin. We need to be sure that this network is still
able to solve the test problem. There must be an allowable decision boundary that can separate the vectors p 2 and p 3 from the vector p 1 . The figure
to the left illustrates that there are indeed an infinite number of such
boundaries.
4-9
The adjacent figure shows the weight vectors that correspond to the allowable decision boundaries. (Recall that the weight vector is orthogonal to the
decision boundary.) We would like a learning rule that will find a weight
vector that points in one of these directions. Remember that the length of
the weight vector does not matter; only its direction is important.
Training begins by assigning some initial values for the network parameters. In this case we are training a two-input/single-output network without a bias, so we only have to initialize its two weights. Here we set the
elements of the weight vector, 1w , to the following randomly generated values:
1w
= 1.0 0.8 .
(4.21)
We will now begin presenting the input vectors to the network. We begin
with p 1 :
T
a = hardlim 1w p 1 = hardlim 1.0 0.8 1
2
a = hardlim 0.6 = 0 .
(4.22)
The network has not returned the correct value. The network output is 0,
while the target response, t 1 , is 1.
1
We can see what happened by looking at the adjacent diagram. The initial
weight vector results in a decision boundary that incorrectly classifies the
vector p 1 . We need to alter the weight vector so that it points more toward
p 1 , so that in the future it has a better chance of classifying it correctly.
One approach would be to set 1w equal to p 1 . This is simple and would ensure that p 1 was classified properly in the future. Unfortunately, it is easy
to construct a problem for which this rule cannot find a solution. The diagram to the lower left shows a problem that cannot be solved with the
weight vector pointing directly at either of the two class 1 vectors. If we apply the rule 1w = p every time one of these vectors is misclassified, the networks weights will simply oscillate back and forth and will never find a
solution.
Another possibility would be to add p 1 to 1w . Adding p 1 to 1w would make
1w point more in the direction of p 1 . Repeated presentations of p 1 would
cause the direction of 1w to asymptotically approach the direction of p 1 .
This rule can be stated:
If t = 1 and a = 0, then 1w
4-10
new
= 1w
old
+p.
(4.23)
Applying this rule to our test problem results in new values for 1w :
1w
new
= 1w
old
+ p1 =
1.0 + 1 = 2.0 .
0.8
2
1.2
(4.24)
T
a = hardlim 1w p 2 = hardlim 2.0 1.2 1
2
= hardlim 0.4 = 1 .
4
(4.25)
new
= 1w
old
p.
(4.26)
new
= 1w
old
p 2 = 2.0 1 = 3.0 ,
1.2
2
0.8
(4.27)
T
a = hardlim 1w p 3 = hardlim 3.0 0.8 0
1
= hardlim 0.8 = 1 .
(4.28)
new
= 1w
4-11
old
p3 =
3.0 0 = 3.0 .
0.8
1
0.2
(4.29)
The diagram to the left shows that the perceptron has finally learned to
classify the three vectors properly. If we present any of the input vectors to
the neuron, it will output the correct class for that input vector.
This brings us to our third and final rule: if it works, dont fix it.
If t = a, then 1w
3
new
= 1w
old
(4.30)
Here are the three rules, which cover all possible combinations of output
and target values:
If t = 1 and a = 0, then 1w
new
= 1w
old
+ p.
If t = 0 and a = 1, then 1w
new
= 1w
old
p.
If t = a, then 1w
new
= 1w
old
(4.31)
(4.32)
new
If e = 1, then 1w
= 1w
new
If e = 0, then 1w
old
= 1w
new
+p.
old
= 1w
p.
old
(4.33)
Looking carefully at the first two rules in Eq. (4.33) we can see that the sign
of p is the same as the sign on the error, e. Furthermore, the absence of p
in the third rule corresponds to an e of 0. Thus, we can unify the three rules
into a single expression:
1w
new
= 1w
old
+ ep = 1w
old
+ t a p .
(4.34)
This rule can be extended to train the bias by noting that a bias is simply
a weight whose input is always 1. We can thus replace the input p in Eq.
(4.34) with the input to the bias, which is 1. The result is the perceptron
rule for a bias:
b
4-12
new
= b
old
+e.
(4.35)
new
= iw
old
+ ei p .
(4.36)
new
= bi
old
+ ei .
(4.37)
new
= W
old
+ ep ,
(4.38)
old
+e.
(4.39)
and
b
2
+2
new
= b
To test the perceptron learning rule, consider again the apple/orange recognition problem of Chapter 3. The input/output prototype vectors will be
p1 = 1 t1 = 0
p2 = 1 t2 = 1 .
(4.40)
(Note that we are using 0 as the target output for the orange pattern, p 1 ,
instead of -1, as was used in Chapter 3. This is because we are using the
hardlim transfer function, instead of hardlims .)
Typically the weights and biases are initialized to small random numbers.
Suppose that here we start with the initial weight matrix and bias:
W = 0.5 1 0.5 , b = 0.5 .
(4.41)
The first step is to apply the first input vector, p 1 , to the network:
= hardlim 2.5 = 1
4-13
(4.42)
(4.43)
new
= W
old
+ ep = 0.5 1 0.5 + 1 1 1 1
(4.44)
= 0.5 0 0.5 .
The bias update is
b
new
= b
old
+ e = 0.5 + 1 = 0.5 .
(4.45)
1
1 + 0.5 )
1
= hardlim ( 0.5) = 0
(4.46)
e = t2 a = 1 0 = 1
W
new
= W
old
new
= b
old
+ e = 0.5 + 1 = 0.5
(4.47)
(4.48)
(4.49)
The third iteration begins again with the first input vector:
1
a = hardlim (Wp 1 + b) = hardlim ( 0.5 1 0.5 1 + 0.5)
1
= hardlim (0.5) = 1
e = t1 a = 0 1 = 1
W
new
= W
old
+ ep = 0.5 1 0.5 + 1 1 1 1
= 0.5 2 0.5
4-14
(4.50)
(4.51)
(4.52)
Proof of Convergence
new
= b
old
+ e = 0.5 + 1 = 0.5 .
(4.53)
If you continue with the iterations you will find that both input vectors will
now be correctly classified. The algorithm has converged to a solution. Note
that the final decision boundary is not the same as the one we developed in
Chapter 3, although both boundaries correctly classify the two input vectors.
To experiment with the perceptron learning rule, use the Neural Network
Design Demonstration Perceptron Rule (nnd4pr).
Proof of Convergence
Although the perceptron learning rule is simple, it is quite powerful. In
fact, it can be shown that the rule will always converge to weights that accomplish the desired classification (assuming that such weights exist). In
this section we will present a proof of convergence for the perceptron learning rule for the single-neuron perceptron shown in Figure 4.5.
Inputs
p1
p2
p3
pR
1
a = hardlim (1wTp + b)
Figure 4.5 Single-Neuron Perceptron
The output of this perceptron is obtained from
T
a = hardlim 1w p + b .
(4.54)
The network is provided with the following examples of proper network behavior:
{p 1, t 1} {p 2, t 2} {p Q, t Q} .
(4.55)
Notation
To conveniently present the proof we will first introduce some new notation. We will combine the weight matrix and the bias into a single vector:
4-15
x =
1w
(4.56)
b
We will also augment the input vectors with a 1, corresponding to the bias
input:
zq =
pq
(4.57)
n = 1w p + b = x z .
(4.58)
The perceptron learning rule for a single-neuron perceptron (Eq. (4.34) and
Eq. (4.35)) can now be written
x
new
= x
old
+ ez .
(4.59)
(4.60)
(4.61)
We will assume that a weight vector exists that can correctly categorize all
Q input vectors. This solution will be denoted x . For this weight vector
we will assume that
x z q 0 if t q = 1 ,
(4.62)
x z q 0 if t q = 0 .
(4.63)
and
T
Proof
We are now ready to begin the proof of the perceptron convergence theorem. The objective of the proof is to find upper and lower bounds on the
length of the weight vector at each stage of the algorithm.
4-16
Proof of Convergence
Assume that the algorithm is initialized with the zero weight vector:
x 0 = 0 . (This does not affect the generality of our argument.) Then, after
k iterations (changes to the weight vector), we find from Eq. (4.60):
x k = z' 0 + z' 1 + + z' k 1 .
(4.64)
If we take the inner product of the solution weight vector with the weight
vector at iteration k we obtain
x x k = x z' 0 + x z' 1 + + x z' k 1 .
T
(4.65)
(4.66)
x x k k .
(4.67)
Therefore
T
x x k x
T
xk ,
(4.68)
where
x
= x x.
(4.69)
If we combine Eq. (4.67) and Eq. (4.68) we can put a lower bound on the
squared length of the weight vector at iteration k :
2
xk
T
2
x x k k
-------------------------
------------.
2
2
x
x
(4.70)
Next we want to find an upper bound for the length of the weight vector.
We begin by finding the change in the length at iteration k :
xk
= x k x k
T
= x k 1 + z' k 1 x k 1 + z' k 1
T
(4.71)
= x k 1 x k 1 + 2x k 1 z' k 1
T
+ z' k 1 z' k 1
Note that
T
x k 1 z' k 1 0 ,
4-17
(4.72)
since the weights would not be updated unless the previous input vector
had been misclassified. Now Eq. (4.71) can be simplified to
2
xk
xk 1
+ z' k 1 .
2
(4.73)
z' 0
+ + z' k 1 .
2
(4.74)
k .
(4.75)
We now have an upper bound (Eq. (4.75)) and a lower bound (Eq. (4.70)) on
the squared length of the weight vector at iteration k . If we combine the
two inequalities we find
k x k
2
2
k
x
.
------------2- or k ----------------2
(4.76)
Because k has an upper bound, this means that the weights will only be
changed a finite number of times. Therefore, the perceptron learning rule
will converge in a finite number of iterations.
The maximum number of iterations (changes to the weight vector) is inversely related to the square of . This parameter is a measure of how close
the solution decision boundary is to the input patterns. This means that if
the input classes are difficult to separate (are close to the decision boundary) it will take many iterations for the algorithm to converge.
Note that there are only three key assumptions required for the proof:
1. A solution to the problem exists, so that Eq. (4.66) is satisfied.
2. The weights are only updated when the input vector is misclassified,
therefore Eq. (4.72) is satisfied.
3. An upper bound, , exists for the length of the input vectors.
Because of the generality of the proof, there are many variations of the perceptron learning rule that can also be shown to converge. (See Exercise
E4.13.)
Limitations
The perceptron learning rule is guaranteed to converge to a solution in a
finite number of steps, so long as a solution exists. This brings us to an important question. What problems can a perceptron solve? Recall that a sin-
4-18
Proof of Convergence
gle-neuron perceptron is able to divide the input space into two regions.
The boundary between the regions is defined by the equation
1w
Linear Separability
p+b = 0.
(4.77)
This is a linear boundary (hyperplane). The perceptron can be used to classify input vectors that can be separated by a linear boundary. We call such
vectors linearly separable. The logical AND gate example on page 4-7 illustrates a two-dimensional example of a linearly separable problem. The apple/orange recognition problem of Chapter 3 was a three-dimensional
example.
Unfortunately, many problems are not linearly separable. The classic example is the XOR gate. The input/target pairs for the XOR gate are
0 t = 0 p = 0 t = 1 p = 1 t = 1 p = 1 t = 0 .
p1 =
2
3
4
1
2
3
4
0
1
0
1
This problem is illustrated graphically on the left side of Figure 4.6, which
also shows two other linearly inseparable problems. Try drawing a straight
line between the vectors with targets of 1 and those with targets of 0 in any
of the diagrams of Figure 4.6.
4-19
Summary of Results
Perceptron Architecture
Input
p
Rx1
Sx1
SxR
1
R
Sx1
b
Sx1
a = hardlim (Wp + b)
1w
W =
2w
T
T
Sw
a = hardlim Wp + b
a i = hardlim n i = hardlim iw p + b i
Decision Boundary
iw
p + bi = 0 .
new
= b
old
+e
where e = t a .
4-20
Solved Problems
Solved Problems
P4.1 Solve the three simple classification problems shown in Figure
P4.1 by drawing a decision boundary. Find weight and bias values
that result in single-neuron perceptrons with the chosen decision
boundaries.
(a)
(b)
(c)
(a)
(b)
(c)
The next step is to find the weights and biases. The weight vectors must be
orthogonal to the decision boundaries, and pointing in the direction of
points to be classified as 1 (the dark points). The weight vectors can have
any length we like.
1w
1w
1w
(a)
(b)
(c)
4-21
Now we find the bias values for each perceptron by picking a point on the
decision boundary and satisfying Eq. (4.15).
1w
p+b = 0
T
b = 1w p
This gives us the following three biases:
(a) b = 2 1 0 = 0 , (b) b = 0 2 0 = 2 , (c) b = 2 2 2 = 6
0
1
1
We can now check our solution against the original points. Here we test the
T
a = hardlim 1w p + b
= hardlim 2 1 2 + 0
2
= hardlim 6
= 1
2+2
ans =
4
We can use MATLAB to automate the testing process and to try new points.
Here the first network is used to classify a point that was not in the original
problem.
w=[-2 1]; b = 0;
a = hardlim(w*[1;1]+b)
a =
0
P4.2 Convert the classification problem defined below into an equivalent problem definition consisting of inequalities constraining
weight and bias values.
0 t = 1 p = 1 t = 1 p = 0 t = 0 p = 2 t = 0
p1 =
2
3
4
1
2
3
4
2
0
2
0
4-22
Solved Problems
Each target t i indicates whether or not the net input in response to p i must
be less than 0, or greater than or equal to 0. For example, since t 1 is 1, we
know that the net input corresponding to p 1 must be greater than or equal
to 0. Thus we get the following inequality:
Wp 1 + b 0
0w 1 1 + 2w 1 2 + b 0
2w 1 2 + b 0.
Applying the same procedure to the input/target pairs for p 2 t 2 , p 3 t 3
and p 4 t 4 results in the following set of inequalities.
2w 1 2 + b 0
w 1 1 + b 0
ii
2w 1 2 + b 0 iii
2w 1 1 + b 0 iv
Solving a set of inequalities is more difficult than solving a set of equalities.
One added complexity is that there are often an infinite number of solutions (just as there are often an infinite number of linear decision boundaries that can solve a linearly separable classification problem).
However, because of the simplicity of this problem, we can solve it by
graphing the solution spaces defined by the inequalities. Note that w 1 1
only appears in inequalities (ii) and (iv), and w 1 2 only appears in inequalities (i) and (iii). We can plot each pair of inequalities with two graphs.
w1,1
w1,2
ii
iv
iii
Any weight and bias values that fall in both dark gray regions will solve the
classification problem.
Here is one such solution:
W = 2 3
4-23
b = 3.
class 1: p 1 = 1 p 2 = 1 , class 2: p 3 = 2 p 4 = 2 ,
1
2
1
0
class 3: p 5 = 1 p 6 = 2 , class 4:
2
1
1 p = 2 .
p7 =
8
1
2
Input
p
2x1
1
2
W
2x2
a
2x1
n
2x1
b
2x1
a = hardlim (Wp + b)
Figure P4.2 Two-Neuron Perceptron
Lets begin by displaying the input vectors, as in Figure P4.3. The light circles indicate class 1 vectors, the light squares indicate class 2 vectors,
the dark circles indicate class 3 vectors, and the dark squares indicate
class 4 vectors.
A two-neuron perceptron creates two decision boundaries. Therefore, to divide the input space into the four categories, we need to have one decision
boundary divide the four classes into two sets of two. The remaining boundary must then isolate each class. Two such boundaries are illustrated in
Figure P4.4. We now know that our patterns are linearly separable.
4-24
Solved Problems
2
4
Figure P4.3 Input Vectors for Problem P4.3
2
4
class 1: t 1 = 0 t 2 = 0 , class 2: t 3 = 0 t 4 = 0 ,
0
0
1
1
class 3: t 5 = 1 t 6 = 1 , class 4:
0
0
4-25
1 t = 1 .
t7 =
8
1
1
1w
= 3 and 2w = 1 .
1
2
Note that the lengths of the weight vectors is not important, only their directions. They must be orthogonal to the decision boundaries. Now we can
calculate the bias by picking a point on a boundary and satisfying Eq.
(4.15):
T
b 1 = 1w p = 3 1 0 = 1 ,
1
T
b 2 = 2w p = 1 2 0 = 0 .
0
2
4
W =
1w
2w
T
T
= 3 1 and b = 1 ,
0
1 2
4-26
Solved Problems
2 t = 0 p = 1 t = 1 p = 2 t = 0 p = 1 t = 1
p1 =
2
3
4
1
2
3
4
2
2
2
1
b0 = 0 .
We start by calculating the perceptrons output a for the first input vector
p 1 , using the initial weights and bias.
a = hardlim W 0 p 1 + b 0
= hardlim 0 0 2 + 0 = hardlim 0 = 1
2
The output a does not equal the target value t 1 , so we use the perceptron
rule to find new weights and biases based on the error.
e = t1 a = 0 1 = 1
T
W 1 = W 0 + ep 1 = 0 0 + 1 2 2 = 2 2
b 1 = b 0 + e = 0 + 1 = 1
We now apply the second input vector p 2 , using the updated weights and
bias.
a = hardlim W 1 p 2 + b 1
= hardlim 2 2 1 1 = hardlim 1 = 1
2
This time the output a is equal to the target t 2 . Application of the perceptron rule will not result in any changes.
W2 = W1
b2 = b1
We now apply the third input vector.
4-27
a = hardlim W 2 p 3 + b 2
= hardlim 2 2 2 1 = hardlim 1 = 0
2
The output in response to input vector p 3 is equal to the target t 3 , so there
will be no changes.
W3 = W2
b3 = b2
We now move on to the last input vector p 4 .
a = hardlim W 3 p 4 + b 3
= hardlim 2 2 1 1 = hardlim 1 = 0
1
This time the output a does not equal the appropriate target t 4 . The perceptron rule will result in a new set of values for W and b .
e = t4 a = 1 0 = 1
T
W 4 = W 3 + ep 4 = 2 2 + 1 1 1 = 3 1
b4 = b3 + e = 1 + 1 = 0
We now must check the first vector p 1 again. This time the output a is
equal to the associated target t 1 .
a = hardlim W 4 p 1 + b 4
= hardlim 3 1 2 + 0 = hardlim 8 = 0
2
Therefore there are no changes.
W5 = W4
b5 = b4
4-28
Solved Problems
= hardlim 3 1 1 + 0 = hardlim 1 = 0
2
Here are those new values:
e = t2 a = 1 0 = 1
T
W 6 = W 5 + ep 2 = 3 1 + 1 1 2 = 2 3
b 6 = b 5 + e = 0 + 1 = 1.
Cycling through each input vector once more results in no errors.
a = hardlim W 6 p 3 + b 6 = hardlim 2 3 2 + 1 = 0 = t 3
a = hardlim W 6 p 4 + b 6 = hardlim 2 3 1 + 1 = 1 = t 4
a = hardlim W 6 p 1 + b 6 = hardlim 2 3 2 + 1 = 0 = t 1
a = hardlim W 6 p 2 + b 6 = hardlim 2 3 1 + 1 = 1 = t 2
2
Therefore the algorithm has converged. The final solution is:
W = 2 3
b = 1.
Now we can graph the training data and the decision boundary of the solution. The decision boundary is given by
n = Wp + b = w 1 1 p 1 + w 1 2 p 2 + b = 2p 1 3p 2 + 1 = 0 .
To find the p 2 intercept of the decision boundary, set p 1 = 0 :
b
1
1
p 2 = ---------- = ------ = --w 1 2
3
3
4-29
if p 1 = 0
.
if p 2 = 0
.
1 t = 0 p = 1 t = 0 p = 2 t = 0
p1 =
2
3
1
2
3
1
0
2
0
1
1
2 t = 0 p = 1 t = 1 p = 2 t = 1
p4 =
5
6
4
5
6
0
1
2
0
1
0
1 t = 1 p = 2 t = 1 .
p7 =
8
7
8
1
1
2
1
Lets begin the algorithm with the following initial weights and biases:
W 0 = 1 0 , b 0 = 1 .
0 1
1
The first iteration is
4-30
Solved Problems
a = hardlim (W 0 p 1 + b 0 ) = hardlim ( 1 0 1 + 1 ) = 1 ,
0 1 1
1
1
e = t1 a = 0 1 = 1 ,
0
1
1
T
W 1 = W 0 + ep 1 = 1 0 + 1 1 1 = 0 1 ,
0 1
1
1 0
b 1 = b 0 + e = 1 + 1 = 0 .
1
1
0
W 2 = W 1 + ep 2 =
0 1 + 0
0 1 ,
1 2 =
1 0
0
1 0
b2 = b1 + e = 0 + 0 = 0 .
0
0
0
The third iteration is
a = hardlim (W 2 p 3 + b 2 ) = hardlim ( 0 1 2 + 0 ) = 1 ,
1 0 1
0
0
e = t3 a = 0 1 = 1 ,
1
0
1
4-31
W 3 = W 2 + ep 3 =
0 1 + 1
2 0 ,
2 1 =
1 0
1
1 1
b 3 = b 2 + e = 0 + 1 = 1 .
0
1
1
Iterations four through eight produce no changes in the weights.
W8 = W7 = W6 = W5 = W4 = W3
b8 = b7 = b6 = b 5 = b 4 = b3
The ninth iteration produces
a = hardlim (W 8 p 1 + b 8 ) = hardlim ( 2 0 1 + 1 ) = 0 ,
1 1 1
1
1
e = t1 a = 0 0 = 0 ,
0
1
1
T
W 9 = W 8 + ep 1 = 2 0 + 0 1 1 = 2 0 ,
1 1
1
0 2
b 9 = b 8 + e = 1 + 0 = 1 .
1
1
0
At this point the algorithm has converged, since all input patterns will be
correctly classified. The final decision boundaries are displayed in Figure
P4.7. Compare this result with the network we designed in Problem P4.3.
4-32
Solved Problems
2
4
4-33
Epilogue
In this chapter we have introduced our first learning rule the perceptron
learning rule. It is a type of learning called supervised learning, in which
the learning rule is provided with a set of examples of proper network behavior. As each input is applied to the network, the learning rule adjusts
the network parameters so that the network output will move closer to the
target.
The perceptron learning rule is very simple, but it is also quite powerful.
We have shown that the rule will always converge to a correct solution, if
such a solution exists. The weakness of the perceptron network lies not
with the learning rule, but with the structure of the network. The standard
perceptron is only able to classify vectors that are linearly separable. We
will see in Chapter 11 that the perceptron architecture can be generalized
to multilayer perceptrons, which can solve arbitrary classification problems. The backpropagation learning rule, which is introduced in Chapter
11, can be used to train these networks.
In Chapters 3 and 4 we have used many concepts from the field of linear
algebra, such as inner product, projection, distance (norm), etc. We will find
in later chapters that a good foundation in linear algebra is essential to our
understanding of all neural networks. In Chapters 5 and 6 we will review
some of the key concepts from linear algebra that will be most important in
our study of neural networks. Our objective will be to obtain a fundamental
understanding of how neural networks work.
4-34
Further Reading
Further Reading
[BaSu83]
A. Barto, R. Sutton and C. Anderson, Neuron-like adaptive elements can solve difficult learning control problems,
IEEE Transactions on Systems, Man and Cybernetics, Vol.
13, No. 5, pp. 834846, 1983.
A classic paper in which a reinforcement learning algorithm is used to train a neural network to balance an inverted pendulum.
[Brog91]
[McPi43]
[MiPa69]
[Rose58]
4-35
[Rose61]
[WhSo92]
D. White and D. Sofge (Eds.), Handbook of Intelligent Control, New York: Van Nostrand Reinhold, 1992.
Collection of articles describing current research and applications of neural networks and fuzzy logic to control systems.
4-36
Exercises
Exercises
E4.1 Consider the classification problem defined below:
1 t = 1 p = 0 t = 1 p = 1 t = 1 p = 1 t = 0
p1 =
2
3
4
1
2
3
4
1
0
1
0
0 t = 0.
p5 =
5
1
1 t = 1 p = 1 t = 1 p = 0 t = 0 p = 1 t = 0 .
p1 =
2
3
4
1
2
3
4
1
1
0
0
iii. Classify the following input vectors with your solution. You can either perform the calculations manually or with MATLAB.
p5 = 2
0
p6 = 1
1
p7 = 0
1
p8 = 1
2
iv. Which of the vectors in part (iii) will always be classified the same
way, regardless of the solution values for W and b ? Which may
vary depending on the solution? Why?
E4.3 Solve the classification problem in Exercise E4.2 by solving inequalities (as
in Problem P4.2), and repeat parts (ii) and (iii) with the new solution. (The
solution is more difficult than Problem P4.2, since you cant isolate the
weights and biases in a pairwise manner.)
4-37
E4.4 Solve the classification problem in Exercise E4.2 by applying the perceptron rule to the following initial parameters, and repeat parts (ii) and (iii)
with the new solution.
W0 = 0 0
b0 = 0
E4.5 Prove mathematically (not graphically) that the following problem is unsolvable for a two-input/single-neuron perceptron.
1 t = 1 p = 1 t = 0 p = 1 t = 1 p = 1 t = 0
p1 =
2
3
4
1
2
3
4
1
1
1
1
.
0
1
0
4-38
Exercises
Category II consists of
1 0 2
.
2
0
1
i. Design a single-neuron perceptron network to recognize these two
categories of vectors.
ii. Draw the network diagram.
iii. Sketch the decision boundary.
iv. If we add the following vector to Category I, will your network classify it correctly? Demonstrate by computing the network response.
3
0
v. Can your weight matrix and bias be modified so your network can
classify this new vector correctly (while continuing to classify the
other vectors correctly)? Explain.
E4.8 We want to train a perceptron network with the following training set:
1 t = 0 p = 0 t = 0 p = 1 t = 1 .
p1 =
2
3
1
2
3
1
0
1
4-39
E4.9 We want to train a perceptron network using the following training set:
1 t = 0 p = 1 t = 0 p = 1 t = 1 ,
p1 =
2
3
1
2
3
0
2
2
n = Wp + b
ii. Consider two single-neuron perceptrons with the same weight and
bias values. The first network uses the hard limit function ([0, 1]
values), and the second network uses the symmetric hard limit function. If the two networks are given the same input p , and updated
with the perceptron learning rule, will their weights continue to
have the same value?
iii. If the changes to the weights of the two neurons are different, how
do they differ? Why?
4-40
Exercises
iv. Given initial weight and bias values for a standard hard limit perceptron, create a method for initializing a symmetric hard limit perceptron so that the two neurons will always respond identically
when trained on identical data.
2+2
ans =
4
E4.11 The vectors in the ordered set defined below were obtained by measuring
the weight and ear lengths of toy rabbits and bears in the Fuzzy Wuzzy Animal Factory. The target values indicate whether the respective input vector was taken from a rabbit (0) or a bear (1). The first element of the input
vector is the weight of the toy, and the second element is the ear length.
1 t = 0 p = 1 t = 0 p = 2 t = 0 p = 2 t = 0
p1 =
2
3
4
1
2
3
4
4
5
4
5
3 t = 1 p = 3 t = 1 p = 4 t = 1 p = 4 t = 1
p5 =
6
7
8
5
6
7
8
1
2
1
2
i. Use MATLAB to initialize and train a network to solve this practical problem.
ii. Use MATLAB to test the resulting weight and bias values against
the input vectors.
iii. Add input vectors to the training set to ensure that the decision
boundary of any solution will not intersect one of the original input
vectors (i.e., to ensure only robust solutions are found). Then retrain
the network. Your method for adding the input vectors should be
general purpose (not designed specifically for this problem).
E4.12 Consider again the four-category classification problem described in Problems P4.3 and P4.5. Suppose that we change the input vector p 3 to
p3 = 2 .
2
i. Is the problem still linearly separable? Demonstrate your answer
graphically.
2+2
ans =
4
ii. Use MATLAB to initialize and train a network to solve this problem. Explain your results.
iii. If p 3 is changed to
p3 =
4-41
2
1.5
new
= W
new
old
+ ep
old
+ e
= b
4-42
Objectives
5-1
5-2
5-2
Linear Independence
5-4
Spanning a Space
5-5
Inner Product
5-6
Norm
5-7
Orthogonality
5-7
Gram-Schmidt Orthogonalization
Vector Expansions
5-8
5-9
5-10
Summary of Results
5-14
Solved Problems
5-17
Epilogue
5-26
Further Reading
5-27
Exercises
5-28
Objectives
It is clear from Chapters 3 and 4 that it is very useful to think of the inputs
and outputs of a neural network, and the rows of a weight matrix, as vectors. In this chapter we want to examine these vector spaces in detail and
to review those properties of vector spaces that are most helpful when analyzing neural networks. We will begin with general definitions and then
apply these definitions to specific neural network problems. The concepts
that are discussed in this chapter and in Chapter 6 will be used extensively
throughout the remaining chapters of this book. They are critical to our understanding of why neural networks work.
5-1
x = x1 x2 xn .
(5.1)
5-2
y X , then x + y X .
x X ( x is
2.
x+y = y+x.
3.
x + y + z =
x + y + z .
x + 0 = x for all x X .
x X there is a unique vector in X, to be called x , such
that x + x = 0 .
x2
9.
x1
x X , a b x = ab x .
a + b x = ax + bx .
10. a x + y = a x + a y .
To illustrate these conditions, lets investigate a few sample sets and determine whether or not they are vector spaces. First consider the standard
2
two-dimensional Euclidean space, , shown in the upper left figure. This
is clearly a vector space, and all ten conditions are satisfied for the standard definitions of vector addition and scalar multiplication.
x+y
x
What about subsets of ? What subsets of are also vector spaces (subspaces)? Consider the boxed area ( X ) in the center left figure. Does it satisfy all ten conditions? No. Clearly even condition 1 is not satisfied. The
vectors x and y shown in the figure are in X , but x + y is not. From this
example it is clear that no bounded sets can be vector spaces.
x2
x X , 1 x = x (for scalar 1 ).
x1
Are there any subsets of that are vector spaces? Consider the line ( X )
shown in the bottom left figure. (Assume that the line extends to infinity in
both directions.) Is this line a vector space? We leave it to you to show that
indeed all ten conditions are satisfied. Will any such infinite line satisfy the
ten conditions? Well, any line that passes through the origin will work. If
it does not pass through the origin then condition 4, for instance, would not
be satisfied.
In addition to the standard Euclidean spaces, there are other sets that also
satisfy the ten conditions of a vector space. Consider, for example, the set
2
P of all polynomials of degree less than or equal to 2. Two members of this
set would be
5-3
x = 2 + t + 4t 2
y = 1 + 5t .
(5.2)
f(t)
x = sin t
y = e 2t .
(5.3)
Linear Independence
Now that we have defined what we mean by a vector space, we will investigate some of the properties of vectors. The first properties are linear dependence and linear independence.
Consider n vectors x 1 x 2 x n . If there exist n scalars a 1 a 2 a n , at
least one of which is nonzero, such that
a1 x1 + a2 x2 + + an xn =
0,
(5.4)
5-4
Spanning a Space
Note that these definitions are equivalent to saying that if a set of vectors
is independent then no vector in the set can be written as a linear combination of the other vectors.
2
+2
(5.5)
Let a 1 p 1 + a 2 p 2 = 0 , then
a1 + a2
0
= 0 ,
0
a1 + a2
a1 + a2
(5.6)
2
+2
x 1 = 1 + t + t2 , x2 = 2 + 2t + t2 , x 3 = 1 + t .
(5.7)
0.
(5.8)
Spanning a Space
Next we want to define what we mean by the dimension (size) of a vector
space. To do so we must first define the concept of a spanning set.
Let X be a linear vector space and let u 1 u 2 u m be a subset of general
vectors in X. This subset spans X if and only if for every vector x X there
exist scalars x 1 x 2 x n such that x = x 1 u 1 + x 2 u 2 + + x m u m . In other
words, a subset spans a space if every vector in the space can be written as
a linear combination of the vectors in the subset.
Basis Set
u1 = 1 , u2 = t , u3 = t2 .
(5.9)
Clearly any polynomial of degree two or less can be created by taking a linear combination of these three vectors. Note, however, that any three independent vectors from P2 would form a basis for this space. One such
alternate basis is:
u1 = 1 , u2 = 1 + t , u3 = 1 + t + t2 .
(5.10)
Inner Product
From our brief encounter with neural networks in Chapters 3 and 4, it is
clear that the inner product is fundamental to the operation of many neural
networks. Here we will introduce a general definition for inner products
and then give several examples.
Inner Product
Any scalar function of x and y can be defined as an inner product, (x,y) , provided that the following properties are satisfied:
1.
(x,y) = (y,x) .
2.
3.
(5.11)
but this is not the only possible inner product. Consider again the set C[0, 1]
of all continuous functions defined on the interval [0, 1]. Show that the following scalar function is man inner product (see Problem P5.6).
1
(x,y) =
x t y t dt
0
5-6
(5.12)
Norm
Norm
The next operation we need to define is the norm, which is based on the concept of vector length.
Norm
A scalar function
1.
x 0.
2.
x = 0 if and only if x = 0 .
3.
ax = a
4.
x+y x + y .
x for scalar a.
There are many functions that would satisfy these conditions. One common
norm is based on the inner product:
x = (x,x)
12
(5.13)
For Euclidean spaces, , this yields the norm with which we are most familiar:
T
x = x x
12
x1 + x2 + + xn .
2
(5.14)
In neural network applications it is often useful to normalize the input vectors. This means that p i = 1 for each input vector.
Angle
Using the norm and the inner product we can generalize the concept of angle for vector spaces of dimension greater than two. The angle between
two vectors x and y is defined by
(x,y)
cos = --------------- .
x y
(5.15)
Orthogonality
Now that we have defined the inner product operation, we can introduce
the important concept of orthogonality.
Orthogonality
5-7
tor in X 1 . This is typically represented as x X 1 . A subspace X 1 is orthogonal to a subspace X 2 if every vector in X 1 is orthogonal to every vector in
X 2 . This is represented by X 1 X 2 .
p3
p2
p1
The figure to the left illustrates the two orthogonal spaces that were used
in the perceptron example of Chapter 3. (See Figure 3.4.) The p 1 p 3 plane
3
is a subspace of , which is orthogonal to the p 2 axis (which is another
3
subspace of ). The p 1 p 3 plane was the decision boundary of a perceptron network. In Solved Problem P5.1 we will show that the perceptron decision boundary will be a vector space whenever the bias value is zero.
Gram-Schmidt Orthogonalization
There is a relationship between orthogonality and independence. It is possible to convert a set of independent vectors into a set of orthogonal vectors
that spans the same vector space. The standard procedure to accomplish
this is called Gram-Schmidt orthogonalization.
Assume that we have n independent vectors y 1 y 2 y n . From these vectors we want to obtain n orthogonal vectors v 1 v 2 v n . The first orthogonal vector is chosen to be the first independent vector:
v1 = y1 .
(5.16)
To obtain the second orthogonal vector we use y 2 , but subtract off the portion of y 2 that is in the direction of v 1 . This leads to the equation
v2 = y2 a v1 ,
where a is chosen so that
(5.17)
(5.18)
(v 1,y 2)
a = ---------------.
(v 1,v 1)
(5.19)
or
Projection
(v i,y k)
v k = y k -------------- vi .
(v i,v i)
i=1
5-8
(5.20)
Vector Expansions
2
+2
y1 = 2 , y2 = 1 .
1
2
(5.21)
(5.22)
v2 = y2
T
v1 y2
---------- v1
T
v1 v1
1
2 1
2
= 1 --------------------- 2 = 1 1.6 = 0.6 .
1.2
2
2
0.8
2 1
2 1
1
(5.23)
y2
v2
y2
y1, v1
av1
We could convert v 1 and v 2 to a set of orthonormal (orthogonal and normalized) vectors by dividing each vector by its norm.
To experiment with this orthogonalization process, use the Neural Network
Design Demonstration Gram-Schmidt (nnd5gs).
Vector Expansions
Note that we have been using a script font ( x ) to represent general vectors
n
and bold type ( x ) to represent vectors in , which can be written as columns of numbers. In this section we will show that general vectors in finite
5-9
x X has a
x = xi vi = x1 v1 + x2 v2 + + xn vn .
(5.24)
i=1
Therefore any vector in a finite dimensional vector space can be represented by a column of numbers:
T
x = x1 x2 xn .
(5.25)
This x is a representation of the general vector x . Of course in order to interpret the meaning of x we need to know the basis set. If the basis set
changes, x will change, even though it still represents the same general
vector x . We will discuss this in more detail in the next subsection.
If the vectors in the basis set are orthogonal ( (v i,v j) = 0 , i j ) it is very
easy to compute the coefficients in the expansion. We simply take the inner
product of v j with both sides of Eq. (5.24):
n
(v j,x) = (v j, x i v i) =
x i (vj,vi)
= x j (v j,v j) .
(5.26)
i=1
i=1
(5.27)
When the vectors in the basis set are not orthogonal, the computation of the
coefficients in the vector expansion is more complex. This case is covered in
the following subsection.
ij
(5.28)
= 1
5-10
i = j,
Vector Expansions
where the basis vectors are v 1 v 2 v n and the reciprocal basis vectors
are r 1 r 2 r n .
If the vectors have been represented by columns of numbers (through vector expansion), and the standard inner product is used
T
(r i,v j) = r i v j ,
(5.29)
R B = I,
(5.30)
B = v1 v2 vn ,
(5.31)
R = r1 r2 rn .
(5.32)
where
R = B ,
(5.33)
and the reciprocal basis vectors can be obtained from the columns of R.
Now consider again the vector expansion
x = x1 v1 + x2 v2 + + xn vn .
(5.34)
Taking the inner product of r1 with both sides of Eq. (5.34) we obtain
(r 1,x) = x 1 (r 1,v 1) + x 2 (r 1,v 2) + + x n (r 1,v n) .
(5.35)
By definition
(r 1,v 2) = (r 1,v 3) = = (r 1,v n) = 0
(r 1,v 1) = 1 .
(5.36)
(5.37)
x j = (r j,x) .
(5.38)
and in general
5-11
2
+2
s
s
v1 = 2 , v2 = 1 .
1
2
(5.39)
v2
s2
v1
s1
(5.40)
in terms of the two basis vectors. (We are using the superscript s to indicate that these columns of numbers represent expansions of the vectors in
2
terms of the standard basis in . The elements of the standard basis are
indicated in the adjacent figure as the vectors s 1 and s 2 . We need to use
this explicit notation in this example because we will be expanding the vectors in terms of two different basis sets.)
The first step in the vector expansion is to find the reciprocal basis vectors.
R = 2 1
1 2
T
2
--3
=
1
--3
1
--3
2
--3
2
--3
r1 =
1
--3
1
--3 .
r2 =
2
--3
(5.41)
(5.42)
T s
So that
5-12
1 s
1
--3
2
--3
0
1
--2 .
3 =
--1
2
(5.43)
Vector Expansions
x = 1--- v 1 + 1 v 2 ,
(5.44)
v2
x
v1
v2
- v1/2
Figure 5.2 Vector Expansion
Note that we now have two different vector expansions for
s
v
by x and x . In other words,
x = 0 s 1 + 3--- s 2 = 1--- v 1 + 1 v 2 .
2
x , represented
(5.45)
5-13
Summary of Results
Linear Vector Spaces
Definition. A linear vector space, X, is a set of elements (vectors) defined
over a scalar field, F, that satisfies the following conditions:
1. An operation called vector addition is defined such that if
x X and
y X , then x + y X .
2.
x+y = y+x.
3.
x + y + z =
x + y + z .
x + 0 = x for all x X .
x X there is a unique vector in X, to be called x , such
that x + x = 0 .
x X , 1 x = x (for scalar 1 ).
x X , a b x = ab x .
a + b x = ax + bx .
10. a x + y = a x + a y .
Linear Independence
Consider n vectors x 1 x 2 x n . If there exist n scalars a 1 a 2 a n , at
least one of which is nonzero, such that
a1 x1 + a2 x2 + + an xn =
then the x i are linearly dependent.
5-14
0,
Summary of Results
Spanning a Space
Let X be a linear vector space and let u 1 u 2 u m be a subset of vectors
in X. This subset spans X if and only if for every vector x X there exist
scalars x 1 x 2 x n such that x = x 1 u 1 + x 2 u 2 + + x m u m .
Inner Product
Any scalar function of x and y can be defined as an inner product, (x,y), provided that the following properties are satisfied.
1.
(x,y) = (y,x) .
2.
3.
Norm
A scalar function
1.
x 0.
2.
x = 0 if and only if x = 0 .
3.
ax = a
4.
x+y x + y .
x for scalar a.
Angle
The angle between two vectors
x and y is defined by
(x,y)
cos = --------------- .
x y
Orthogonality
Two vectors x y X are said to be orthogonal if (x,y) = 0 .
Gram-Schmidt Orthogonalization
Assume that we have n independent vectors y 1 y 2 y n . From these vectors we will obtain n orthogonal vectors v 1 v 2 v n .
v1 = y1
5-15
k1
(v i,y k)
v k = yk -------------- vi ,
( v i ,v i )
i=1
where
(v i,y k)
--------------- v i
(v i,v i)
is the projection of
y k on v i .
Vector Expansions
n
x = xi vi = x1 v1 + x2 v2 + + xn vn .
i=1
ij
= 1
i = j
x j = (r j,x) .
To compute the reciprocal basis vectors:
B = v1 v2 vn ,
R = r1 r2 rn ,
T
R = B .
In matrix form:
v
1 s
x = B x .
5-16
Solved Problems
Solved Problems
P5.1 Consider the single-neuron perceptron network shown in Figure
P5.1. Recall from Chapter 3 (see Eq. (3.6)) that the decision boundary for this network is given by Wp + b = 0 . Show that the decision
boundary is a vector space if b = 0 .
Inputs
Sym. Hard
- Title
Limit
- Layer
p
Rx1
1xR
1x1
b
1x1
1x1
- Exp (Wp
- + b)
a = hardlims
Figure P5.1 Single-Neuron Perceptron
To be a vector space the boundary must satisfy the ten conditions given at
the beginning of this chapter. Condition 1 requires that when we add two
vectors together the sum remains in the vector space. Let p 1 and p 2 be two
vectors on the decision boundary. To be on the boundary they must satisfy
Wp 1 = 0
Wp 2 = 0 .
5-17
i.
1
1
1
ii. sin t
iii.
1
1
1
1
1
0
1
cos t
1
0
1
1
1
2
1
2 cos t + ---
4
1
2
1
1
i. We can solve this problem several ways. First, lets assume that the
vectors are dependent. Then we can write
1
1
1
0
a1 1 + a2 0 + a3 2 = 0 .
1
1
1
0
5-18
Solved Problems
If we can solve for the coefficients and they are not all zero, then the vectors
are dependent. By inspection we can see that if we let a 1 = 2 , a 2 = 1 and
a 3 = 1 , then the equation is satisfied. Therefore the vectors are dependent.
n
= 1 0 2 + 1 1 1 + 1 1 1
1 1
1 1
0 2
= 2+0+2 = 0
1
1
cos t + --- = ------- sin t + ------- cos t .
4
2
2
Therefore the vectors are dependent. The dimension of the space spanned
by the vectors is two, since no linear combination of sin t and cos t is identically zero.
iii. This is similar to part (i), except that the number of vectors is less than
4
the size of the vector space they are drawn from (three vectors in ). In
this case the matrix made up of the vectors will not be square, so we will
not be able to compute a determinant. However, we can use something
called the Gramian [Brog91]. It is the determinant of a matrix whose i, j
element is the inner product of vector i and vector j. The vectors are dependent if and only if the Gramian is zero.
5-19
where
1
x1 = 1
1
1
1
x2 = 0
1
1
1
x3 = 2 .
1
1
Therefore
G =
4 3 5
3 3 3
5 3 7
= 4 3 3 + 3 3 5 + 5 3 5
3 7
37
3 3
= 48 18 30 = 0 .
1
0 1
1
1
1
0
2 = 0 .
1
0
1
0
The dimension of the space must therefore be less than 3. We can show that
x 1 and x 2 are independent, since
G =
4 3
3 3
= 40.
5-20
Solved Problems
Wp + b = 0
p 1 = 0.5
0.5
p2
p1
p 2 = 1.5 .
1.5
w11
SxR
p2
w12
1
- Exp -(Wp + b)
a = hardlims
Figure P5.2 Two-Input Perceptron
P5.5 Using the following basis vectors, find an orthogonal set using
Gram-Schmidt orthogonalization.
1
y1 = 1
1
1
y2 = 0
0
Step 1.
1
v1 = y1 = 1
1
5-21
0
y3 = 1
0
Step 2.
1
1 1 1 0
T
1
1
13
23
0 1
v1 y2
v 2 = y 2 ---------v
------------------------=
=
=
0
1
0
1
13
1
T
v1 v1
1
0
1
0
13
1 3
1 1 1 1
1
Step 3.
T
v1 y3
v2 y3
v 3 = y 3 ---------- v 1 ---------- v2
T
T
v1 v1
v2 v2
0
0
1 1 1 1
2 3 1 3 1 3 1
0
23
0 1
0
v 3 = 1 -------------------------- 1 ---------------------------------------------------------------- 1 3
1 1
2 3 1 3
0
1 1 1 1
2 3 1 3 1 3 1 3
1
1 3
0
13
1 3
0
v3 = 1 1 3 1 6 = 1 2
0
13
16
1 2
P5.6 Consider the vector space of all polynomials defined on the inter1
x(t) y t dt
(x,y) = (y,x)
1
(x,y) =
x(t) y t dt
1
2.
5-22
y t x(t)dt
1
= (y,x)
Solved Problems
(x,a y 1 + b y 2) =
= a (x,y 1) + b (x,y 2)
3.
(x,x) =
2
x t x t dt = x (t) dt 0
1
Equality holds here only if x(t) = 0 for 1 t 1 , which is the zero vector.
P5.7 Two vectors from the vector space described in the previous problem (polynomials defined on the interval [-1, 1]) are 1 + t and 1 t .
Find an orthogonal set of vectors based on these two vectors.
Step 1.
v1 = y1 = 1 + t
Step 2.
(v 1,y 2)
- v1
v 2 = y 2 --------------(v 1,v 1)
where
1
(v 1,y 2) =
t
1 + t 1 t dt = t ---3
1
1
(v 1,v 1) =
3 1
1 + t
2
1 + t dt = ----------------3
1
2
2
4
= --- --- = -- 3 3
3
8
8
= --- 0 = --- .
3
3
Therefore
3
1 3
- 1 + t = --- --- t .
v2 = 1 t 4--------83
5-23
P5.8 Expand x = 6 9 9
1
v1 = 1
1
1
v2 = 2
3
1
v3 = 3
2
1 1 1
B = 1 2 3
1 3 2
5
--3
= 1
--3
1
--3
1
--3
1
--3
2
--3
1
--3
2
--3
1
--3
1 3
r2 = 1 3
23
r3 =
5-24
1 3
23 .
1 3
Solved Problems
1
1
1
v
v
v
x = x1 v1 + x2 v2 + x3 v3 = 4 1 + 1 2 + 1 3 .
1
3
2
We can represent the process in matrix form:
5
--3
v
1
x = B x = 1
--3
1
--3
1
--3
1
--3
2
--3
1
--3
6
4
2
--- 9 = 1 .
3
9
1
1
--3
Recall that both x and x are representations of the same vector, but are
expanded in terms of different basis sets. (It is assumed that x uses the
standard basis set, unless otherwise indicated.)
5-25
Epilogue
This chapter has presented a few of the basic concepts of vector spaces, material that is critical to the understanding of how neural networks work.
This subject of vector spaces is very large, and we have made no attempt to
cover all its aspects. Instead, we have presented those concepts that we feel
are most relevant to neural networks. The topics covered here will be revisited in almost every chapter that follows.
The next chapter will continue our investigation of the topics of linear algebra most relevant to neural networks. There we will concentrate on linear transformations and matrices.
5-26
Further Reading
Further Reading
[Brog91]
[Stra76]
5-27
Exercises
E5.1 Consider again the perceptron described in Problem P5.1. If b 0 , show
that the decision boundary is not a vector space.
E5.2 What is the dimension of the vector space described in Problem P5.1?
E5.3 Consider the set of all continuous functions that satisfy the condition
f 0 = 0 . Show that this is a vector space.
E5.4 Show that the set of 2 2 matrices is a vector space.
E5.5 Consider a perceptron network, with the following weights and bias.
W = 1 0 1 , b = 0 .
i. Write out the equation for the decision boundary.
ii. Show that the decision boundary is a vector space. (Demonstrate
that the 10 criteria are satisfied for any point on the boundary.)
iii. What is the dimension of the vector space?
iv. Find a basis set for the vector space.
E5.6 The three parts to this question refer to subsets of the set of real-valued
continuous functions defined on the interval [0,1]. Tell which of these subsets are vector spaces. If the subset is not a vector space, identify which of
the 10 criteria are not satisfied.
i. All functions such that f 0.5 = 2 .
ii. All functions such that f 0.75 = 0 .
iii. All functions such that f 0.5 = f 0.75 3 .
E5.7 The next three questions refer to subsets of the set of real polynomials de2
fined over the real line (e.g., 3 + 2t + 6t ). Tell which of these subsets are
vector spaces. If the subset is not a vector space, identify which of the 10
criteria are not satisfied.
i. Polynomials of degree 5 or less.
ii. Polynomials that are positive for positive t.
iii. Polynomials that go to zero as t goes to zero.
5-28
Exercises
2+2
ans =
4
E5.8 Which of the following sets of vectors are independent? Find the dimension
of the vector space spanned by each set. (Verify your answers to parts (i)
and (iv) using the MATLAB function rank.)
i.
1
2
3
1
0
1
1
2
1
ii. sin t
cos t
iii. 1 + t
1t
iv.
1
2
2
1
1
0
0
1
cos 2t
3
4
4
3
E5.9 Recall the apple and orange pattern recognition problem of Chapter 3. Find
the angles between each of the prototype patterns (orange and apple) and
the test input pattern (oblong orange). Verify that the angles make intuitive sense.
1
p 1 = 1 orange
1
p2 =
1
1 apple
1
1
p = 1
1
E5.10 Using the following basis vectors, find an orthogonal set using GramSchmidt orthogonalization. (Check your answer using MATLAB.)
2+2
ans =
4
1
y1 = 0
0
1
y2 = 1
0
1
y3 = 1
1
E5.11 Consider the vector space of all piecewise continuous functions on the interval [0, 1]. The set f 1 f 2 f 3 , which is defined in Figure E15.1, contains
three vectors from this vector space.
i. Show that this set is linearly independent.
ii. Generate an orthogonal set using the Gram-Schmidt procedure. The
inner product is defined to be
5-29
(f,g) =
f t g t dt .
0
f1(t)
f2(t)
f3(t)
1
1
-1
-1
-1
f2(t)
f1(t)
1
2
1
-1
-1
-
(f,g) =
f t g t dt .
0
5-30
Exercises
g (t)
3
h (t)
2
1
-1
-2
-3
ii. Expand the vectors g and h in Figure E15.3 in terms of the orthogonal set you created in Part 1. Explain any problems you find.
E5.13 Consider the set of polynomials of degree 1 or less. This is a linear vector
space. One basis set for this space is
{u 1 = 1, u 2 = t }
Using this basis set, the polynomial y = 2 + 4t can be represented as
u
y = 2
4
x = 1 v1 + 1 v2
The vectors
as
5-31
y = 1 s1 + 1 s2 .
Find the expansion of y in terms of the basis vectors {v 1, v 2} .
E5.15 Consider the vector space of all continuous functions on the interval [0,1].
The set f 1 f 2 , which is defined in the figure below, contains two vectors
from this vector space.
f1 t = 1
f2 t = 1 t
0t1
0t1
(f,g) =
f t g t dt .
0
ii. Expand the following vector h in terms of the orthogonal set you
created in part i., using Eq. (5.27). Demonstrate that the expansion
is correct by reproducing h as a combination of g 1 and g 2 .
h t = t 1
0t1
t
1
-1
Figure E15.5 Vector
E5.16 Consider the set of all complex numbers. This can be considered a vector
space, because it satisfies the ten defining properties. We can also define
5-32
Exercises
s2
u1
s1
u2
Figure E15.6 Vector Definitions for Exercise E5.17
i. Write the expansion for
5-33
x in terms of
iv. Draw sketches, similar to Figure 5.2, that demonstrate that the expansions of part i. and part iii. are equivalent.
E5.18 Consider the set of all functions that can be written in the form A sin t + .
This set can be considered a vector space, because it satisfies the ten defining properties.
i. Consider the following basis set for the vector space described
above: v 1 = sin t , v 2 = cos t . Represent the vector
x = 2 sin t + 4 cos t as a column of numbers x v (find the vector expansion), using this basis set.
ii. Using your basis set from part i., find vector expansions for
u1 = 2 sin t + cos t , u 2 = 3 sin t .
iii. We now want to represent the vector x of part i., using the basis set
u 1 u 2 . Use reciprocal basis vectors to find the expansion for x in
terms of the basis vectors u 1 u 2 . This will allow you to write x as
u
a new column of numbers x .
iv. Show that the representations for x that you found in parts i. and
v
u
iii. are equivalent (the two columns of numbers x and x both represent the same vector x ).
E5.19 Suppose that we have three vectors: x y z X . We want to add some multiple of y to x, so that the resulting vector is orthogonal to z.
i. How would you determine the appropriate multiple of y to add to x?
ii. Verify your results in part i. using the following vectors.
x = 1
0
y =
1
0.5
z = 0.5
1
E5.20 Expand x = 1 2 2 in terms of the following basis set. (Verify your answer using MATLAB.)
2+2
ans =
4
v1 =
1
1
0
5-34
v2 =
1
1
2
1
v3 = 1
0
Exercises
12
x ay + ay
x .
5-35
Objectives
6-1
6-2
Linear Transformations
6-2
Matrix Representations
6-3
Change of Basis
6-6
6-10
Diagonalization
6-13
Summary of Results
6-15
Solved Problems
6-17
Epilogue
6-29
Further Reading
6-30
Exercises
6-31
Objectives
This chapter will continue the work of Chapter 5 in laying out the mathematical foundations for our analysis of neural networks. In Chapter 5 we
reviewed vector spaces; in this chapter we investigate linear transformations as they apply to neural networks.
As we have seen in previous chapters, the multiplication of an input vector
by a weight matrix is one of the key operations that is performed by neural
networks. This operation is an example of a linear transformation. We
want to investigate general linear transformations and determine their
fundamental characteristics. The concepts covered in this chapter, such as
eigenvalues, eigenvectors and change of basis, will be critical to our understanding of such key neural network topics as performance learning (including the Widrow-Hoff rule and backpropagation) and Hopfield network
convergence.
6-1
(6.1)
Notice that at each iteration the output of the network is again multiplied
by the weight matrix W. What is the effect of this repeated operation? Can
we determine whether or not the output of the network will converge to
some steady state value, go to infinity, or oscillate? In this chapter we will
lay the foundation for answering these questions, along with many other
questions about neural networks discussed in this book.
Initial
Condition
Recurrent Layer
Sx1
SxS
n(t + 1)
a(t + 1)
Sx1
Sx1
b
Sx1
a(0) = p
S
a(t + 1) = satlins (Wa(t) + b)
Linear Transformations
We begin with some general definitions.
Transformation
x i X to an element y i Y .
6-2
a(t)
Sx1
Matrix Representations
Linear Transformation
A(x )
x 1 x 2 X , A x 1 + x2 = A x1 + A x2 ,
2. for all
x X , a R , A ax = aA x .
Matrix Representations
x 1+x 2
x2
x1
A(x 1 + x 2)
A(x 1)
x = x i v i and y = y i u i .
i=1
A(x 2)
i=1
Ax = y
(6.3)
can be written
A(ax )
= aA(x )
A(x )
(6.2)
ax
A x j v j = y i u i .
j=1
(6.4)
i=1
xj A vj
j=1
6-3
yi ui .
i=1
(6.5)
A v j = a ij u i .
(6.6)
i=1
(Note that the notation used for the coefficients of this expansion, a ij , was
not chosen by accident.) If we substitute Eq. (6.6) into Eq. (6.5) we obtain
n
xj a ij u i
j=1
yi ui .
i=1
(6.7)
i=1
ui a ij xj = yi u i .
i=1
(6.8)
i=1
j=1
i=1
u i a ij x j y i =
0.
(6.9)
j=1
Recall that since the u i form a basis set they must be independent. This
means that each coefficient that multiplies u i in Eq. (6.9) must be identically zero (see Eq. (5.4)), therefore
n
aij x j
= yi .
(6.10)
j=1
a m1 a m2 a mn x n
y2
(6.11)
a 21 a 22 a 2n x 2
y1
ym
6-4
Matrix Representations
Keep in mind that the matrix representation is not unique (just as the representation of a general vector by a column of numbers is not unique see
Chapter 5). If we change the basis set for the domain or for the range, the
matrix representation will also change. We will use this fact to our advantage in later chapters.
2
+2
As an example of a matrix representation, consider the rotation transformation. Lets find a matrix representation for that transformation. The key
step is given in Eq. (6.6). We must transform each basis vector for the domain and then expand it in terms of the basis vectors of the range. In this
2
example the domain and the range are the same ( X = Y = ), so to keep
things simple we will use the standard basis for both ( u i = v i = s i ), as
shown in the adjacent figure.
A(x)
s2
The first step is to transform the first basis vector and expand the resulting
transformed vector in terms of the basis vectors. If we rotate s 1 counterclockwise by the angle we obtain
2
s1
A s 1 = cos s 1 + sin s 2 = a i1 s i = a 11 s 1 + a 21 s 2 ,
(6.12)
i=1
as can be seen in the middle left figure. The two coefficients in this expansion make up the first column of the matrix representation.
cos()
A(s1)
sin()
cos()
-sin()
s 2 coun-
A s2 = sin s 1 + cos s 2 = a i2 s i = a 12 s 1 + a 22 s 2 ,
s1
A(s2)
(6.13)
i=1
s2
as can be seen in the lower left figure. From this expansion we obtain the
second column of the matrix representation. The complete matrix representation is thus given by
A =
cos sin .
sin cos
(6.14)
Verify for yourself that when you multiply a vector by the matrix of Eq.
(6.14), the vector is rotated by an angle .
In summary, to obtain the matrix representation of a transformation we
use Eq. (6.6). We transform each basis vector for the domain and expand it
in terms of the basis vectors of the range. The coefficients of each expansion
produce one column of the matrix.
6-5
Change of Basis
We notice from the previous section that the matrix representation of a linear transformation is not unique. The representation will depend on what
basis sets are used for the domain and the range of the transformation. In
this section we will illustrate exactly how a matrix representation changes
as the basis sets are changed.
Consider a linear transformation A :X Y . Let v 1 v 2 v n be a basis
for vector space X , and let u 1 u 2 u m be a basis for vector space Y.
Therefore, any vector x X can be written
n
x = xi vi ,
(6.15)
i=1
y Y can be written
m
y = yi ui .
(6.16)
i=1
So if
Ax = y
(6.17)
y2
ym
a m1 a m2 a mn x n
a 21 a 22 a 2n x 2
y1
(6.18)
or
Ax = y .
(6.19)
Now suppose that we use different basis sets for X and Y . Let
t 1 t 2 t n be the new basis for X , and let w 1 w 2 w m be the new
basis for Y . With the new basis sets, the vector x X is written
6-6
Change of Basis
x = x' i t i ,
(6.20)
i=1
y Y is written
m
y = y' i w i .
(6.21)
i=1
y' 1
y' m
y' 2
(6.22)
or
A'x' = y' .
(6.23)
What is the relationship between A and A' ? To find out, we need to find
the relationship between the two basis sets. First, since each t i is an element of X , they can be expanded in terms of the original basis for X :
n
t i = t ji v j .
(6.24)
j=1
w i = w ji u j .
(6.25)
j=1
t 2i
ti =
w 1i
wi =
t ni
Define a matrix whose columns are the ti:
6-7
w 2i .
t 1i
w mi
(6.26)
Bt = t1 t2 tn .
(6.27)
(6.28)
(6.29)
(6.30)
which then demonstrates the relationships between the two different representations for the vector y.
Now substitute Eq. (6.28) and Eq. (6.30) into Eq. (6.19):
AB t x' = B w y' .
(6.31)
1
B w AB t x' = y' .
Change of Basis
A comparison of Eq. (6.32) and Eq. (6.23) yields the following operation for
a change of basis:
1
A' = B w AB t .
Similarity Transform
2
+2
(6.32)
(6.33)
This key result, which describes the relationship between any two matrix
representations of a given linear transformation, is called a similarity
transform [Brog91]. It will be of great use to us in later chapters. It turns
out that with the right choice of basis vectors we can obtain a matrix representation that reveals the key characteristics of the linear transformation it represents. This will be discussed in the next section.
As an example of changing basis sets, lets revisit the vector rotation example of the previous section. In that section a matrix representation was developed using the standard basis set {s1, s2} . Now lets find a new
representation using the basis {t1, t2} , which is shown in the adjacent fig-
6-8
Change of Basis
ure. (Note that in this example the same basis set is used for both the domain and the range.)
t2
The first step is to expand t 1 and t 2 in terms of the standard basis set, as
in Eq. (6.24) and Eq. (6.25). By inspection of the adjacent figure we find:
s2
t1
t 1 = s 1 + 0.5 s 2 ,
(6.34)
t2 = s1 + s2 .
(6.35)
1
0.5
t2 = 1 .
1
(6.36)
Bt = t1 t2 =
1 1 ,
0.5 1
(6.37)
s1
Therefore we can write
t1 =
Now we can form the matrix
and, because we are using the same basis set for both the domain and the
range of the transformation,
Bw
= Bt = 1 1 .
0.5 1
(6.38)
We can now compute the new matrix representation from Eq. (6.33):
1
A' = B w AB t =
2 3 2 3 cos sin 1 1
1 3 2 3 sin cos 0.5 1
1 3 sin + cos
4 3 sin
.
5
--- sin
1 3 sin + cos
6
(6.39)
6-9
(6.40)
A = 0.866 0.5 .
0.5 0.866
(6.41)
To check that these matrices are correct, lets try a test vector
x =
(6.42)
(Note that the vector represented by x and x' is t 1 , a member of the second
basis set.) The transformed test vector would be
y = Ax = 0.866 0.5 1 = 0.616 ,
0.5 0.866 0.5
0.933
(6.43)
t2
s2
y = A( x )
t1 = x
s1
(6.44)
How can we test to see if y' does correspond to y ? Both should be representations of the same vector, y , in terms of two different basis sets; y uses
the basis {s1, s2} and y' uses the basis {t1, t2} . In Chapter 5 we used the reciprocal basis vectors to transform from one representation to another (see
Eq. (5.43)). Using that concept we have
y' = B 1 y =
1 1
0.5 1
which verifies our previous result. The vectors are displayed in the figure
to the left. Verify graphically that the two representations, y and y' , given
by Eq. (6.43) and Eq. (6.44), are reasonable.
Az = z
(6.46)
s2
A(x)
x
s1
(6.47)
A I z = 0 .
(6.48)
or
This means that the columns of A I are dependent, and therefore the
determinant of this matrix must be zero:
A I = 0 .
(6.49)
As an example, lets revisit the rotation example. If we use the standard basis set, the matrix of the transformation is
A =
cos sin .
sin cos
(6.50)
= 0,
(6.51)
or
2
6-11
(6.52)
2 = cos j sin .
(6.53)
(6.54)
= 0,
(6.55)
or
2
+ 3 + 2 = + 1 + 2 = 0 ,
(6.56)
2 = 2 .
(6.57)
To find the eigenvectors we must solve Eq. (6.48), which in this example becomes
1
1
z = 0 .
0
2
0
(6.58)
We will solve this equation twice, once using 1 and once using 2 . Beginning with 1 we have
0 1 z = 0 1 z 11 = 0
1
0 1
0 1 z 21
0
(6.59)
z 21 = 0 , no constraint on z 11 .
(6.60)
or
6-12
z1 = 1 ,
0
(6.61)
(6.62)
z 22 = z 12 .
(6.63)
or
1 ,
1
(6.64)
(6.65)
Az 2 = 1 1 1 = 2 = 2 1 = 2 z 2 .
0 2 1
2
1
(6.66)
Diagonalization
Whenever we have n distinct eigenvalues we are guaranteed that we can
find n independent eigenvectors [Brog91]. Therefore the eigenvectors
make up a basis set for the vector space of the transformation. Lets find
the matrix of the previous transformation (Eq. (6.54)) using the eigenvectors as the basis vectors. From Eq. (6.33) we have
1
A' = B AB = 1 1 1 1 1 1 = 1 0 .
0 1 0 2 0 1
0 2
(6.67)
Note that this is a diagonal matrix, with the eigenvalues on the diagonal.
This is not a coincidence. Whenever we have distinct eigenvalues we can
diagonalize the matrix representation by using the eigenvectors as the ba-
6-13
(6.68)
B AB =
Diagonalization
0 0 n
(6.69)
6-14
Summary of Results
Summary of Results
Transformations
A transformation consists of three parts:
1. a set of elements X = x i , called the domain,
2. a set of elements Y = y i , called the range, and
3. a rule relating each
x i X to an element y i Y .
Linear Transformations
A transformation
A is linear if:
1. for all
x 1 x 2 X , A x 1 + x2 = A x1 + A x2 ,
2. for all
x X , a R , A ax = aA x .
Matrix Representations
Let v 1 v 2 v n be a basis for vector space X , and let u 1 u 2 u m be
a basis for vector space Y . Let A be a linear transformation with domain
X and range Y :
Ax = y .
The coefficients of the matrix representation are obtained from
m
A v j = aij u i .
i=1
Change of Basis
Bt = t1 t2 tn
Bw = w1 w2 wm
1
A' = B w AB t
6-15
Diagonalization
B = z1 z2 zn ,
where {z 1 z 2 , z n} are the eigenvectors of a square matrix A .
1 0 0
0 2 0
B AB =
0 0 n
6-16
Solved Problems
Solved Problems
P6.1 Consider the single-layer network shown in Figure P6.1, which has
a linear transfer function. Is the transformation from the input
vector to the output vector a linear transformation?
Inputs
p
Rx1
1
R
Linear
- Title
Layer
-
W
SxR
Sx1
Sx1
b
Sx1
a = purelin (Wp + b)
Figure P6.1 Single-Neuron Perceptron
The network equation is
a =
A p = Wp + b .
A p1 + p2 = A p1 + A p2 ,
2.
A ap = a A p .
A p 1 + p 2 = W p 1 + p 2 + b = Wp 1 + Wp 2 + b .
Compare this with
A p 1 + A p 2 = Wp1 + b + Wp 2 + b = Wp 1 + Wp 2 + 2b .
Clearly these two expressions will be equal only if b = 0 . Therefore this
network performs a nonlinear transformation, even though it has a linear
transfer function. This particular type of nonlinearity is called an affine
transformation.
6-17
x with v .
A x 1 + A x2 .
s2
x
s1
A(x)
Figure P6.2 Reflection Transformation
The key to finding the matrix of a transformation is given in Eq. (6.6):
6-18
Solved Problems
A v j = aij u i .
i=1
s1
We need to transform each basis vector of the domain and then expand the
result in terms of the basis vectors for the range. Each time we do the expansion we get one column of the matrix representation. In this case the
basis set for both the domain and the range is {s 1, s 2} . So lets transform s 1
first. If we reflect s 1 about the line x 1 + x 2 = 0 , we find
2
A(s1) = -s2
A s 1 = s 2 = ai1 s i = a 11 s 1 + a21 s 2 = 0 s 1 + 1 s 2
i=1
(as shown in the top left figure), which gives us the first column of the matrix. Next we transform s 2 :
s2
A s 2 = s 1 = a i2 s i = a 12 s 1 + a 22 s 2 = 1 s 1 + 0 s 2
i=1
A(s2) = -s1
(as shown in the second figure on the left), which gives us the second column of the matrix. The final result is
0 1 .
1 0
T
0 1 1 = 1 .
1 0 1
1
6-19
s2
s1
A(x )
A v1 = A 1 + j = 1 j = v 2 = a 11 v 1 + a 21 v 2 = 0 v 1 + 1 v2 ,
A v 2 = A 1 j = 1 + j = v 1 = a 12 v 1 + a 22 v 2 = 1 v 1 + 0 v2 .
This gives us the matrix representation
A = 0 1 .
1 0
ii. To find the eigenvalues, we need to use Eq. (6.49):
6-20
Solved Problems
1
1
A I =
= 1 = 1 + 1 = 0 .
1 ,
1
z1 = 1 v1 + 1 v2 = 1 + j + 1 j = 2 ,
6-21
z 2 = 1 v 1 + 1 v 2 = 1 + j 1 j = 2j .
Checking that these are indeed eigenvectors:
A z 1 = 2 = 2 = 1 z 1 ,
A z 2 = 2j = 2j = 2 z 2 .
iii. To perform a change of basis we need to use Eq. (6.33):
1
A' = B w AB t = B AB ,
where
B = z1 z2 = 1 1 .
1 1
(We are using the same basis set for the range and the domain.) Therefore
we have
1 0
.
A' = 0.5 0.5 0 1 1 1 = 1 0 =
0 2
0.5 0.5 1 0 1 1
0 1
As expected from Eq. (6.69), we have diagonalized the matrix representation.
P6.5 Diagonalize the following matrix:
A =
2 2 .
1 3
2 2
1 3
= 5 + 4 = 1 4 = 0 ,
6-22
Solved Problems
1 2 z = 1 2 z 11 = 0 ,
1
1 2
1 2 z 21
0
or
z 11 = 2z 21 .
Therefore the first eigenvector will be
z1 = 2 ,
1
or any scalar multiple.
For = 2 = 4
2 2 z = 2 2 z 12 = 0 ,
1
1 1
1 1 z 22
0
or
z 12 = z 22 .
Therefore the second eigenvector will be
z2 =
1 ,
1
A' = B AB ,
where
B = z1 z2 = 2 1 .
1 1
Therefore we have
6-23
1
--A' = 3
1
--3
1
--3 2 2 2 1 = 1 0 = 1 0 .
2 1 3 1 1
0 4
0 2
--3
3
T = 0 1 2
0
3
1
W = 1 0 .
0 2
Bw = 1 0 .
0 2
A' = B w AB t ,
A' =
2 0 0
1 0
6 1 2
3 1 0
0 1 2 =
1
1
3 .
0 --- 0 0 1
--- 0 --2
2
2
1 0 3
Therefore this is the matrix of the transformation with respect to the basis
sets T and W .
P6.7 Consider a transformation
as V = v 1 v 2 .
6-24
Solved Problems
A v1 = v1 + 2 v2 ,
A v2 = v1 + v2 .
ii. Consider a new basis set W = w 1 w 2 . Find the matrix of
the transformation A relative to the basis set W if it is given
that
w1 = v1 + v2 ,
w2 = v1 v2 .
i. Each of the two equations gives us one column of the matrix, as defined
in Eq. (6.6). Therefore the matrix is
A = 1 1 .
2 1
ii. We can represent the W basis vectors as columns of numbers in terms
of the V basis vectors:
w1 = 1
1
w2 =
1 .
1
We can now form the basis matrix that we need to perform the similarity
transform:
Bw = 1 1 .
1 1
The new matrix representation can then be obtained from Eq. (6.33):
1
A' = B w AB w ,
1
--A' = 2
1
--2
6-25
1
5
----2 1 1 1 1 = 2
1
1 2 1 1 1
-- --2
2
1
--2 .
1
--2
P6.8 Consider the vector space P of all polynomials of degree less than
2
or equal to 2. One basis for this vector space is V = 1 t t . Consider the differentiation transformation D .
i. Find the matrix of this transformation relative to the basis
set V .
ii. Find the eigenvalues and eigenvectors of the transformation.
i.
D 1 = 0 = 0 1 + 0 t + 0 t 2 ,
D t = 1 = 1 1 + 0 t + 0 t 2 ,
D t2 = 2t = 0 1 + 2 t + 0 t 2 .
The matrix of the transformation is then given by
0 1 0
D = 0 0 2 .
0 0 0
ii. To find the eigenvalues we must solve
D I =
1 0
0 2
0 0
= = 0 .
Therefore all three eigenvalues are zero. To find the eigenvectors we need
to solve
D I z =
1 0
0
z
=
0 2
0 .
0 0
0
For = 0 we have
0 1 0 z1
0
=
0 0 2 z2
0 .
0 0 0 z3
0
6-26
Solved Problems
P6.9 Consider a transformation A :R R . Two examples of transformed vectors are given in Figure P6.4. Find the matrix representation of this transformation relative to the standard basis set.
x1
x2
s2
A(x 1)
A(x 2)
s1
So that
A = 1 2 2 1
0 1 2 1
= 1 2
0 1
1
--4
1
--2
3 5
1
--- ----4 = 4 4 .
1 1
1
----- --2 2
2
6-28
Epilogue
Epilogue
In this chapter we have reviewed those properties of linear transformations and matrices that are most important to our study of neural networks. The concepts of eigenvalues, eigenvectors, change of basis
(similarity transformation) and diagonalization will be used again and
again throughout the remainder of this text. Without this linear algebra
background our study of neural networks could only be superficial.
In the next chapter we will use linear algebra to analyze the operation of
one of the first neural network training algorithms the Hebb rule.
6-29
Further Reading
[Brog91]
[Stra76]
6-30
Exercises
Exercises
E6.1 Is the operation of transposing a matrix a linear transformation?
E6.2 Consider again the neural network shown in Figure P6.1. Show that if the
bias vector b is equal to zero then the network performs a linear operation.
E6.3 Consider the linear transformation illustrated in Figure E6.1.
i. Find the matrix representation of this transformation relative to
the standard basis set.
ii. Find the matrix of this transformation relative to the basis set
v 1 v 2 .
v2
A(v1)
s2
v1
s1
A(v2)
Figure E6.1 Example Transformation for Exercise E6.3
E6.4 Consider the space of complex numbers. Let this be the vector space X , and
let the basis for X be {1 + j, 1 j} . Let A :X X be the operation of multiplication by 1 + j (i.e., A x = 1 + j x ).
i. Find the matrix of the transformation
given above.
iv. Check your answers to parts (ii) and (iii) using MATLAB.
6-31
E6.5 Consider a transformation A :P P , from the space of second-order polynomials to the space of third-order polynomials, which is defined by the following:
x = a0 + a1 t + a2 t2 ,
A x = a0 t + 1 + a1 t + 1 2 + a2 t + 1 3 .
Find the matrix representation of this transformation relative to the basis
2
2
3
2 3
sets V = 1 t t V = 1 t t t .
E6.6 Consider the vector space of polynomials of degree two or less. These poly2
nomials have the form f t = a 0 + a 1 t + a 2 t . Now consider the transformation in which the variable t is replaced by t + 1 . (for example,
2
2
2
t + 2t + 3 t + 1 + 2 t + 1 + 3 = t + 4t + 6 )
i. Find the matrix of this transformation with respect to the basis set
2
1 t 1 t .
ii. Find the eigenvalues and eigenvectors of the transformation. Show
the eigenvectors as columns of numbers and as functions of time
(polynomials).
E6.7 Consider the space of functions of the form sin t + . One basis set for
this space is V = sin t cos t . Consider the differentiation transformation
D.
i. Find the matrix of the transformation
E6.8 Consider the vector space of functions of the form + e . One basis set
2t
2t
for this vector space is V = 1 + e 1 e . Consider the differentiation
transformation D .
i. Find the matrix of the transformation
using Eq. (6.6).
6-32
Exercises
v1 = 1 0 , v2 = 0 1 , v3 = 0 0 , v4 = 0 0
0 0
0 0
1 0
0 1
E6.10 Consider a transformation A :P P , from the space of first degree polynomials into the space of second degree polynomials. The transformation is
defined as follows
A a + bt = at + b--- t 2
2
A relative to
6-33
5t
u 1 u 2 = e te
for both the domain and the range of the transformation D.
i. Show that the transformation D is linear.,
ii. Find the matrix of this transformation relative to the basis shown
above.
iii. Find the eigenvalues and eigenvectors of the transformation D.
E6.12 A certain linear transformation has the following eigenvalues and eigenvectors (represented in terms of the standard basis set):
1 = 1 , z = 1 = 2
z1 =
2
1
2
2
2
A(v1)
v1
v2
A(v2)
Exercises
E6.14 Consider the vector spaces P and P of second-order and third-order polynomials. Find the matrix representation of the integration transformation
I :P 2 P 3 , relative to the basis sets V 2 = 1 t t 2 V 3 = 1 t t2 t 3 .
2
V = 1 2 .
3 5
1 = 1
2 = 2
A :R 2 R 2 has eigenvalues
z2 = 1 .
2
A relative to
6-35
V = 1 1 .
1
1
E6.17 Consider the transformation A created by projecting a vector x onto the line
shown in Figure E6.3. An example of the transformation is shown in the
figure.
i. Using Eq. (6.6), find the matrix representation of this transformation relative to the standard basis set s 1 s 2 .
ii. Using your answer to part i, find the matrix representation of this
transformation relative to the basis set v 1 v 2 shown in Figure
E6.3.
iii. What are the eigenvalues and eigenvectors of this transformation?
Sketch the eigenvectors and their transformations.
v1
s2
y =A(x )
s1
v2
6-36
Exercises
V = v 1 v 2 = 1 1 .
1 2
(The basis vectors are represented relative to the standard basis set.)
i. Find the reciprocal basis vectors for this basis set.
2
0 1 .
2 3
Find the expansion of Av 1 in terms of the basis set V . (Use the reciprocal basis vectors.)
iii. Find the expansion of Av 2 in terms of the basis set V .
iv. Find the matrix representation for A relative to the basis V . (This
step should require no further computation.)
6-37
Objectives
7-1
7-2
Linear Associator
7-3
7-4
Performance Analysis
7-5
Pseudoinverse Rule
7-7
Application
7-10
7-12
Summary of Results
7-14
Solved Problems
7-16
Epilogue
7-29
Further Reading
7-30
Exercises
7-31
Objectives
7
The Hebb rule was one of the first neural network learning laws. It was
proposed by Donald Hebb in 1949 as a possible mechanism for synaptic
modification in the brain and since then has been used to train artificial
neural networks.
In this chapter we will use the linear algebra concepts of the previous two
chapters to explain why Hebbian learning works. We will also show how
the Hebb rule can be used to train neural networks for pattern recognition.
7-1
Linear Associator
Linear Associator
Linear Associator
Linear Layer
Inputs
p
Rx1
W
SxR
Sx1
Sx1
S
a = purelin (Wp)
(7.1)
or
R
ai =
w ij p j .
(7.2)
j=1
Associative Memory
(7.3)
In other words, if the network receives an input p = p q then it should produce an output a = t q , for q = 1 2 Q . In addition, if the input is
changed slightly (i.e., p = p q + ) then the output should only be changed
slightly (i.e., a = t q + ).
7-3
w ijnew = w ijold + f i a iq g j p jq ,
(7.4)
where p jq is the jth element of the qth input vector p q ; a iq is the ith element of the network output when the qth input vector is presented to the
network; and is a positive constant, called the learning rate. This equation says that the change in the weight w ij is proportional to a product of
functions of the activities on either side of the synapse. For this chapter we
will simplify Eq. (7.4) to the following form
w ijnew = w ijold + a iq p jq .
(7.5)
Note that this expression actually extends Hebbs postulate beyond its
strict interpretation. The change in the weight is proportional to a product
of the activity on either side of the synapse. Therefore, not only do we increase the weight when both p j and a i are positive, but we also increase
the weight when they are both negative. In addition, this implementation
of the Hebb rule will decrease the weight whenever p j and a i have opposite
sign.
The Hebb rule defined in Eq. (7.5) is an unsupervised learning rule. It does
not require any information concerning the target output. In this chapter
we are interested in using the Hebb rule for supervised learning, in which
the target output is known for each input vector. (We will revisit the unsupervised Hebb rule in Chapter 13.) For the supervised Hebb rule we substitute the target output for the actual output. In this way, we are telling the
algorithm what the network should do, rather than what it is currently doing. The resulting equation is
w ijnew = w ijold + t iq p jq ,
(7.6)
where t iq is the ith element of the qth target vector t q . (We have set the
learning rate to one, for simplicity.)
Notice that Eq. (7.6) can be written in vector notation:
W
7-4
new
= W
old
+ tq pq .
(7.7)
If we assume that the weight matrix is initialized to zero and then each of
the Q input/output pairs are applied once to Eq. (7.7), we can write
Q
W = t1 p1 + t2 p2 + + tQ pQ =
T
tq pq .
T
(7.8)
q=1
p1
(7.9)
T
W = t 1 t 2 t Q p 2 = TP ,
T
pQ
where
T = t1 t2 tQ
P = p1 p2 pQ .
(7.10)
Performance Analysis
Lets analyze the performance of Hebbian learning for the linear associator. First consider the case where the p q vectors are orthonormal (orthogonal and unit length). If p k is input to the network, then the network
output can be computed
a = Wp k =
T
t q p q p k
q=1
T
tq pq pk .
(7.11)
q=1
pq pk = 1
q = k
= 0
q k.
(7.12)
(7.13)
The output of the network is equal to the target output. This shows that, if
the input prototype vectors are orthonormal, the Hebb rule will produce the
correct output for each input.
7-5
But what about non-orthogonal prototype vectors? Lets assume that each
p q vector is unit length, but that they are not orthogonal. Then Eq. (7.11)
becomes
Error
a = Wp k = t k +
tq pq pk .
T
(7.14)
qk
Because the vectors are not orthogonal, the network will not produce the
correct output. The magnitude of the error will depend on the amount of
correlation between the prototype input patterns.
2
+2
0.5
0.5 t = 1
p1 =
1
1
0.5
0.5
0.5
1
0.5
t2 =
p2 =
.
1
0.5
0.5
(7.15)
W = TP =
(7.16)
0.5 = 1 ,
Wp 1 =
0 1 1 0 0.5
1
0.5
(7.17)
0.5
Wp 2 = 1 0 0 1 0.5 = 1 .
0 1 1 0 0.5
1
0.5
(7.18)
and
7-6
Pseudoinverse Rule
2
+2
Now lets revisit the apple and orange recognition problem described in
Chapter 3. Recall that the prototype inputs were
1
p 1 = 1 orange
1
p2 =
1
1 apple .
1
(7.19)
(Note that they are not orthogonal.) If we normalize these inputs and
choose as desired outputs -1 and 1, we obtain
0.5774
p
=
1
0.5774 t 1 = 1
0.5774
0.5774
p 2 = 0.5774 t 2 = 1 .
0.5774
(7.20)
(7.21)
(7.22)
0.5774
Wp 2 = 0 1.1548 0 0.5774 = 0.6668 .
0.5774
(7.23)
The outputs are close, but do not quite match the target outputs.
Pseudoinverse Rule
When the prototype input patterns are not orthogonal, the Hebb rule produces some errors. There are several procedures that can be used to reduce
these errors. In this section we will discuss one of those procedures, the
pseudoinverse rule.
Recall that the task of the linear associator was to produce an output of t q
for an input of p q . In other words,
Wp q = t q
7-7
q = 1 2 Q .
(7.24)
F W =
t q Wp q .
(7.25)
q=1
If the prototype input vectors p q are orthonormal and we use the Hebb rule
to find W, then F(W) will be zero. When the input vectors are not orthogonal and we use the Hebb rule, then F(W) will be not be zero, and it is not
clear that F(W) will be minimized. It turns out that the weight matrix that
will minimize F(W) is obtained by using the pseudoinverse matrix, which
we will define next.
First, lets rewrite Eq. (7.24) in matrix form:
WP = T ,
(7.26)
T = t1 t2 tQ P = p1 p2 pQ .
(7.27)
where
= E ,
(7.28)
where
E = T WP ,
(7.29)
and
E
eij .
2
(7.30)
Note that F(W) can be made zero if we can solve Eq. (7.26). If the P matrix
has an inverse, the solution is
1
W = TP .
(7.31)
7-8
Pseudoinverse Rule
Pseudoinverse Rule
It has been shown [Albe72] that the weight matrix that minimizes Eq.
(7.25) is given by the pseudoinverse rule:
+
W = TP ,
(7.32)
PP P = P,
+
P PP = P ,
+
(7.33)
P P = P P ,
+ T
PP = PP .
When the number, R, of rows of P is greater than the number of columns,
Q, of P , and the columns of P are independent, then the pseudoinverse can
be computed by
+
P = P P P .
2
+2
(7.34)
To test the pseudoinverse rule (Eq. (7.32)), consider again the apple and orange recognition problem. Recall that the input/output prototype vectors
are
p1 = 1 t1 = 1
p2 = 1 t2 = 1 .
(7.35)
(Note that we do not need to normalize the input vectors when using the
pseudoinverse rule.)
The weight matrix is calculated from Eq. (7.32):
+
1 1
+
W = TP = 1 1 1 1 ,
1 1
(7.36)
7-9
(7.37)
(7.38)
(7.39)
1
1 = 1
1
(7.40)
Wp 2 = 0 1 0
The network outputs exactly match the desired outputs. Compare this result with the performance of the Hebb rule. As you can see from Eq. (7.22)
and Eq. (7.23), the Hebbian outputs are only close, while the pseudoinverse
rule produces exact results.
Application
Autoassociative Memory
Now lets see how we might use the Hebb rule on a practical, although
greatly oversimplified, pattern recognition problem. For this problem we
will use a special type of associative memory the autoassociative memory. In an autoassociative memory the desired output vector is equal to the
input vector (i.e., t q = p q ). We will use an autoassociative memory to store
a set of patterns and then to recall these patterns, even when corrupted
patterns are provided as input.
The patterns we want to store are shown to the left. (Since we are designing
an autoassociative memory, these patterns represent the input vectors and
the targets.) They represent the digits {0, 1, 2} displayed in a 6X5 grid. We
need to convert these digits to vectors, which will become the prototype patterns for our network. Each white square will be represented by a -1, and
each dark square will be represented by a 1. Then, to create the input vectors, we will scan each 6X5 grid one column at a time. For example, the first
prototype pattern will be
T
p1 = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 .
(7.41)
7-10
Application
W = p1 p1 + p2 p2 + p3 p3 .
(7.42)
Inputs
p
30x1
30
W
30x30
30x1
30x1
30
a = hardlims (Wp)
7-11
new
= W
old
+ tq pq .
(7.43)
A positive parameter , called the learning rate, can be used to limit the
amount of increase in the weight matrix elements, if the learning rate is
less than one, as in:
W
new
= W
old
+ t q p q .
(7.44)
We can also add a decay term, so that the learning rule behaves like a
smoothing filter, remembering the most recent inputs more clearly:
W
new
= W
old
+ t q p q W
old
= 1 W
old
+ t q p q ,
(7.45)
7-12
law quickly forgets old inputs and remembers only the most recent patterns. This keeps the weight matrix from growing without bound.
The idea of filtering the weight changes and of having an adjustable learning rate are important ones, and we will discuss them again in Chapters
10, 12, 15, 16, 18 and 19.
If we modify Eq. (7.44) by replacing the desired output with the difference
between the desired output and the actual output, we get another important learning rule:
W
new
= W
old
+ t q a q p q .
(7.46)
This is sometimes known as the delta rule, since it uses the difference between desired and actual output. It is also known as the Widrow-Hoff algorithm, after the researchers who introduced it. The delta rule adjusts the
weights so as to minimize the mean square error (see Chapter 10). For this
reason it will produce the same results as the pseudoinverse rule, which
minimizes the sum of squares of errors (see Eq. (7.25)). The advantage of
the delta rule is that it can update the weights after each new input pattern
is presented, whereas the pseudoinverse rule computes the weights in one
step, after all of the input/target pairs are known. This sequential updating
allows the delta rule to adapt to a changing environment. The delta rule
will be discussed in detail in Chapter 10.
The basic Hebb rule will be discussed again, in a different context, in Chapter 13. In the present chapter we have used a supervised form of the Hebb
rule. We have assumed that the desired outputs of the network, t q , are
known, and can be used in the learning rule. In the unsupervised Hebb
rule, which is discussed in Chapter 13, the actual network output is used
instead of the desired network output, as in:
W
new
= W
old
+ a q p q ,
(7.47)
where a q is the output of the network when p q is given as the input (see
also Eq. (7.5)). This unsupervised form of the Hebb rule, which does not require knowledge of the desired output, is actually a more direct interpretation of Hebbs postulate than is the supervised form discussed in this
chapter.
7-13
Summary of Results
Hebbs Postulate
When an axon of cell A is near enough to excite a cell B and repeatedly or
persistently takes part in firing it, some growth process or metabolic change
takes place in one or both cells such that As efficiency, as one of the cells firing B, is increased.
Linear Associator
Linear Layer
Inputs
p
Rx1
W
SxR
Sx1
Sx1
S
a = purelin (Wp)
p1
T
W = t 1 t 2 t Q p 2 = TP
T
pQ
Pseudoinverse Rule
W = TP
7-14
Summary of Results
P = P P P .
= 1 W
old
+ t q p q
Delta Rule
(See Chapter 10)
W
new
= W
old
+ t q a q p q
Unsupervised Hebb
(See Chapter 13)
W
new
= W
old
+ a q p q
7-15
Solved Problems
P7.1 Consider the linear associator shown in Figure P7.1.
Linear Layer
Inputs
4x1
2x4
2x1
2x1
2
a = purelin (Wp)
1 t = 1
p1 =
1
1
1
1
1
t2 =
p2 =
.
1
1
i. Use the Hebb rule to find the appropriate weight matrix for
this linear associator.
ii. Repeat part (i) using the pseudoinverse rule.
iii. Apply the input p 1 to the linear associator using the weight
matrix of part (i), then using the weight matrix of part (ii).
i.
1
1 ,
1
1
T =
1 1 .
1 1
7-16
Solved Problems
W = TP =
1 1 1 1 1 1 = 2 0 0 2 .
1 1 1 1 1 1
0 2 2 0
W = TP .
Since the number of rows of P , four, is greater than the number of columns
of P , two, and the columns of P are independent, then the pseudoinverse
can be computed by Eq. (7.34):
+
P = P P P .
1 1
+
P = 1 1 1 1 1 1
1 1 1 1 1 1
1 1
1 1 1 1 = 4 0
0 4
1 1 1 1
1
1 1
--- ----- 0
4
1
1
1
1
=
= 4 4
1 1
1 1 1 1 1
--- --0 --4 4
4
1
--4
1
--4
1 1 1 1
1 1 1 1
1
--4
1
--4
1
--4
1
--4
1
--4
1
--4
7
1
1
--- 0
--4 = 2
1
1
--0 --4
2
1
0 --2 .
1
--- 0
2
7-17
1
--- 0
W p1 = 2
1
0 --2
p
1 1
0 --2 1 = 1 = t
1
1
1
1
--- 0
2
1
Why didnt the Hebb rule produce the correct results? Well, consider again
Eq. (7.11). Since p 1 and p 2 are orthogonal (check that they are) this equation can be written
T
W p1 = t1 p1 p1 ,
T
t q Wp q ,
q=1
p1
p2
pt
p2 = 1 1 1 1 1 1 .
7-18
Solved Problems
1
1
T
p1 p2 = 1 1 1 1 1 1 1 = 0 .
1
1
1
Therefore they are orthogonal. (Although they are not normalized since
T
p 1 p 1 = p 2 p 2 = 6 .)
ii. We will use an autoassociator like the one in Figure 7.2, except that the
number of inputs and outputs to the network will be six. To find the weight
matrix we use the Hebb rule:
T
W = TP ,
where
1
1
P = T = 1
1
1
1
1
1
1 .
1
1
1
1
2 0
1
0 2
1 1 1 1 1 1 1 = 2 0
1 1 1 1 1 1 1
0 2
1
2 0
1
0 2
2
0
2
0
2
0
0
2
0
2
0
2
2
0
2
0
2
0
0
2
0 .
2
0
2
pt = 1 1 1 1 1 1 .
The network response is then
7-19
a = hardlims Wp t = hardlims
a = hardlims
2
6
2
6
2
6
2
0
2
0
2
0
0
2
0
2
0
2
2
0
2
0
2
0
0
2
0
2
0
2
2
0
2
0
2
0
0 1
2 1
0 1
2 1
0 1
2 1
1 = p .
=
2
1
1
1
p2 = 1
1
1
1
7-20
1
1
1
p3 = 1
1
1
1
1
1
1
pt = 1
1
1
1
Solved Problems
2+2
ans =
4
This problem is a little tedious to work out by hand, so lets use MATLAB.
First we create the prototype vectors.
p1=[ 1
1 -1 -1
p2=[ 1
-1
p3=[-1
1 -1
1 -1
1
1 -1
1]';
1]';
1]';
P=[p1 p2 p3];
Now we can compute the weight matrix using the Hebb rule.
wh=P*P';
1 -1 -1
1 -1
1]';
-1
-1
-1
Notice that this response does not match any of the prototype vectors. This
is not surprising since the prototype patterns are not orthogonal. Lets try
the pseudoinverse rule.
pseu=inv(P'*P)*P';
wp=P*pseu;
ap=hardlims(wp*pt);
ap'
ans =
-1
-1
-1
Note that the network response is equal to p 3 . Is this the correct response?
As usual, we want the response to be the prototype pattern closest to the
input pattern. In this case p t is a Hamming distance of 2 from both p 1 and
p 2 , but only a distance of 1 from p 3 . Therefore the pseudoinverse rule produces the correct response.
Try other test inputs to see if there are additional cases where the pseudoinverse rule produces better results than the Hebb rule.
7-21
p1
p2
pt
p3
1
p2 = 1
1
1
1
p3 = 1
1
1
1
pt = 1 .
1
1
We now need to choose the desired output vectors for each prototype input
vector. Since there are three prototype vectors that we need to distinguish,
we will need two elements in the output vector. We can choose the three desired outputs to be:
t1 = 1
1
t2 = 1
1
1 .
1
t3 =
(Note that this choice was arbitrary. Any distinct combination of 1 and -1
could have been chosen for each vector.)
The resulting network is shown in Figure P7.2.
Inputs
p
4x1
W
2x4
2x1
2x1
2
a = hardlims (Wp)
7-22
Solved Problems
T
W = TP = 1 1 1
1 1 1
1 1 1 1
3 1 1 1
1 1 1 1 =
1 3 1 1
1 1 1 1
ii. The response of the network to the test input pattern is calculated as
follows.
a = hardlims Wp t = hardlims 3 1 1 1 1
1 3 1 1 1
= hardlims 2 = 1 p 1 .
2
1
So the response of the network indicates that the test input pattern is closest to p 1 . Is this correct? Yes, the Hamming distance to p 1 is 1, while the
distance to p 2 and p 3 is 3.
P7.5 Suppose that we have a linear autoassociator that has been designed for Q orthogonal prototype vectors of length R using the
Hebb rule. The vector elements are either 1 or -1.
i. Show that the Q prototype patterns are eigenvectors of the
weight matrix.
ii. What are the other ( R - Q ) eigenvectors of the weight matrix?
i.
Since this is an autoassociator, these are both the input vectors and the desired output vectors. Therefore
T = p1 p2 pQ
P = p1 p2 pQ .
If we then use the Hebb rule to calculate the weight matrix we find
Q
T
W = TP =
pq pq ,
T
q=1
7-23
from Eq. (7.8). Now, if we apply one of the prototype vectors as input to the
network we obtain
a = Wp k =
q=1
T
p q p q p k =
pq pq pk .
T
q=1
a = pk pk pk .
And since every element of p k must be either -1 or 1, we find that
a = pk R .
To summarize the results:
Wp k = Rp k ,
which implies that p k is an eigenvector of W and R is the corresponding
eigenvalue. Each prototype vector is an eigenvector with the same eigenvalue.
ii. Note that the repeated eigenvalue R has a Q -dimensional eigenspace
associated with it: the subspace spanned by the Q prototype vectors. Now
consider the subspace that is orthogonal to this eigenspace. Every vector in
this subspace should be orthogonal to each prototype vector. The dimension
of the orthogonal subspace will be R - Q . Consider the following arbitrary
basis set for this orthogonal space:
z 1 z 2 z R Q .
If we apply any one of these basis vectors to the network we obtain:
a = Wz k =
q=1
T
p q p q z k
pq pq zk
T
= 0,
q=1
7-24
Solved Problems
P7.6 The networks we have used so far in this chapter have not included a bias vector. Consider the problem of designing a perceptron
network (Figure P7.3) to recognize the following patterns:
p1 = 1
1
Inputs
p
2x1
1
2
p2 = 2 .
2
Sym. Hard
- Title
Limit
- Layer
W
1x2
1x1
1x1
b
1
1x1
- Exp (Wp
- + b)
a = hardlims
Figure P7.3 Single-Neuron Perceptron
i. Why is a bias required to solve this problem?
ii. Use the pseudoinverse rule to design a network with bias to
solve this problem.
i. Recall from Chapters 3 and 4 that the decision boundary for the perceptron network is the line defined by:
Wp + b = 0 .
If there is no bias, then b = 0 and the boundary is defined by:
Wp = 0 ,
Wp = 0
p2
p1
which is a line that must pass through the origin. Now consider the two
vectors, p 1 and p 2 , which are given in this problem. They are shown graphically in the figure to the left, along with an arbitrary decision boundary
that passes through the origin. It is clear that no decision boundary that
passes through the origin could separate these two vectors. Therefore a
bias is required to solve this problem.
ii. To use the pseudoinverse rule (or the Hebb rule) when there is a bias
term, we should treat the bias as another weight, with an input of 1 (as is
shown in all of the network figures). We then augment the input vectors
with a 1 as the last element:
7-25
1
p' 1 = 1
1
2
p' 2 = 2 .
1
t2 = 1 ,
so that
1 2
P = 1 2 , T = 1 1 .
1 1
We now form the pseudoinverse matrix:
1 2
+
P = 1 1 1 1 2
2 2 1
1 1
1 1 1 = 3 5
2 2 1
5 9
1 1 1 = 0.5 0.5 2 .
2 2 1
0.5 0.5 1
We can then pull out the standard weight matrix and bias:
W = 1 1
b = 3.
The decision boundary for this weight and bias is shown in the Figure P7.4.
This boundary does separate the two prototype vectors.
7-26
Solved Problems
Wp + b = 0
p2
p1
p q = 2p' q 1 ,
7-27
effective response as a bipolar network (as in Figure 7.2), then the net input, n , should be the same for both networks:
W'p' + b = Wp .
Inputs
p'
Rx1
W'
SxR
a
Sx1
b
Sx1
n
Sx1
a = hardlim (Wp'+ b)
Figure P7.5 Binary Associative Network
This will guarantee that whenever the bipolar network produces a 1 the
binary network will produce a 1, and whenever the bipolar network produces a -1 the binary network will produce a 0.
If we then substitute for p' as a function of p we find:
1
1
1
1
W' --- p + --- 1 + b = --- W'p + --- W'1 + b = Wp .
2
2
2
2
Therefore, to produce the same results as the bipolar network, we should
choose
W' = 2W
where W is the bipolar weight matrix.
7-28
b = W1 ,
Epilogue
Epilogue
We had two main objectives for this chapter. First, we wanted to introduce
one of the most influential neural network learning rules: the Hebb rule.
This was one of the first neural learning rules ever proposed, and yet it continues to influence even the most recent developments in network learning
theory. Second, we wanted to show how the performance of this learning
rule could be explained using the linear algebra concepts discussed in the
two preceding chapters. This is one of the key objectives of this text. We
want to show how certain important mathematical concepts underlie the
operation of all artificial neural networks. We plan to continue to weave together the mathematical ideas with the neural network applications, and
hope in the process to increase our understanding of both.
We will again revisit the Hebb rule in Chapters 15 and 21. In Chapter 21
we will use the Hebb rule in the design of a recurrent associative memory
network the Hopfield network.
The next two chapters introduce some mathematics that are critical to our
understanding of the two learning laws covered in Chapters 10 and 11.
Those learning laws fall under a subheading called performance learning,
because they attempt to optimize the performance of the network. In order
to understand these performance learning laws, we need to introduce some
basic concepts in optimization. As with the material on the Hebb rule, our
understanding of these topics in optimization will be greatly aided by our
previous work in linear algebra.
7-29
Further Reading
[Albe72]
A. Albert, Regression and the Moore-Penrose Pseudoinverse, New York: Academic Press, 1972.
Alberts text is the major reference for the theory and basic
properties of the pseudoinverse. Proofs are included for all
major pseudoinverse theorems.
[Ande72]
J. Anderson, A simple neural network generating an interactive memory, Mathematical Biosciences, vol. 14, pp.
197220, 1972.
Anderson proposed a linear associator model for associative memory. The model was trained, using a generalization of the Hebb postulate, to learn an association between
input and output vectors. The physiological plausibility of
the network was emphasized. Kohonen published a closely
related paper at the same time [Koho72], although the two
researchers were working independently.
[Hebb49]
[Koho72]
T. Kohonen, Correlation matrix memories, IEEE Transactions on Computers, vol. 21, pp. 353359, 1972.
Kohonen proposed a correlation matrix model for associative memory. The model was trained, using the outer product rule (also known as the Hebb rule), to learn an
association between input and output vectors. The mathematical structure of the network was emphasized. Anderson published a closely related paper at the same time
[Ande72], although the two researchers were working independently.
7-30
Exercises
Exercises
E7.1 Consider the prototype patterns given to the left.
p1
p2
pt
p1
p2
Inputs
p
6x1
W
1x6
1x1
1x1
1
a = hardlims (Wp)
W = PP QI ,
7-31
where Q is the number of prototype vectors. (Hint: show that the prototype
vectors continue to be eigenvectors of the new weight matrix.)
E7.6 We have three input/output prototype vector pairs:
1 t = 1 p = 1 t = 1 p = 0 t = 1 .
p1 =
2
3
1
2
3
0
1
1
i. Show that this problem cannot be solved unless the network uses a
bias.
ii. Use the pseudoinverse rule to design a network for these prototype
vectors. Verify that the network correctly transforms the prototype
vectors.
E7.7 Consider the reference patterns and targets given below. We want to use
these data to train a linear associator network.
2 t =
p1 =
26
1
4
4 t =
p2 =
26
2
2
2 t =
p3 =
26
3
2
7-32
Exercises
iv. Find the eigenvalues and eigenvectors of the weight matrix. (Do not
solve the equation W I = 0 . Use an analysis of the Hebb
rule.)
-1
p1
p2
p3
3 t =
p1 =
75
1
6
6 t =
p2 =
75
2
3
6 t =
p3 =
75
3
3
1 t =
p1 =
1
1
1
1 t =
p2 =
1
2
1
i. Use the Hebb rule to determine the weight matrix for the perceptron network shown in Figure E7.3.
ii. Plot the resulting decision boundary. Is this a good decision
boundary? Explain.
iii. Repeat part i. using the Pseudoinverse rule.
iv. Will there be any difference in the operation of the network if the
Pseudoinverse weight matrix is used? Explain.
7-33
Inputs
p
2x1
1x1
n
1x1
1x2
2
a = hardlims(Wp)
E7.11 One question we might ask about the Hebb and pseudoinverse rules is:
How many prototype patterns can be stored in one weight matrix? Test this
experimentally using the digit recognition problem that was discussed on
page 7-10. Begin with the digits 0 and 1. Add one digit at a time up to
6, and test how often the correct digit is reconstructed after randomly
changing 2, 4 and 6 pixels.
i. First use the Hebb rule to create the weight matrix for the digits 0
and 1. Then randomly change 2 pixels of each digit and apply the
noisy digits to the network. Repeat this process 10 times, and record
the percentage of times in which the correct pattern (without noise)
is produced at the output of the network. Repeat as 4 and 6 pixels of
each digit are modified. The entire process is then repeated when
the digits 0, 1 and 2 are used. This continues, one digit at a
time, until you test the network when all of the digits 0 through
6 are used. When you have completed all of the tests, you will be
able to plot three curves showing percentage error versus number of
digits stored, one curve each for 2, 4 and 6 pixel errors.
ii. Repeat part (i) using the pseudoinverse rule, and compare the results of the two rules.
7-34
Objectives
8-1
8-2
Taylor Series
8-2
Vector Case
8-4
Directional Derivatives
8-5
Minima
8-7
8-9
First-Order Conditions
8-10
Second-Order Conditions
8-11
Quadratic Functions
Eigensystem of the Hessian
8-12
8-13
Summary of Results
8-20
Solved Problems
8-22
Epilogue
8-34
Further Reading
8-35
Exercises
8-36
Objectives
This chapter lays the foundation for a type of neural network training technique called performance learning. There are several different classes of
network learning laws, including associative learning (as in the Hebbian
learning of Chapter 7) and competitive learning (which we will discuss in
Chapter 16). Performance learning is another important class of learning
law, in which the network parameters are adjusted to optimize the performance of the network. In the next two chapters we will lay the groundwork
for the development of performance learning, which will then be presented
in detail in Chapters 1014. The main objective of the present chapter is to
investigate performance surfaces and to determine conditions for the existence of minima and maxima of the performance surface. Chapter 9 will follow this up with a discussion of procedures to locate the minima or maxima.
8-1
Performance Index
There are several different learning laws that fall under the category of
performance learning. Two of these will be presented in this text. These
learning laws are distinguished by the fact that during training the network parameters (weights and biases) are adjusted in an effort to optimize
the performance of the network.
There are two steps involved in this optimization process. The first step is
to define what we mean by performance. In other words, we must find a
quantitative measure of network performance, called the performance index, which is small when the network performs well and large when the
network performs poorly. In this chapter, and in Chapter 9, we will assume
that the performance index is given. In Chapters 10, 11 and 13 we will discuss the choice of performance index.
The second step of the optimization process is to search the parameter
space (adjust the network weights and biases) in order to reduce the performance index. In this chapter we will investigate the characteristics of
performance surfaces and set some conditions that will guarantee that a
surface does have a minimum point (the optimum we are searching for).
Thus, in this chapter we will obtain some understanding of what performance surfaces look like. Then, in Chapter 9 we will develop procedures for
locating the optimum points.
Taylor Series
Let us say that the performance index that we want to minimize is represented by F x , where x is the scalar parameter we are adjusting. We will
assume that the performance index is an analytic function, so that all of its
derivatives exist. Then it can be represented by its Taylor series expansion
about some nominal point x :
F x = F x +
d
F x
dx
x = x
x x
1 d
+ --- 2 F x
2 dx
x x +
2
1 d
+ ----- n F x
n! d x
2
+2
(8.1)
x = x
x x +
n
x = x
8-2
Taylor Series
F x = cos x .
(8.2)
(8.3)
(8.4)
(8.5)
(Note that in this case the first-order approximation is the same as the zeroth-order approximation, since the first derivative is zero.)
The fourth-order approximation is
1 2 1 4
F x F 4 x = 1 --- x + ------ x .
2
24
(8.6)
F0 x
F4 x
0.5
-0.5
Fx
F2 x
-1
-1.5
-6
-4
-2
8-3
From the figure we can see that all three approximations are accurate if x
is very close to x = 0 . However, as x moves farther away from x only the
higher-order approximations are accurate. The second-order approximation is accurate over a wider range than the zeroth-order approximation,
and the fourth-order approximation is accurate over a wider range than the
second-order approximation. An investigation of Eq. (8.1) explains this behavior. Each succeeding term in the series involves a higher power of
x x . As x gets closer to x , these terms will become geometrically
smaller.
We will use the Taylor series approximations of the performance index to
investigate the shape of the performance index in the neighborhood of possible optimum points.
To experiment with Taylor series expansions of the cosine function, use the
MATLAB Neural Network Design Demonstration Taylor Series (nnd8ts1).
Vector Case
Of course the neural network performance index will not be a function of a
scalar x . It will be a function of all of the network parameters (weights and
biases), of which there may be a very large number. Therefore, we need to
extend the Taylor series expansion to functions of many variables. Consider the following function of n variables:
F x = F x 1 x 2 x n .
(8.7)
The Taylor series expansion for this function, about the point x , will be
Fx
F x
F x = F x +
x x +
x x
x1
x2
x = x 1 1
x = x 2 2
++
1
Fx
x x + --- 2 F x
x x
xn
2 x
x = x n n
x = x 1 1
1
1
Fx
+ -- x x x 2 x 2 +
2 x 1 x 2
x = x 1 1
(8.8)
This notation is a bit cumbersome. It is more convenient to write it in matrix form, as in:
F x = F x + F x
x = x
x x
T
1
x x +
+ --- x x 2F x
2
x = x
Gradient
(8.9)
Directional Derivatives
Fx
F x
Fx ,
x1
x2
xn
F x =
Hessian
(8.10)
Fx
Fx
x 1 x 2
x 1 x n
F x
2
x1
Fx
2F x = x 2 x 1
F x
2
x2
Fx .
x 2 x n
Fx
Fx
x n x 1
x n x 2
(8.11)
2
2
xn
F x
The gradient and the Hessian are very important to our understanding of
performance surfaces. In the next section we discuss the practical meaning
of these two concepts.
To experiment with Taylor series expansions of a function of two variables,
use the MATLAB Neural Network Design Demonstration Vector Taylor
Series(nnd8ts2).
Directional Derivatives
Directional Derivative
The ith element of the gradient, F x x i , is the first derivative of the performance index F along the x i axis. The ith element of the diagonal of the
2
2
Hessian matrix, F x x i , is the second derivative of the performance index F along the x i axis. What if we want to know the derivative of the function in an arbitrary direction? We let p be a vector in the direction along
which we wish to know the derivative. This directional derivative can be
computed from
T
p F x
---------------------- .
p
(8.12)
p 2F x p
---------------------------.
2
p
8-5
(8.13)
2
+2
F x = x 1 + 2x 2 .
(8.14)
Suppose that we want to know the derivative of the function at the point
T
T
x = 0.5 0.5 in the direction p = 2 1 . First we evaluate the gradient
at x :
F x
= x
F x
x1
F x
x2
2x 1
4x 2
= x
x = x
= 1 .
2
(8.15)
(8.16)
Therefore the function has zero slope in the direction p from the point x .
Why did this happen? What can we say about those directions that have
zero slope? If we consider the definition of directional derivative in Eq.
(8.12), we can see that the numerator is an inner product between the direction vector and the gradient. Therefore any direction that is orthogonal
to the gradient will have zero slope.
Which direction has the greatest slope? The maximum slope will occur
when the inner product of the direction vector and the gradient is a maximum. This happens when the direction vector is the same as the gradient.
(Notice that the magnitude of the direction vector has no effect, since we
normalize by its magnitude.) This effect is illustrated in Figure 8.2, which
shows a contour plot and a 3-D plot of F x . On the contour plot we see five
vectors starting from our nominal point x and pointing in different directions. At the end of each vector the first directional derivative is displayed.
The maximum derivative occurs in the direction of the gradient. The zero
derivative is in the direction orthogonal to the gradient (tangent to the contour line).
To experiment with directional derivatives, use the MATLAB Neural Network Design Demonstration Directional Derivatives (nnd8dd).
8-6
Minima
2.2
2.0
1.6
0.8
x2
0.0
0
2
-1
x2
-2
-2
-1
-1
-2
-1
-2
x1
x1
Minima
Recall that the objective of performance learning will be to optimize the
network performance index. In this section we want to define what we
mean by an optimum point. We will assume that the optimum point is a
minimum of the performance index. The definitions can be easily modified
for maximization problems.
Strong Minimum
Strong Minimum
The point x is a strong minimum of F x if a scalar 0 exists, such that
F x F x + x for all x such that x 0 .
In other words, if we move away from a strong minimum a small distance
in any direction the function will increase.
Global Minimum
Global Minimum
The point x is a unique global minimum of F x if F x F x + x for all
x 0 .
For a simple strong minimum, x , the function may be smaller than F x
at some points outside a small neighborhood of x . Therefore this is sometimes called a local minimum. For a global minimum the function will be
larger than the minimum point at every other point in the parameter
space.
Weak Minimum
Weak Minimum
The point x is a weak minimum of F x if it is not a strong minimum, and a scalar 0 exists, such that F x F x + x for all x such that x 0 .
8-7
No matter which direction we move away from a weak minimum, the function cannot decrease, although there may be some directions in which the
function does not change.
2
+2
(8.17)
This function is displayed in Figure 8.3. Notice that it has two strong minimum points: at approximately -1.1 and 1.1. For both of these points the
function increases in a local neighborhood. The minimum at 1.1 is a global
minimum, since there is no other point for which the function is as small.
There is no weak minimum for this function. We will show a two-dimensional example of a weak minimum later.
8
4
2 1
F x = 3x 7x --- x + 6
2
6
Local Minimum
Global Minimum
0
-2
-1
Now lets consider some vector cases. First, consider the following function:
4
F x = x 2 x 1 + 8x 1 x 2 x 1 + x 2 + 3 .
Contour Plot
Saddle Point
(8.18)
In Figure 8.4 we have a contour plot (a series of curves along which the
function value remains constant) and a 3-D surface plot for this function
(for function values less than 12). We can see that the function has two
strong local minimum points: one at (-0.42, 0.42), and the other at (0.55,
-0.55). The global minimum point is at (0.55, -0.55).
There is also another interesting feature of this function at (-0.13, 0.13). It
is called a saddle point because of the shape of the surface in the neighborhood of the point. It is characterized by the fact that along the line x 1 = x 2
the saddle point is a local maximum, but along a line orthogonal to that line
it is a local minimum. We will investigate this example in more detail in
Problems P8.2 and P8.5.
8-8
This function is used in the MATLAB Neural Network Design Demonstration Vector Taylor Series (nnd8ts2).
2
12
1
8
0
2
-1
1
1
-1
-2
-2
-1
-2
-1
-2
F x = x 1 1.5x 1 x 2 + 2x 2 x 1
(8.19)
The contour and 3-D plots of this function are given in Figure 8.5. Here we
can see that any point along the line x 1 = 0 is a weak minimum.
2
8
1
6
4
0
2
0
2
-1
1
1
-1
-2
-2
-1
-2
-1
-2
8-9
F x = F x + x = F x + F x
x = x
1 T
x + ,
+ --- x 2F x
2
x = x
(8.20)
where
x = x x .
(8.21)
First-Order Conditions
If x is very small then the higher order terms in Eq. (8.20) will be negligible and we can approximate the function as
F x + x F x + F x
x = x
x .
(8.22)
The point x is a candidate minimum point, which means that the function
should go up (or at least not go down) if x is not zero. For this to happen
the second term in Eq. (8.22) should not be negative. In other words
F x
x = x
x 0 .
(8.23)
x 0 ,
(8.24)
x = x
x = x
x F x .
(8.25)
x = x
x = 0 .
(8.26)
Stationary Points
x = x
= 0.
(8.27)
Therefore the gradient must be zero at a minimum point. This is a first-order, necessary (but not sufficient) condition for x to be a local minimum
point. Any points that satisfy Eq. (8.27) are called stationary points.
8-10
Second-Order Conditions
Assume that we have a stationary point x . Since the gradient of F x is
zero at all stationary points, the Taylor series expansion will be
1 T
F x + x = F x + --- x 2F x
x + .
2
x = x
(8.28)
x 2F x
x = x
x 0 .
For this to be true for arbitrary x 0 requires that the Hessian matrix be
positive definite. (By definition, a matrix A is positive definite if
T
z Az 0
Positive Semidefinite
(8.29)
(8.30)
z Az 0
(8.31)
for any vector z . We can check these conditions by testing the eigenvalues
of the matrix. If all eigenvalues are positive, then the matrix is positive definite. If all eigenvalues are nonnegative, then the matrix is positive
semidefinite.)
Sufficient Condition
2
+2
F x = x1 + x2 .
(8.32)
F x = 4x 1 = 0 .
2x 2
8-11
(8.33)
x=0
= 12x 1 0
0 2
= 0 0 .
0 2
(8.34)
x=0
x = x
= 0 and 2F x
x = x
positive semidefinite.
x = x
= 0 and 2F x
x = x
positive definite.
Quadratic Functions
We will find throughout this text that one type of performance index is universal the quadratic function. This is true because there are many applications in which the quadratic function appears, but also because many
functions can be approximated by quadratic functions in small neighborhoods, especially near local minimum points. For this reason we want to
spend a little time investigating the characteristics of the quadratic function.
Quadratic Function
(8.35)
where the matrix A is symmetric. (If the matrix is not symmetric it can be
replaced by a symmetric matrix that produces the same F x . Try it!)
To find the gradient for this function, we will use the following useful properties of the gradient:
T
h x = x h = h ,
where h is a constant vector, and
8-12
(8.36)
Quadratic Functions
(8.37)
(8.38)
(8.39)
All higher derivatives of the quadratic function are zero. Therefore the first
three terms of the Taylor series expansion (as in Eq. (8.20)) give an exact
representation of the function. We can also say that all analytic functions
behave like quadratics over a small neighborhood (i.e., when x is small).
(8.40)
The shape of this function can be seen more clearly if we perform a change
of basis (see Chapter 6). We want to use the eigenvectors of the Hessian
matrix, A , as the new basis vectors. Since A is symmetric, its eigenvectors
will be mutually orthogonal. (See [Brog91].) This means that if we make up
a matrix with the eigenvectors as the columns, as in Eq. (6.68):
B = z1 z2 zn ,
(8.41)
= B .
(8.42)
0 0 n
8-13
0 2 0
A' = B AB =
(8.43)
where the i are the eigenvalues of A . We can also write this equation as
T
A = BB .
(8.44)
We will now use the concept of the directional derivative to explain the
physical meaning of the eigenvalues and eigenvectors of A , and to explain
how they determine the shape of the surface of the quadratic function.
Recall from Eq. (8.13) that the second derivative of a function F x in the
direction of a vector p is given by
T
p 2F x p
p Ap
--------------------------- = -------------.
2
2
p
p
(8.45)
p = Bc ,
(8.46)
Now define
where c is the representation of the vector p with respect to the eigenvectors of A . (See Eq. (6.28) and the discussion that follows.) With this definition, and Eq. (8.44), we can rewrite Eq. (8.45):
n
i ci
p Ap
c c
c B BB Bc
=1
- = ----------- = i------------------------------ = ---------------------------------------.
n
2
T T
T
p
c B Bc
c c
2
ci
(8.47)
i=1
This result tells us several useful things. First, note that this second derivative is just a weighted average of the eigenvalues. Therefore it can never
be larger than the largest eigenvalue, or smaller than the smallest eigenvalue. In other words,
T
p Ap
- max .
min ------------2
p
(8.48)
Under what condition, if any, will this second derivative be equal to the
largest eigenvalue? What if we choose
p = z max ,
(8.49)
where z max is the eigenvector associated with the largest eigenvalue, max ?
For this case the c vector will be
T
c = B p = B z max = 0 0 0 1 0 0 ,
8-14
(8.50)
Quadratic Functions
where the one occurs only in the position that corresponds to the largest
eigenvalue (i.e., c max = 1 ). This is because the eigenvectors are orthonormal.
If we now substitute z max for p in Eq. (8.47) we obtain
n
i ci
z max Az max
i=1
--------------------------- = ------------------ = max .
n
2
z max
2
ci
(8.51)
i=1
So the maximum second derivative occurs in the direction of the eigenvector that corresponds to the largest eigenvalue. In fact, in each of the eigenvector directions the second derivatives will be equal to the corresponding
eigenvalue. In other directions the second derivative will be a weighted average of the eigenvalues. The eigenvalues are the second derivatives in the
directions of the eigenvectors.
z1
(min)
z2
(max)
2
+2
(8.52)
8-15
(8.53)
4
1
2
0
0
2
-1
1
1
-1
-2
-2
-1
-2
-1
-2
Lets try an example with distinct eigenvalues. Consider the following quadratic function:
1 T
2
2
F x = x 1 + x 1 x 2 + x 2 = --- x 2 1 x
2
12
(8.54)
(8.55)
(As we discussed in Chapter 6, the eigenvectors are not unique, they can be
multiplied by any scalar.) In this case the maximum curvature is in the direction of z 2 so we should cross contour lines more quickly in that direction.
Figure 8.7 shows the contour and 3-D plots for this function, an elliptical
hollow.
8-16
Quadratic Functions
3
1
2
0
2
-1
1
1
-1
-2
-2
-1
-2
-1
-2
What happens when the eigenvalues have opposite signs? Consider the following function:
1 2 3
1 2
1 T
F x = --- x 1 --- x 1 x 2 --- x 2 = --- x 0.5 1.5 x .
4
2
4
2
1.5 0.5
(8.56)
(8.58)
is no longer a strong minimum point, since the Hessian matrix is not positive definite. Since the eigenvalues are of opposite sign, we know that the
Hessian is indefinite (see [Brog91]). The stationary point is therefore a saddle point. It is a minimum of the function along the first eigenvector (positive eigenvalue), but it is a maximum of the function along the second
eigenvector (negative eigenvalue).
8-17
4
1
0
-4
-8
2
-1
1
1
-1
-2
-2
-1
-2
-1
-2
As a final example, lets try a case where one of the eigenvalues is zero. An
example of this is given by the following function:
1 2
1 2
1 T
F x = --- x 1 x 1 x 2 + --- x 2 = --- x 1 1 x .
2
2
2
1 1
(8.59)
1 1 , = 2 , z = 1 , = 0 , z = 1 .
1
1
2
2
1 1
1
1
(8.60)
(8.61)
8-18
Quadratic Functions
3
1
2
0
2
-1
1
1
-1
-2
-2
-1
-2
-1
-2
(8.62)
Summary of Results
Taylor Series
F x = F x + F x
x = x
x x
T
1
x x +
+ --- x x 2F x
2
x = x
Gradient
F x
Fx
Fx
x1
x2
xn
F x =
Hessian Matrix
F x
Fx
x 1 x 2
x 1 x n
Fx
2
x1
F x
2F x = x 2 x 1
Fx
2
x2
Directional Derivatives
First Directional Derivative
T
p F x
---------------------p
p 2F x p
--------------------------2
p
F x
F x
x n x 1
x n x 2
8-20
Fx
x 2 x n
2
xn
Fx
Summary of Results
Minima
Strong Minimum
The point x is a strong minimum of F x if a scalar 0 exists, such that
F x F x + x for all x such that x 0 .
Global Minimum
The point x is a unique global minimum of F x if F x F x + x for all
x 0 .
Weak Minimum
The point x is a weak minimum of F x if it is not a strong minimum, and a scalar 0 exists, such that F x F x + x for all x such that x 0 .
x = x
= 0 (Stationary Points)
Second-Order Condition
2F x
x = x
Quadratic Functions
1 T
T
F x = --- x Ax + d x + c
2
Gradient
F x = Ax + d
Hessian
2F x = A
Directional Derivatives
T
p Ap
- max
min ------------2
p
8-21
Solved Problems
P8.1 In Figure 8.1 we illustrated 3 approximations to the cosine function about the point x = 0 . Repeat that procedure about the point
x = 2 .
The function we want to approximate is
F x = cos x .
The Taylor series expansion for F x about the point x = 2 is
2
F x = cos x = cos --- sin --- x --- --- cos --- x ---
2
2
2
2 2
2
3
1
3
= x --- + --- x --- --------- x --- +
120
2
2 6
2
The zeroth-order approximation of F x is
F x F0 x = 0 .
The first-order approximation is
F x F 1 x = x --- = --- x .
2
2
(Note that in this case the second-order approximation is the same as the
first-order approximation, since the second derivative is zero.)
The third-order approximation is
1
3
F x F 3 x = x --- + --- x --- .
2
6
2
A graph showing F x and these three approximations is shown in Figure
P8.1. Note that in this case the zeroth-order approximation is very poor,
while the first-order approximation is accurate over a reasonably wide
range. Compare this result with Figure 8.1. In that case we were expanding
about a local maximum point, x = 0 , so the first derivative was zero.
Check the Taylor series expansions at other points using the Neural Network Design Demonstration Taylor Series (nnd8ts1).
8-22
Solved Problems
1.5
F1 x
1
0.5
F0 x
0
-0.5
Fx
-1
-1.5
-6
F3 x
-4
-2
F x = x 2 x 1 + 8x 1 x 2 x 1 + x 2 + 3 .
To find the second-order Taylor series expansion, we need to find the gradient and the Hessian for F x . For the gradient we have
F x =
F x
x1
F x
x2
4 x 2 x 1 + 8x 2 1
2F x =
Fx
2
x1
F x
x 1 x 2
F x
x 2 x 1
2
2
x2
12 x 2 x 1
2
12 x 2 x 1 + 8
8-23
4 x 2 x 1 + 8x 1 + 1
Fx
12 x 2 x 1 + 8
12 x 2 x 1
F x = F x + F x
x = x1
1
= 2.93 + --- x 0.42
2
0.42
1
1
1 T
1
x x + --- x x 2F x
x x
2
x = x1
8.42 0.42 x 0.42 .
0.42 8.42
0.42
12
1
8
0
2
-1
1
1
-1
-2
-2
-1
-2
-1
-2
8-24
Solved Problems
12
1
8
0
2
-1
1
1
-1
-2
-2
-1
-2
-1
-2
12
1
8
0
2
-1
1
1
-1
-2
-2
-1
-2
-1
-2
2 2
F x = 2 + x1 + 5 1 x1 x2
To solve this problem we can use the directional derivative. What is the derivative of F x along a line that is tangent to a contour line? Since the contour is a line along which the function does not change, the derivative of
F x should be zero in the direction of the contour. So we can get the equation for the tangent to the contour line by setting the directional derivative
equal to zero.
First we need to find the gradient:
8-25
F x =
2 2 + x 1 + 10 1 x 1 x 2 1
6 + 12x 1 + 10x 2
.
3
10 1 x 1 x 2 2x 2
p F x
---------------------- .
p
Therefore if we want the equation for the line that passes through
T
x = 0 0 and along which the derivative is zero, we can set the numerator of the directional derivative in the direction of x to zero:
x F x = 0 ,
T
12
1
8
0
2
-1
1
1
-1
-2
-2
-1
-2
-1
-2
8-26
Solved Problems
Find any stationary points and test them to see if they are minima.
To find the stationary points we set the derivative of F x to zero:
d
3
2
F x = 4x 2x 4x + 2 = 0 .
dx
We can use MATLAB to find the roots of this polynomial:
coef=[4 -2 -4 2];
stapoints=roots(coef);
stapoints
ans =
1.0000
-1.0000
0.5000
Now we need to check the second derivative at each of these points. The second derivative of F x is
d
dx
2
2
F x = 12x 4x 4 .
2 F 1 = 4 2 F 1 = 12 2 F 0.5 = 3 .
dx
dx
dx
Therefore we should have strong local minima at 1 and -1 (since the second
derivatives were positive), and a strong local maximum at 0.5 (since the
second derivative was negative). To find the global minimum we would
have to evaluate the function at the two local minima:
F 1 = 4.333 F 1 = 1.667 .
Therefore the global minimum occurs at -1. But are we sure that this is a
global minimum? What happens to the function as x or x ? In
this case, because the highest power of x has a positive coefficient and is
4
an even power ( x ), the function goes to at both limits. So we can safely
say that the global minimum occurs at -1. The function is plotted in Figure
P8.6.
8-27
4 2 3
2
F(x) = x --- x 2x + 2x + 4
3
0
-2
-1
2F x =
12 x 2 x 1 + 8
12 x 2 x 1 + 8
12 x 2 x 1
To test the definiteness of this matrix we can check the eigenvalues. If the
eigenvalues are all positive, the Hessian is positive definite, which guarantees a strong minimum. If the eigenvalues are nonnegative, the Hessian is
positive semidefinite, which is consistent with either a strong or a weak
minimum. If one eigenvalue is positive and the other eigenvalue is negative, the Hessian is indefinite, which would signal a saddle point.
1
2F x =
8.42 0.42 .
0.42 8.42
Solved Problems
therefore x must be a saddle point. In one direction the curvature is negative, and in another direction the curvature is positive. The negative curvature is in the direction of the first eigenvector, and the positive curvature
is in the direction of the second eigenvector. The eigenvectors are
z1 =
1 and z = 1 .
2
1
1
(Note that this is consistent with our previous discussion of this function
on page 8-8.)
3
2F x =
14.7 6.71 .
6.71 14.7
F x = t1 a1 x + t2 a2 x .
8-29
Linear Neuron
Input
1
a = purelin (wp + b)
Figure P8.7 Linear Network for Problem P8.6
The parameters of this network are w and b , which make up the parameter vector
x = w .
b
We want to sketch the performance index F x . First we will show that the
performance index is a quadratic function. Then we will find the eigenvectors and eigenvalues of the Hessian matrix and use them to sketch the contour plot of the function.
Begin by writing F x as an explicit function of the parameter vector x :
2
F x = e1 + e2 ,
where
e 1 = t 1 wp 1 + b e 2 = t 2 wp 2 + b .
This can be written in matrix form:
T
Fx = e e ,
where
e = t
p1 1
p2 1
x = t Gx .
F x = t Gx t Gx = t t 2t Gx + x G Gx .
8-30
Solved Problems
c = t t , d = 2 G t , and A = 2G G .
The gradient of the quadratic function is given in Eq. (8.38):
T
F x = Ax + d = 2G Gx 2 G t .
The stationary point (also the center of the function contours) will occur
where the gradient is equal to zero:
1
x = A d = G G G t .
1
For
G =
p1 1
p2 1
2 1 and t = 0.5
1 1
0
we have
1 T
T
x = G G G t = 5 1
1 2
1 = 0.167 .
0.5
0.167
To sketch the contour plot we need the eigenvectors and eigenvalues of the
Hessian. For this case we find
1
1 = 10.6 z 1 =
0.3
0.3
2 = 3.4 z 2 =
Therefore we know that x is a strong minimum. Also, since the first eigenvalue is larger than the second, we know that the contours will be elliptical
and that the long axis of the ellipses will be in the direction of the second
8-31
6
1
3
0
0
2
-1
1
1
-1
-2
-2
-1
-2
-1
-2
(8.63)
1 , = 2 z = 1 .
2
2
1 = 0 z 1 =
1
1
Notice that the first eigenvalue is zero, so there is no curvature along the
first eigenvector. The second eigenvalue is positive, so there is positive curvature along the second eigenvector. If we had no linear term in F x , the
plot of the function would show a stationary valley, as in Figure 8.9. In this
case we must find out if the linear term creates a slope in the direction of
the valley (the direction of the first eigenvector).
8-32
Solved Problems
F lin x =
which means that the linear term is increasing most rapidly in the direction of this gradient. Since the quadratic term has no curvature in this direction, the overall function will have a linear slope in this direction.
Therefore F x will have positive curvature in the direction of the second
eigenvector and a linear slope in the direction of the first eigenvector. The
contour plot and the 3-D plot for this function are given in Figure P8.9.
2
3
1
0
0
-3
-1
2
2
1
1
-1
-2
-2
-1
-2
-1
-2
since the Hessian matrix does not have an inverse. This lack of an inverse
could mean that we have a weak minimum point, as illustrated in Figure
8.9, or that there is no stationary point, as this example shows.
8-33
Epilogue
Performance learning is one of the most important classes of neural network learning rules. With performance learning, network parameters are
adjusted to optimize network performance. In this chapter we have introduced tools that we will need to understand performance learning rules. After reading this chapter and solving the exercises, you should be able to:
i. Perform a Taylor series expansion and use it to approximate a function.
ii. Calculate a directional derivative.
iii. Find stationary points and test whether they could be minima.
iv. Sketch contour plots of quadratic functions.
We will be using these concepts in a number of succeeding chapters, including the chapters on performance learning (914), the radial basis network
chapter (17) and the chapters on stability and Hopfield networks (2021).
In the next chapter we will build on the concepts we have covered here, to
design algorithms that will optimize performance functions. Then, in succeeding chapters, we will apply these algorithms to the training of neural
networks.
8-34
Further Reading
Further Reading
[Brog91]
[Gill81]
P. E. Gill, W. Murray, and M. H. Wright, Practical Optimization, New York: Academic Press, 1981.
As the title implies, this text emphasizes the practical implementation of optimization algorithms. It provides motivation for the optimization methods, as well as details of
implementation that affect algorithm performance.
[Himm72]
[Scal85]
8-35
Exercises
E8.1 Consider the following scalar function:
1
F x = -------------------------- .
1
3 3
x --- x --4
2
i. Find the second-order Taylor series approximation for F x about
the point x = 0.5 .
ii. Find the second-order Taylor series approximation for F x about
the point x = 1.1 .
iii. Plot F x and the two approximations and discuss their accuracy.
E8.2 Consider the following function of two variables:
F x = e
2x 1 + 2x 2 + x 1 5x 2 + 10
iv. Explain the difference between the two stationary points. (Use
MATLAB to plot the two functions.)
E8.3 For the following functions find the first and second directional derivatives
T
T
from the point x = 1 1 in the direction p = 1 1 .
7 2
2
i. F x = --- x 1 6x 1 x 2 x 2
2
2
ii. F x = 5x 1 6x 1 x 2 + 5x 2 + 4x 1 + 4x 2
9 2
2
iii. F x = --- x 1 2x 1 x 2 + 3x 2 + 2x 1 x 2
2
1
2
2
iv. F x = --- 7x 1 + 12x 1 x 2 2x 2
2
2
v. F x = x 1 + x 1 x 2 + x 2 + 3x 1 + 3x 2
8-36
Exercises
1 2
1 2
vi. F x = --- x 1 3x 1 x 2 + --- x 2 4x 1 + 4x 2
2
2
1 2
2
vii. F x = --- x 1 2x 1 x 2 + 2x 2 + x 1 2x 2
2
3 2
viii. F x = --- x 1 + 2x 1 x 2 + 4x 1 + 4x 2
2
3 2
3 2
ix. F x = --- x 1 + 4x 1 x 2 + --- x 2 + 5x 1
2
2
1 2
2
x. F x = 2x 1 2x 1 x 2 + --- x 2 + x 1 + x 2
2
E8.4 For the following function,
4 1 2
F x = x --- x + 1 ,
2
F x = x 1 + x 2 12x 1 x 2 + x 1 + x 2 + 1 .
i. Verify that the function has three stationary points at
1
2
3
x = 0.6504 , x = 0.085 , x = 0.5655 .
0.6504
0.085
0.5655
ii. Test the stationary points to find any minima, maxima or saddle
points.
iii. Find the second-order Taylor series approximations for the function
at each of the stationary points.
2+2
ans =
4
in
iv. Is your answer to part iii. consistent with your contour plot of part
ii.? Explain.
E8.8 Repeat Exercise E8.7 with the following quadratic function:
1 T
F x = --- x 3 2 x + 4 4 x + 2 .
2
2 0
E8.9 Consider the following function:
1 4
2
F x = 1 + x 1 + x 2 + --- x .
4 1
i. Find the quadratic approximation to F x about the point
T
x0 = 1 0
ii. Sketch the contour plot of the quadratic approximation in part i.
E8.10 Consider the following function:
3 2
3
F x = --- x + 2x 1 x 2 + x 2 + 4x 1 + 4x 2 .
2 1
i. Find the quadratic approximation to F x about the point
T
x0 = 1 0 .
ii. Locate the stationary point of the quadratic approximation you
found in part i.
8-38
Exercises
F x = x 1 + 2x 1 x 2 + x 2 + x 1 x 2 .
i. Find the quadratic approximation to F x about the point
T
x0 = 2 1 .
ii. Sketch the contour plot of the quadratic approximation.
E8.13 Recall the function in Problem P8.7. For that function there was no stationary point. It is possible to modify the function, by changing only the d vector, so that a stationary point will exist. Find a new nonzero d vector that
will create a weak minimum.
8-39
Objectives
Performance Optimization
Objectives
9-1
9-2
Steepest Descent
9-2
9-6
9-8
Newtons Method
9-10
Conjugate Gradient
9-15
Summary of Results
9-21
Solved Problems
9-23
Epilogue
9-37
Further Reading
9-38
Exercises
9-39
Objectives
We initiated our discussion of performance optimization in Chapter 8.
There we introduced the Taylor series expansion as a tool for analyzing the
performance surface, and then used it to determine conditions that must be
satisfied by optimum points. In this chapter we will again use the Taylor
series expansion, in this case to develop algorithms to locate the optimum
points. We will discuss three different categories of optimization algorithm:
steepest descent, Newtons method and conjugate gradient. In Chapters
1014 we will apply all of these algorithms to the training of neural networks.
9-1
9 Performance Optimization
(9.1)
x k = x k + 1 x k = k p k ,
(9.2)
or
where the vector p k represents a search direction, and the positive scalar
k is the learning rate, which determines the length of the step.
The algorithms we will discuss in this chapter are distinguished by the
choice of the search direction, p k . We will discuss three different possibilities. There are also a variety of ways to select the learning rate, k , and we
will discuss several of these.
Steepest Descent
When we update our guess of the optimum (minimum) point using Eq.
(9.1), we would like to have the function decrease at each iteration. In other
words,
F xk + 1 F xk .
9-2
(9.3)
Steepest Descent
F x k + 1 = F x k + x k F x k + g k x k ,
(9.4)
x = xk
(9.5)
g k x k = k g k p k 0 .
(9.6)
We will select an k that is small, but greater than zero. This implies:
T
gk pk 0 .
Descent Direction
(9.7)
Any vector p k that satisfies this equation is called a descent direction. The
function must go down if we take a small enough step in this direction. This
brings up another question. What is the direction of steepest descent? (In
what direction will the function decrease most rapidly?) This will occur
when
T
gk pk
(9.8)
is most negative. (We assume that the length of p k does not change, only
the direction.) This is an inner product between the gradient and the direction vector. It will be most negative when the direction vector is the negative of the gradient. (Review our discussion of directional derivatives on
page 8-6.) Therefore a vector that points in the steepest descent direction is
pk = gk .
Steepest Descent
Using this in the iteration of Eq. (9.1) produces the method of steepest descent:
xk + 1 = xk k gk .
Learning Rate
(9.9)
(9.10)
For steepest descent there are two general methods for determining the
learning rate, k . One approach is to minimize the performance index F x
with respect to k at each iteration. In this case we are minimizing along
the line
xk k gk .
9-3
(9.11)
9 Performance Optimization
The other method for selecting k is to use a fixed value (e.g., k = 0.02 ),
or to use variable, but predetermined, values (e.g., k = 1 k ). We will discuss the choice of k in more detail in the following examples.
2
+2
F x = x 1 + 25x 2 ,
(9.12)
(9.13)
F x =
Fx
x1
Fx
x2
2x 1
(9.14)
50x 2
x = x0
1 .
25
(9.15)
Assume that we use a fixed learning rate of = 0.01 . The first iteration of
the steepest descent algorithm would be
x 1 = x 0 g 0 = 0.5 0.01 1 = 0.49 .
0.5
25
0.25
(9.16)
(9.17)
9-4
Steepest Descent
0.5
-0.5
-1
-1
-0.5
0.5
0.5
-0.5
-1
-1
-0.5
0.5
9 Performance Optimization
(9.18)
(9.19)
If we now insert this expression into our expression for the steepest descent
algorithm (assuming a constant learning rate), we obtain
x k + 1 = x k g k = x k Ax k + d
(9.20)
x k + 1 = I A x k d .
(9.21)
or
(9.22)
(9.23)
If we assume that the quadratic function has a strong minimum point, then
its eigenvalues must be positive numbers. Eq. (9.23) then reduces to
2
---- .
i
(9.24)
Since this must be true for all the eigenvalues of the Hessian matrix we
have
2
----------- .
max
(9.25)
The maximum stable learning rate is inversely proportional to the maximum curvature of the quadratic function. The curvature tells us how fast
the gradient is changing. If the gradient is changing too fast we may jump
9-6
Steepest Descent
past the minimum point so far that the gradient at the new location will be
larger in magnitude (but opposite direction) than the gradient at the old location. This will cause the steps to increase in size at each iteration.
2
+2
Lets apply this result to our previous example. The Hessian matrix for that
quadratic function is
A = 2 0 .
0 50
(9.26)
1 = 50 z = 0 .
2
2
1 = 2 z 1 =
0
1
(9.27)
(9.28)
0.5
0.5
-0.5
-0.5
-1
-1
-0.5
0.5
-1
-1
-0.5
0.5
9 Performance Optimization
tor that corresponds to the smallest eigenvalue ( z 1 for our example). In the
end it is the smallest eigenvalue, in combination with the learning rate,
that determines how quickly the algorithm will converge. When there is a
great difference in magnitude between the largest and smallest eigenvalues, the steepest descent algorithm will converge slowly.
To experiment with steepest descent on this quadratic function, use the Neural Network Design Demonstration Steepest Descent for a Quadratic
(nnd9sdq).
(9.29)
To do this for arbitrary functions requires a line search, which we will discuss in Chapter 12. For quadratic functions it is possible to perform the linear minimization analytically. The derivative of Eq. (9.29) with respect to
k , for quadratic F x , can be shown to be
d
T
T
F x k + k p k = F x
p + k p k 2F x
p .
x = xk k
x = xk k
d k
(9.30)
T
F x
p
gk pk
x = xk k
k = -------------------------------------------=
-----------------,
T
T
p k 2F x
pk
pk Ak pk
x = xk
(9.31)
x = xk
(9.32)
Lets apply steepest descent with line minimization to the following quadratic function:
1 T
F x = --- x 2 1 x ,
2
1 2
starting from the initial guess
9-8
(9.33)
Steepest Descent
x0 =
0.8 .
0.25
(9.34)
2x 1 + x 2
(9.35)
x 1 + 2x 2
The search direction for steepest descent is the negative of the gradient.
For the first iteration this will be
p 0 = g 0 = F x
x = x0
= 1.35 .
0.3
(9.36)
From Eq. (9.31), the learning rate for the first iteration will be
1.35
1.35 0.3
0.3
0 = ---------------------------------------------------------------- = 0.413 .
2 1 1.35
1.35 0.3
1 2 0.3
(9.37)
(9.38)
The first five iterations of the algorithm are illustrated in Figure 9.4.
Note that the successive steps of the algorithm are orthogonal. Why does
this happen? First, when we minimize along a line we will always stop at
a point that is tangent to a contour line. Then, since the gradient is orthogonal to the contour line, the next step, which is along the negative of the
gradient, will be orthogonal to the previous step.
We can show this analytically by using the chain rule on Eq. (9.30):
d
d
d
T
F xk + k pk =
F x k + 1 = F x
x + k pk
x = xk + 1 d k k
d k
d k
(9.39)
= F x
9-9
x = xk + 1
pk = gk + 1 pk .
9 Performance Optimization
Therefore at the minimum point, where this derivative is zero, the gradient
is orthogonal to the previous search direction. Since the next search direction is the negative of this gradient, the consecutive search directions must
be orthogonal. (Note that this result implies that when minimizing in any
direction, the gradient at the minimum point will be orthogonal to the
search direction, even if we are not using steepest descent. We will use this
result in our discussion of conjugate directions.)
Contour Plot
x2
0.5
-0.5
-1
-1
-0.5
0
x1
0.5
Newtons Method
The derivation of the steepest descent algorithm was based on the first-order Taylor series expansion (Eq. (9.4)). Newtons method is based on the
second-order Taylor series:
1 T
T
F x k + 1 = F x k + x k F x k + g k x k + --- x k A k x k .
2
(9.40)
9-10
Newtons Method
g k + A k x k = 0 .
(9.41)
x k = A k g k .
Newtons Method
xk + 1 = xk Ak gk .
2
+2
(9.42)
(9.43)
F x = x 1 + 25x 2 .
(9.44)
F x =
F x
x1
F x
x2
2x 1
50x 2
, 2F x = 2 0 .
0 50
(9.45)
(9.46)
1 = 0.5 0.5 = 0 .
25
0.5
0.5
0
(9.47)
This method will always find the minimum of a quadratic function in one
step. This is because Newtons method is designed to approximate a function as quadratic and then locate the stationary point of the quadratic approximation. If the original function is quadratic (with a strong minimum)
it will be minimized in one step. The trajectory of Newtons method for this
problem is given in Figure 9.5.
If the function F x is not quadratic, then Newtons method will not generally converge in one step. In fact, we cannot be sure that it will converge at
all, since this will depend on the function and the initial guess.
9-11
9 Performance Optimization
0.5
-0.5
-1
-1
-0.5
0.5
F x = x 2 x 1 + 8x 1 x 2 x 1 + x 2 + 3 .
(9.48)
We know from Chapter 8 (see Problem P8.5) that this function has three
stationary points:
1
2
3
x = 0.41878 , x = 0.134797 , x = 0.55358 .
0.41878
0.134797
0.55358
(9.49)
The first point is a strong local minimum, the second point is a saddle point,
and the third point is a strong global minimum.
If we apply Newtons method to this problem, starting from the initial
T
guess x 0 = 1.5 0 , our first iteration will be as shown in Figure 9.6. The
graph on the left-hand side of the figure is a contour plot of the original
function. On the right we see the quadratic approximation to the function
at the initial guess.
The function is not minimized in one step, which is not surprising since the
function is not quadratic. However, we do take a step toward the global
minimum, and if we continue for two more iterations the algorithm will
converge to within 0.01 of the global minimum. Newtons method converges
quickly in many applications because analytic functions can be accurately
approximated by quadratic functions in a small neighborhood of a strong
minimum. So as we move closer to the minimum point, Newtons method
will more accurately predict its location. In this case we can see that the
contour plot of the quadratic approximation is similar to the contour plot of
the original function near the initial guess.
9-12
Newtons Method
-1
-1
-2
-2
-1
-2
-2
-1
In Figure 9.7 we see one iteration of Newtons method from the initial guess
T
x 0 = 1.5 0 . In this case we are converging to the local minimum. Clearly Newtons method cannot distinguish between a local minimum and a global minimum, since it approximates the function as a quadratic, and the
quadratic function can have only one minimum. Newtons method, like
steepest descent, relies on the local features of the surface (the first and
second derivatives). It cannot know the global character of the function.
2
-1
-1
-2
-2
-1
-2
-2
-1
In Figure 9.8 we see one iteration of Newtons method from the initial guess
T
x 0 = 0.75 0.75 . Now we are converging toward the saddle point of the
function. Note that Newtons method locates the stationary point of the
quadratic approximation to the function at the current guess. It does not
distinguish between minima, maxima and saddle points. For this problem
the quadratic approximation has a saddle point (indefinite Hessian ma9-13
9 Performance Optimization
trix), which is near the saddle point of the original function. If we continue
the iterations, the algorithm does converge to the saddle point of F x .
2
-1
-1
-2
-2
-1
-2
-2
-1
In each of the cases we have looked at so far the stationary point of the quadratic approximation has been close to a corresponding stationary point of
F x . This is not always the case. In fact, Newtons method can produce
very unpredictable results.
In Figure 9.9 we see one iteration of Newtons method from the initial guess
T
x 0 = 1.15 0.75 . In this case the quadratic approximation predicts a saddle point, however, the saddle point is located very close to the local minimum of F x . If we continue the iterations, the algorithm will converge to
the local minimum. Notice that the initial guess was actually farther away
from the local minimum than it was for the previous case, in which the algorithm converged to the saddle point.
2
-1
-1
-2
-2
-1
-2
-2
-1
9-14
Conjugate Gradient
Ak = Ak = I .
(9.50)
Conjugate Gradient
Quadratic Termination
9 Performance Optimization
contours this produces a zig-zag trajectory of short steps. Perhaps quadratic search directions are not the best choice. Is there a set of search directions that will guarantee quadratic termination? One possibility is
conjugate directions.
Suppose that we wish to locate the minimum of the following quadratic
function:
1 T
T
(9.51)
F x = --- x Ax + d x + c .
2
Conjugate
A set of vectors p k is mutually conjugate with respect to a positive definite Hessian matrix A if and only if
T
p k Ap j = 0
k j.
(9.52)
As with orthogonal vectors, there are an infinite number of mutually conjugate sets of vectors that span a given n -dimensional space. One set of
conjugate vectors consists of the eigenvectors of A . Let 1 2 n and
z 1 z 2 z n be the eigenvalues and eigenvectors of the Hessian matrix.
To see that the eigenvectors are conjugate, replace p k with z k in Eq. (9.52):
T
z k Az j = j z k z j = 0
kj,
(9.53)
where the last equality holds because the eigenvectors of a symmetric matrix are mutually orthogonal. Therefore the eigenvectors are both conjugate and orthogonal. (Can you find a quadratic function where all
orthogonal vectors are also conjugate?)
It is not surprising that we can minimize a quadratic function exactly by
searching along the eigenvectors of the Hessian matrix, since they form the
principal axes of the function contours. (See the discussion on pages 8-13
through 8-19.) Unfortunately this is not of much practical help, since to
find the eigenvectors we must first find the Hessian matrix. We want to
find an algorithm that does not require the computation of second derivatives.
It can be shown (see [Scal85] or [Gill81]) that if we make a sequence of exact linear searches along any set of conjugate directions p 1 p 2 p n ,
then the exact minimum of any quadratic function, with n parameters, will
be reached in at most n searches. The question is How can we construct
these conjugate search directions? First, we want to restate the conjugacy
condition, which is given in Eq. (9.52), without use of the Hessian matrix.
Recall that for quadratic functions
9-16
F x = Ax + d ,
(9.54)
2F x = A .
(9.55)
Conjugate Gradient
(9.56)
(9.57)
k p k Ap j = x k Ap j = g k p j = 0
k j.
(9.58)
Note that we no longer need to know the Hessian matrix. We have restated
the conjugacy conditions in terms of the changes in the gradient at successive iterations of the algorithm. The search directions will be conjugate if
they are orthogonal to the changes in the gradient.
Note that the first search direction, p 0 , is arbitrary, and p 1 can be any vector that is orthogonal to g 0 . Therefore there are an infinite number of sets
of conjugate vectors. It is common to begin the search in the steepest descent direction:
p0 = g0 .
(9.59)
(9.60)
g k 1 g k
k = --------------------------,
T
g k 1 p k 1
(9.61)
gk gk
k = ---------------------T
gk 1 gk 1
9-17
(9.62)
9 Performance Optimization
g k 1 g k
k = ---------------------T
gk 1 gk 1
(9.63)
2
+2
(9.64)
0.8 .
0.25
(9.65)
2x 1 + x 2
(9.66)
x 1 + 2x 2
As with steepest descent, the first search direction is the negative of the
gradient:
p 0 = g 0 = F x
9-18
x = x0
= 1.35 .
0.3
(9.67)
Conjugate Gradient
From Eq. (9.31), the learning rate for the first iteration will be
1.35
1.35 0.3
0.3
0 = ---------------------------------------------------------------- = 0.413 .
2 1 1.35
1.35 0.3
1 2 0.3
(9.68)
(9.69)
x = x1
= 2 1 0.24 = 0.11 .
1 2 0.37
0.5
(9.70)
(9.71)
using the method of Fletcher and Reeves (Eq. (9.62)). The second search direction is then computed from Eq. (9.60):
p 1 = g 1 + 1 p 0 = 0.11 + 0.137 1.35 = 0.295 .
0.5
0.3
0.459
(9.72)
From Eq. (9.31), the learning rate for the second iteration will be
0.295
0.11 0.5
0.459
0.262
1 = ------------------------------------------------------------------------ = ------------- = 0.807 .
0.325
2 1 0.295
0.295 0.459
1 2 0.459
9-19
(9.73)
9 Performance Optimization
x2 = x1 + 1 p1 =
(9.74)
As predicted, the algorithm converges exactly to the minimum in two iterations (since this is a two-dimensional quadratic function), as illustrated in
Figure 9.10. Compare this result with the steepest descent algorithm, as
shown in Figure 9.4. The conjugate gradient algorithm adjusts the second
search direction so that it will pass through the minimum of the function
(center of the function contours), instead of using an orthogonal search direction, as in steepest descent.
1
0.5
-0.5
-1
-1
-0.5
0.5
9-20
Summary of Results
Summary of Results
General Minimization Algorithm
xk + 1 = xk + k pk
or
x k = x k + 1 x k = k p k
x = xk
gk pk
k = --------------T
p k Ap k
gk + 1 pk = 0
Newtons Method
1
xk + 1 = xk Ak gk
Where A k 2F x
9-21
x = xk
9 Performance Optimization
g k 1 g k
gk gk
g k 1 g k
k = -------------------------- or k = ---------------------- or k = ---------------------T
T
T
g k 1 p k 1
gk 1 gk 1
gk 1 gk 1
Where g k F x
9-22
x = xk
and g k = g k + 1 g k .
Solved Problems
Solved Problems
P9.1 We want to find the minimum of the following function:
2
F x = 5x 1 6x 1 x 2 + 5x 2 + 4x 1 + 4x 2 .
i. Sketch a contour plot of this function.
ii. Sketch the trajectory of the steepest descent algorithm on
the contour plot of part (i) if the initial guess is
T
x 0 = 1 2.5 . Assume a very small learning rate is used.
iii. What is the maximum stable learning rate?
i. To sketch the contour plot we first need to find the Hessian matrix. For
quadratic functions we can do this by putting the function into the standard form (see Eq. (8.35)):
1 T
1 T
T
F x = --- x Ax + d x + c = --- x 10 6 x + 4 4 x .
2
2
6 10
From Eq. (8.39) the Hessian matrix is
2F x = A = 10 6 .
6 10
The eigenvalues and eigenvectors of this matrix are
1 = 4 , z 1 = 1 , 2 = 16 , z 2 = 1 .
1
1
From the discussion on quadratic functions in Chapter 8 (see page 8-15) we
know that the function contours are elliptical. The maximum curvature of
F x is in the direction of z 2 , since 2 is larger than 1 , and the minimum
curvature is in the direction of z 1 (the long axis of the ellipses).
Next we need to find the center of the contours (the stationary point). This
occurs when the gradient is equal to zero. From Eq. (8.38) we find
F x = Ax + d = 10 6 x + 4 = 0 .
6 10
4
0
Therefore
9-23
9 Performance Optimization
x = 10 6
6 10
4 = 1 .
4
1
The contours will be elliptical, centered at x , with long axis in the direction of z 1 . The contour plot is shown in Figure P9.1.
ii. We know that the gradient is always orthogonal to the contour line,
therefore the steepest descent trajectory, if we take small enough steps,
will follow a path that is orthogonal to each contour line it intersects. We
can therefore trace the trajectory without performing any computations.
The result is shown in Figure P9.1.
0
-1
-2
-3
-3
-2
-1
Figure P9.1 Contour Plot and Steep. Desc. Trajectory for Problem P9.1
iii. From Eq. (9.25) we know that the maximum stable learning rate for a
quadratic function is determined by the maximum eigenvalue of the Hessian matrix:
2
----------- .
max
The maximum eigenvalue for this problem is 2 = 16 , therefore for stability
2
------ = 0.125 .
16
This result is verified experimentally in Figure P9.2, which shows the
steepest descent trajectories when the learning rate is just below
( = 0.12 ) and just above ( = 0.13 ) the maximum stable value.
9-24
Solved Problems
-1
-1
-2
-2
-3
-3
-2
-1
-3
-3
-2
-1
x0 = 0 2 .
In Problem P9.1 we found the gradient of the function to be
F x = Ax + d = 10 6 x + 4 .
6 10
4
If we evaluate this at x 0 , we find
g 0 = F x 0 = Ax 0 + d = 10 6 0 + 4 = 16 .
6 10 2
4
16
Therefore the first search direction is
p 0 = g 0 = 16 .
16
To minimize along a line, for a quadratic function, we can use Eq. (9.31):
0 =
T
g0 p0
--------------T
p 0 Ap 0
16
16 16
16
512
= -------------------------------------------------------- = ------------ = 0.0625 .
8192
10 6 16
16 16
6 10 16
9-25
9 Performance Optimization
x1 = x0 0 g0 =
-1
-2
-3
-3
-2
-1
Figure P9.3 Steepest Descent with Linear Minimization for Problem P9.2
This is an unusual case, where the steepest descent algorithm located the
minimum in one iteration. Notice that this occurred because the initial
guess was located in the direction of one of the eigenvectors of the Hessian
matrix, with respect to the minimum point. For those cases where every direction is an eigenvector, the steepest descent algorithm will always locate
the minimum in one iteration. What would this imply about the eigenvalues of the Hessian matrix?
P9.3 Recall Problem P8.6, in which we derived a performance index for
a linear neural network. The network, which is displayed again in
Figure P9.4, was to be trained for the following input/output pairs:
p 1 = 2 t 1 = 0.5 p 2 = 1 t 2 = 0
The performance index for the network was defined to be
2
F x = t1 a1 x + t2 a2 x ,
9-26
Solved Problems
Linear Neuron
Input
1
a = purelin (wp + b)
Figure P9.4 Linear Network for Problems P9.3 and P8.6
i. In Problem P8.6 we found that the performance index could be written
in quadratic form:
1 T
T
F x = --- x Ax + d x + c ,
2
where
T
c = t t = 0.5 0 0.5 = 0.25 ,
0
T
d = 2 G t = 2 2 1 0.5 = 2 ,
1 1
0
1
T
A = 2G G = 10 2 .
2 4
The gradient at x 0 is
g 0 = F x 0 = Ax 0 + d = 10 2 1 + 2 = 10 .
2 4 1
1
5
9-27
9 Performance Optimization
The remaining iterations are displayed in Figure P9.5. The algorithm conT
verges to the minimum point x = 0.167 0.167 . Therefore the optimal
value for both the weight and the bias of this network is 0.167 .
2
-1
-2
-2
-1
Figure P9.5 Steepest Descent Trajectory for Problem P9.3 with = 0.05
Note that in order to train this network we needed to know all of the input/
output pairs. We then performed iterations of the steepest descent algorithm until convergence was achieved. In Chapter 10 we will introduce an
adaptive algorithm, based on steepest descent, for training linear networks. With this adaptive algorithm the network parameters are updated
after each input/output pair is presented. We will show how this allows the
network to adapt to a changing environment.
ii. The maximum eigenvalue of the Hessian matrix for this problem is
1 = 10.6 (see Problem P8.6), therefore for stability
2
---------- = 0.1887 .
10.6
9-28
Solved Problems
x 1 x 1 + 2x 2 + 4
F x =
F x
x1
F x
x2
= e
x 1 x 1 + 2x 2 + 4
2x 1 1
4x 2
2F x =
Fx
x 1 x 2
Fx
2
x1
Fx
x 2 x 1
= e
2
2
x2
x 1 x 1 + 2x 2 + 4
Fx
4x 1 4x 1 + 3 2x 1 1 4x 2
2
2x 1 1 4x 2
16x 2 + 4
x = x0
0.163 10
1.302 10
,
6
and
A 0 = 2F x
x = x0
0.049 10
0.130 10 .
7
7
0.130 10 1.107 10
Therefore the first iteration of Newtons method, from Eq. (9.43), will be
9-29
9 Performance Optimization
x1 = x0 A0
g 0 = 1 0.049 10 0.130 10
7
7
2
0.130 10 1.107 10
0.163 10
1.302 10
0.971
1.886
=
6
How close is this to the true minimum point of F x ? First, note that the
exponent of F x is a quadratic function:
1 T
1 T
2
2
T
x 1 x 1 + 2x 2 + 4 = --- x Ax + d x + c = --- x 2 0 x + 1 0 x + 4 .
2
2
0 4
The minimum point of F x will be the same as the minimum point of the
exponent, which is
1
x = A d = 2 0
0 4
1 = 0.5 .
0
0
Therefore Newtons method has taken only a very small step toward the
true minimum point. This is because F x cannot be accurately approxiT
-1
-2
-2
-1
9-30
Solved Problems
P9.5 Compare the performance of Newtons method and steepest descent on the following function:
1 T
F x = --- x 1 1 x .
2
1 1
Start from the initial guess
x0 = 1 .
0
Recall that this function is an example of a stationary valley (see Eq. (8.59)
and Figure 8.9). The gradient is
1 1 x
1 1
F x = Ax + d =
and the Hessian matrix is
2F x = A =
1 1 .
1 1
xk + 1 = xk Ak gk .
Note, however, that we cannot actually perform this algorithm, because the
Hessian matrix is singular. We know from our discussion of this function
in Chapter 8 that this function does not have a strong minimum, but it does
have a weak minimum along the line x 1 = x 2 .
What about steepest descent? If we start from the initial guess, with learning rate = 0.1 , the first two iterations will be
x 1 = x 0 g 0 = 1 0.1 1 = 0.9 ,
0
1
0.1
x 2 = x 1 g 1 = 0.9 0.1 0.8 = 0.82 .
0.1
0.8
0.18
9-31
9 Performance Optimization
The complete trajectory is shown in Figure P9.7. This is a case where the
steepest descent algorithm performs better than Newtons method. Steepest descent converges to a minimum point (weak minimum), while Newtons method fails to converge. In Chapter 12 we will discuss a technique
that combines steepest descent with Newtons method, to overcome the
problem of singular (or almost singular) Hessian matrices.
1
0.5
-0.5
-1
-1
-0.5
0.5
Figure P9.7 Steepest Descent Trajectory for Problem P9.5 with = 0.1
P9.6 Consider the following function:
3
2 2
F x = x1 + x1 x2 x1 x2
i. Perform one iteration of Newtons method from the initial
T
guess x 0 = 1 1 .
ii. Find the second-order Taylor series expansion of F x about
x 0 . Is this quadratic function minimized at the point x 1
found in part (i)? Explain.
i.
The gradient of F x is
F x =
9-32
Fx
x1
Fx
x2
3x 1 + x 2 2x 1 x 2
2
x 1 2x 1 x 2
Solved Problems
2F x =
6x 1 2x 2 1 4x 1 x 2
1 4x 1 x 2
2x 1
A 0 = 2F x
x = x0
x = x0
2 ,
1
4 3 .
3 2
2 = 0.5882 .
1
1.1176
F x 1 + 2 1 x 1 + --- x 1 4 3 x 1 .
2
1
1
1 3 2
9-33
9 Performance Optimization
-1
-1
-2
-2
-1
-2
-2
-1
P9.7 Repeat Problem P9.3 (i) using the conjugate gradient algorithm.
Recall that the function to be minimized was
1 T
F x = 0.25 + 2 1 x + --- x 10 2 x .
2
2 4
The gradient at x 0 is
g 0 = F x 0 = Ax 0 + d = 10 2 1 + 2 = 10 .
2 4 1
1
5
The first search direction is then
p 0 = g 0 = 10 .
5
To minimize along a line, for a quadratic function, we can use Eq. (9.31):
9-34
Solved Problems
0 =
T
g0 p0
--------------T
p 0 Ap 0
10
10 5
5
125
= ----------------------------------------------------- = ------------ = 0.0962 .
1300
10 2 10
10 5
2 4 5
x = x1
= 10 2 0.038 + 2 = 0.577 .
2 4 0.519
1
1.154
From Eq. (9.31), the learning rate for the second iteration will be
0.444
0.577 1.154
1.220
1.664
1 = --------------------------------------------------------------------------- = ---------------- = 0.2889 .
5.758
10 2 0.444
0.444 1.220
2 4 1.220
The second step of conjugate gradient is therefore
9-35
9 Performance Optimization
-1
-2
-2
-1
aj pj
= 0,
j=0
pk A aj pj =
T
j=0
n1
a j pk Apj
T
= a k p k Ap k = 0 ,
j=0
where the second equality comes from the definition of conjugate vectors in
Eq. (9.52). If A is positive definite (a unique strong minimum exists), then
T
p k Ap k must be strictly positive. This implies that a k must be zero for all k .
Therefore conjugate directions must be independent.
9-36
Epilogue
Epilogue
In this chapter we have introduced three different optimization algorithms:
steepest descent, Newtons method and conjugate gradient. The basis for
these algorithms is the Taylor series expansion. Steepest descent is derived
by using a first-order expansion, whereas Newtons method and conjugate
gradient are designed for second-order (quadratic) functions.
Steepest descent has the advantage that it is very simple, requiring calculation only of the gradient. It is also guaranteed to converge to a stationary
point if the learning rate is small enough. The disadvantage of steepest descent is that training times are generally longer than for other algorithms.
This is especially true when the eigenvalues of the Hessian matrix, for quadratic functions, have a wide range of magnitudes.
Newtons method is generally much faster than steepest descent. For quadratic functions it will locate a stationary point in one iteration. One disadvantage is that it requires calculation and storage of the Hessian matrix,
as well as its inverse. In addition, the convergence properties of Newtons
method are quite complex. In Chapter 12 we will introduce a modification
of Newtons method that overcomes some of the disadvantages of the standard algorithm.
The conjugate gradient algorithm is something of a compromise between
steepest descent and Newtons method. It will locate the minimum of a quadratic function in a finite number of iterations, but it does not require calculation and storage of the Hessian matrix. It is well suited to problems
with large numbers of parameters, where it is impractical to compute and
store the Hessian.
In later chapters we will apply each of these optimization algorithms to the
training of neural networks. In Chapter 10 we will demonstrate how an approximate steepest descent algorithm, Widrow-Hoff learning, can be used
to train linear networks. In Chapter 11 we generalize Widrow-Hoff learning to train multilayer networks. In Chapter 12 the conjugate gradient algorithm, and a variation of Newtons method, are used to speed up the
training of multilayer networks.
9-37
9 Performance Optimization
Further Reading
[Batt92]
[Brog91]
[Gill81]
P. E. Gill, W. Murray and M. H. Wright, Practical Optimization, New York: Academic Press, 1981.
As the title implies, this text emphasizes the practical implementation of optimization algorithms. It provides motivation for the optimization methods, as well as details of
implementation that affect algorithm performance.
[Himm72]
[Scal85]
9-38
Exercises
Exercises
E9.1 In Problem P9.1 we found the maximum stable learning rate for the steepest descent algorithm when applied to a particular quadratic function. Will
the algorithm always diverge when a larger learning rate is used, or are
there any conditions for which the algorithm will still converge?
E9.2 We want to find the minimum of the following function:
1 T
F x = --- x 6 2 x + 1 1 x .
2
2 6
i. Sketch a contour plot of this function.
ii. Sketch the trajectory of the steepest descent algorithm on the conT
tour plot of part (i), if the initial guess is x 0 = 0 0 . Assume a very
small learning rate is used.
iii. Perform two iterations of steepest descent with learning rate
= 0.1 .
iv. What is the maximum stable learning rate?
v. What is the maximum stable learning rate for the initial guess given in part (ii)? (See Exercise E9.1.)
2+2
ans =
4
vi. Write a MATLAB M-file to implement the steepest descent algorithm for this problem, and use it to check your answers to parts (i).
through (v).
E9.3 For the quadratic function
2
F x = x 1 + 2x 2 ,
i. Find the minimum of the function along the line
x = 1 + 1 .
1
2
ii. Verify that the gradient of F x at the minimum point from part (i)
is orthogonal to the line along which the minimization occurred.
9-39
9 Performance Optimization
2+2
ans =
4
E9.4 For the functions given in Exercise E8.3 perform two iterations of the
steepest descent algorithm with linear minimization, starting from the iniT
tial guess x 0 = 1 1 . Write MATLAB M-files to check your answer.
E9.5 Consider the following function:
2
F x = 1 + x 1 + x 2 5 1 + 3x 1 2x 2 .
i. Perform one iteration of Newtons method, starting from the initial
T
guess x 0 = 10 10 .
T
F x = x1 + x2 + 2 x2 1
9-40
Exercises
E9.10 Recall the function presented in Exercise E8.5. Write MATLAB M-files to
implement the steepest descent algorithm and Newtons method for that
function. Test the performance of the algorithms for various initial guesses.
E9.11 Repeat Exercise E9.4 using the conjugate gradient algorithm. Use each of
the three methods (Eq. (9.61)Eq. (9.63)) at least once.
9-41
9 Performance Optimization
9-42
Objectives
10
Widrow-Hoff Learning
Objectives
10-1
10-2
ADALINE Network
10-2
Single ADALINE
10-3
10-4
LMS Algorithm
10-7
Analysis of Convergence
10-9
Adaptive Filtering
10-13
10-15
Echo Cancellation
10-21
Summary of Results
10-22
Solved Problems
10-24
Epilogue
10-40
Further Reading
10-41
Exercises
10-42
Objectives
In the previous two chapters we laid the foundation for performance learning, in which a network is trained to optimize its performance. In this chapter we apply the principles of performance learning to a single-layer linear
neural network.
Widrow-Hoff learning is an approximate steepest descent algorithm, in
which the performance index is mean square error. This algorithm is important to our discussion for two reasons. First, it is widely used today in
many signal processing applications, several of which we will discuss in
this chapter. In addition, it is the precursor to the backpropagation algorithm for multilayer networks, which is presented in Chapter 11
10
10-1
10 Widrow-Hoff Learning
ADALINE Network
The ADALINE network is shown in Figure 10.1. Notice that it has the
same basic structure as the perceptron network we discussed in Chapter 4.
The only difference is that it has a linear transfer function.
10-2
ADALINE Network
Linear Neuron
Input
p
Rx1
1
R
Sx1
SxR
Sx1
b
Sx1
a = purelin (Wp + b)
Figure 10.1 ADALINE Network
The output of the network is given by
a = purelin Wp + b = Wp + b .
(10.1)
Recall from our discussion of the perceptron network that the ith element
of the network output vector can be written
T
a i = purelin n i = purelin iw p + b i = iw p + b i ,
(10.2)
w i 2
iw
w i R
(10.3)
Single ADALINE
To simplify our discussion, lets consider a single ADALINE with two inputs. The diagram for this network is shown in Figure 10.2.
The output of the network is given by
T
a = purelin n = purelin 1w p + b = 1w p + b
T
= 1w p + b = w 1 1 p 1 + w 1 2 p 2 + b .
10-3
(10.4)
10
10 Widrow-Hoff Learning
Inputs
Two-Input Neuron
p1
w1,1
p2
w1,2
1
a = purelin (Wp + b)
Figure 10.2 Two-Input Linear Neuron
You may recall from Chapter 4 that the perceptron has a decision boundary, which is determined by the input vectors for which the net input n is
zero. Now, does the ADALINE also have such a boundary? Clearly it does.
T
If we set n = 0 then 1w p + b = 0 specifies such a line, as shown in Figure
10.3.
p2
a<0
a>0
-b/w1,2
w Tp + b = 0
p1
-b/w1,1
{p 1, t 1} { p 2, t 2} {p Q, tQ} ,
(10.5)
1w
(10.6)
b
Similarly, we include the bias input 1 as a component of the input vector
z = p .
1
(10.7)
= 1w p + b ,
(10.8)
can be written as
T
a = x z.
Mean Square Error
(10.9)
F x = E e = E t a = E t xTz ,
(10.10)
where the expectation is taken over all sets of input/target pairs. (Here we
use E to denote expected value. We use a generalized definition of expectation, which becomes a time-average for deterministic signals. See
[WiSt85].) We can expand this expression as follows:
2
10
F x = E t 2tx T z + x T zz x
2
= E t 2x T E tz + x T E zz x .
10-5
(10.11)
10 Widrow-Hoff Learning
F x = c 2x h + x Rx ,
(10.12)
where
2
c = E t , h = E tz and R = E zz .
Correlation Matrix
(10.13)
Here the vector h gives the cross-correlation between the input vector and
its associated target, while R is the input correlation matrix. The diagonal
elements of this matrix are equal to the mean square values of the elements
of the input vectors.
Take a close look at Eq. (10.12), and compare it with the general form of the
quadratic function given in Eq. (8.35) and repeated here:
1 T
T
F x = c + d x + --- x Ax .
2
(10.14)
We can see that the mean square error performance index for the ADALINE network is a quadratic function, where
d = 2h and A = 2R .
(10.15)
This is a very important result, because we know from Chapter 8 that the
characteristics of the quadratic function depend primarily on the Hessian
matrix A . For example, if the eigenvalues of the Hessian are all positive,
then the function will have one unique global minimum.
In this case the Hessian matrix is twice the correlation matrix R , and it
can be shown that all correlation matrices are either positive definite or
positive semidefinite, which means that they can never have negative
eigenvalues. We are left with two possibilities. If the correlation matrix has
only positive eigenvalues, the performance index will have one unique global minimum (see Figure 8.7). If the correlation matrix has some zero
eigenvalues, the performance index will either have a weak minimum (see
Figure 8.9) or no minimum (see Problem P8.7), depending on the vector
d = 2h .
Now lets locate the stationary point of the performance index. From our
previous discussion of quadratic functions we know that the gradient is
1 T
T
F x = c + d x + --- x Ax = d + Ax = 2h + 2Rx .
(10.16)
(10.17)
LMS Algorithm
(10.18)
It is worth noting here that the existence of a unique solution depends only
on the correlation matrix R . Therefore the characteristics of the input vectors determine whether or not a unique solution exists.
LMS Algorithm
Now that we have analyzed our performance index, the next step is to design an algorithm to locate the minimum point. If we could calculate the
statistical quantities h and R , we could find the minimum point directly
from Eq. (10.18). If we did not want to calculate the inverse of R , we could
use the steepest descent algorithm, with the gradient calculated from Eq.
(10.16). In general, however, it is not desirable or convenient to calculate h
and R . For this reason we will use an approximate steepest descent algorithm, in which we use an estimated gradient.
The key insight of Widrow and Hoff was that they could estimate the mean
square error F x by
2
2
F x = t k a k = e k ,
(10.19)
where the expectation of the squared error has been replaced by the
squared error at iteration k . Then, at each iteration we have a gradient estimate of the form:
2
F x = e k .
Stochastic Gradient
(10.20)
e k
e k
2
e k j = --------------- = 2e k ------------- for j = 1 2 R ,
w 1 j
w 1 j
(10.21)
10
and
2
e k
e k
2
e k R + 1 = --------------- = 2e k ------------- .
b
b
10-7
(10.22)
10 Widrow-Hoff Learning
Now consider the partial derivative terms at the ends of these equations.
First evaluate the partial derivative of e k with respect to the weight w 1 j :
t k a k
e k
T
------------- = ---------------------------------- =
t k 1w p k + b
w 1 j
w 1 j
w 1 j
R
t k w 1 i p i k + b
w 1 j
i=1
(10.23)
where p i k is the ith element of the input vector at the kth iteration. This
simplifies to
e k
------------- = p j k .
w 1 j
(10.24)
(10.25)
Note that p j k and 1 are the elements of the input vector z , so the gradient of the squared error at iteration k can be written
2
F x = e k = 2e k z k .
(10.26)
Now we can see the beauty of approximating the mean square error by the
single error at iteration k , as in Eq. (10.19). To calculate this approximate
gradient we need only multiply the error times the input.
This approximation to F x can now be used in the steepest descent algorithm. From Eq. (9.10) the steepest descent algorithm, with constant learning rate, is
x k + 1 = x k F x
x = xk
(10.27)
(10.28)
or
1w k
+ 1 = 1w k + 2e k p k ,
(10.29)
and
b k + 1 = b k + 2e k .
10-8
(10.30)
Analysis of Convergence
These last two equations make up the least mean square (LMS) algorithm.
This is also referred to as the delta rule or the Widrow-Hoff learning algorithm.
The preceding results can be modified to handle the case where we have
multiple outputs, and therefore multiple neurons, as in Figure 10.1. To update the ith row of the weight matrix use
iw k
+ 1 = iw k + 2e i k p k ,
(10.31)
where e i k is the ith element of the error at iteration k . To update the ith
element of the bias we use
b i k + 1 = b i k + 2e i k .
LMS Algorithm
(10.32)
(10.33)
b k + 1 = b k + 2e k .
(10.34)
and
Note that the error e and the bias b are now vectors.
Analysis of Convergence
The stability of the steepest descent algorithm was investigated in Chapter
9. There we found that the maximum stable learning rate for quadratic
functions is 2 max , where max is the largest eigenvalue of the Hessian
matrix. Now we want to investigate the convergence of the LMS algorithm,
which is approximate steepest descent. We will find that the result is the
same.
To begin, note that in the LMS algorithm, Eq. (10.28), x k is a function only
of z k 1 z k 2 z 0 . If we assume that successive input vectors are
statistically independent, then x k is independent of z k . We will show in
the following development that for stationary input processes meeting this
condition, the expected value of the weight vector will converge to
x = R h .
1
(10.35)
2
10-9
(10.36)
10
10 Widrow-Hoff Learning
(10.37)
E x k + 1 = E x k + 2 E t k z k E x k z k z k .
T
(10.38)
E x k + 1 = E x k + 2 E t k z k E z k z k x k .
(10.39)
Since x k is independent of z k :
E x k + 1 = E x k + 2 h RE x k .
(10.40)
(10.41)
(10.42)
for all i ,
(10.43)
or
0 1 max .
(10.44)
Note that this condition is equivalent to the condition we derived in Chapter 9 for the steepest descent algorithm, although in that case we were using the eigenvalues of the Hessian matrix A . Now we are using the
eigenvalues of the input correlation matrix R . (Recall that A = 2R .)
If this condition on stability is satisfied, the steady state solution is
E x ss = I 2R E x ss + 2h ,
(10.45)
E x ss = R h = x .
(10.46)
or
1
10-10
Analysis of Convergence
Thus the LMS solution, obtained by applying one input vector at a time, is
the same as the minimum mean square error solution of Eq. (10.18).
2
+2
To test the ADALINE network and the LMS algorithm consider again the
apple/orange recognition problem originally discussed in Chapter 3. For
simplicity we will assume that the ADALINE network has a zero bias.
The LMS weight update algorithm of Eq. (10.29) will be used to calculate
the new weights at each step in the network training:
T
W k + 1 = W k + 2e k p k .
(10.47)
First lets compute the maximum stable learning rate . We can get such
a value by finding the eigenvalues of the input correlation matrix. Recall
that the orange and apple vectors and their associated targets are
p1 = 1 t1 = 1
=
t
p
2
1 .
1 2
(10.48)
If we assume that the input vectors are generated randomly with equal
probability, we can compute the input correlation matrix:
1
1
T
T
T
R = E pp = --- p 1 p 1 + --- p 2 p 2
2
2
1
1
1 0 1
1
1
= --- 1 1 1 1 + --- 1 1 1 1 = 0 1 0 .
2
2
1
1
1 0 1
(10.49)
2 = 0.0
3 = 2.0 .
(10.50)
(10.51)
To be conservative we will pick = 0.2 . (Note that in practical applications it might not be practical to calculate R , and could be selected by
trial and error. Other techniques for choosing are given in [WiSt85].)
We will start, arbitrarily, with all the weights set to zero, and then will apply inputs p 1 , p 2 , p 1 , p 2 , etc., in that order, calculating the new weights
after each input is presented. (The presentation of the weights in alternat-
10-11
10
10 Widrow-Hoff Learning
(10.52)
e 0 = t 0 a 0 = t1 a 0 = 1 0 = 1 .
(10.53)
and
W 1 = W 0 + 2e 0 p 0
T
1
= 0 0 0 + 2 0.2 1 1 = 0.4 0.4 0.4 .
1
(10.54)
According to plan, we will next present the apple, p 2 , and its target of 1:
a 1 = W 1 p 1 = W 1 p 2 = 0.4 0.4 0.4
1
1 = 0.4 ,
1
(10.55)
(10.56)
W 2 = W 1 + 2e 1 p 1
T
1
= 0.4 0.4 0.4 + 2 0.2 1.4 1 = 0.16 0.96 0.16 .
1
(10.57)
10-12
(10.58)
Adaptive Filtering
The error is
e 2 = t 2 a 2 = t 1 a 2 = 1 0.64 = 0.36 .
(10.59)
(10.60)
(10.61)
Compare this result with the result of the perceptron learning rule in
Chapter 4. You will notice that the ADALINE has produced the same decision boundary that we designed in Chapter 3 for the apple/orange problem.
This boundary falls halfway between the two reference patterns. The perceptron rule did not produce such a boundary. This is because the perceptron rule stops as soon as the patterns are correctly classified, even though
some patterns may be close to the boundaries. The LMS algorithm minimizes the mean square error. Therefore it tries to move the decision boundaries as far from the reference patterns as possible.
Adaptive Filtering
As we mentioned at the beginning of this chapter, the ADALINE network
has the same major limitation as the perceptron network; it can only solve
linearly separable problems. In spite of this, the ADALINE has been much
more widely used than the perceptron network. In fact, it is safe to say that
it is one of the most widely used neural networks in practical applications.
One of the major application areas of the ADALINE has been adaptive filtering, where it is still used extensively. In this section we will demonstrate
an adaptive filtering example.
Tapped Delay Line
In order to use the ADALINE network as an adaptive filter, we need to introduce a new building block, the tapped delay line. A tapped delay line
with R outputs is shown in Figure 10.4.
The input signal enters from the left. At the output of the tapped delay line
we have an R -dimensional vector, consisting of the input signal at the current time and at delays of from 1 to R 1 time steps.
10
10-13
10 Widrow-Hoff Learning
y(k)
p1(k) = y(k)
p2(k) = y(k - 1)
D
D
pR(k) = y(k - R + 1)
If we combine a tapped delay line with an ADALINE network, we can create an adaptive filter, as is shown in Figure 10.5. The output of the filter is
given by
R
a k = purelin Wp + b =
w 1 i y k i + 1 + b .
i=1
Inputs
ADALINE
y(k)
w1,1
w1,2
SxR
n(k)
a(k)
w1,R
10-14
(10.62)
Adaptive Filtering
If you are familiar with digital signal processing, you will recognize the network of Figure 10.5 as a finite impulse response (FIR) filter [WiSt85]. It is
beyond the scope of this text to review the field of digital signal processing,
but we can demonstrate the usefulness of this adaptive filter through a
simple, but practical, example.
Restored Signal
e
Contaminated
Signal
+
Contaminating
Noise
"Error"
Adaptively Filtered
Noise to Cancel
Contamination
Noise Path
Filter
Graduate
Student
v
Adaptive
Filter
60-Hz
Noise Source
Adaptive Filter Adjusts to Minimize Error (and in doing
this removes 60-Hz noise from contaminated signal)
10-15
10
10 Widrow-Hoff Learning
a will be close to the contaminating noise m . In this way the error e will
be close to the original uncontaminated EEG signal s .
In this simple case of a single sine wave noise source, a neuron with two
weights and no bias is sufficient to implement the filter. The inputs to the
filter are the current and previous values of the noise source. Such a twoinput filter can attenuate and phase-shift the noise v in the desired way.
The filter is shown in Figure 10.7.
Inputs
ADALINE
w1,1
v(k)
w1,2
SxR
n(k)
a(k)
R = zz and h = E tz .
(10.63)
In our case the input vector is given by the current and previous values of
the noise source:
z k =
vk ,
v k 1
(10.64)
while the target is the sum of the current signal and filtered noise:
t k = s k + mk .
(10.65)
E v k v k 1 ,
2
E v k 1 v k E v k 1
10-16
Ev k
(10.66)
Adaptive Filtering
and
E s k + m k v k .
E s k + m k v k 1
h =
(10.67)
To obtain specific values for these two quantities we must define the noise
signal v , the EEG signal s and the filtered noise m . For this exercise we
will assume: the EEG signal is a white (uncorrelated from one time step to
the next) random signal uniformly distributed between the values -0.2 and
+0.2, the noise source (60-Hz sine wave sampled at 180 Hz) is given by
2k
v k = 1.2 sin --------- ,
3
(10.68)
and the filtered noise that contaminates the EEG is the noise source attenuated by a factor of 10 and shifted in phase by 2 :
2k
m k = 0.12 sin --------- + --- .
3
2
(10.69)
2
21
E v k = 1.2 --3
-
sin -------3
2k
(10.70)
E v k 1 = E v k = 0.72 ,
(10.71)
k=1
2
1
E v k v k 1 = --3
1.2
2k
2 k 1
sin --------- 1.2 sin -----------------------
3
3
k=1
2
2
= 1.2 0.5 cos ------ = 0.36
3
(10.72)
0.72 0.36 .
0.36 0.72
(10.73)
The terms of h can be found in a similar manner. We will consider the top
term in Eq. (10.67) first:
E s k + m k v k = E s k v k + E m k v k .
10-17
(10.74)
10
10 Widrow-Hoff Learning
Here the first term on the right is zero because s k and v k are independent and zero mean. The second term is also zero:
3
1
E m k v k = --3
0.12
2k
2k
sin --------- + --- 1.2 sin --------- = 0
3
2
3
(10.75)
k=1
(10.76)
As with the first element of h , the first term on the right is zero because
s k and v k 1 are independent and zero mean. The second term is evaluated as follows:
3
0.12
1
E m k v k 1 = --3
2 k 1
2k
sin --------- + --- 1.2 sin -----------------------
3
2
3
k=1
(10.77)
= 0.0624 .
Thus, h is
h =
0
.
0.0624
(10.78)
The minimum mean square error solution for the weights is given by Eq.
(10.18):
x = R h =
0.72 0.36
0.36 0.72
0
= 0.0578 .
0.0624
0.1156
(10.79)
Now, what kind of error will we have at the minimum solution? To find this
error recall Eq. (10.12):
T
F x = c 2x h + x Rx .
(10.80)
c = E t k= E s k + m k
2
= E s k + 2E s k m k + E m k .
10-18
(10.81)
Adaptive Filtering
The middle term is zero because s k and m k are independent and zero
mean. The first term, the mean squared value of the random signal, can be
calculated as follows:
0.2
1
E s k = ------0.4
2
1
2
3
s ds = ---------------s
3 0.4
0.2
= 0.0133 .
(10.82)
2
0.12 sin -----3- + --2- = 0.0072 ,
k=1
(10.83)
0.2
0.2
1
E m k = --3
2
so that
c = 0.0133 + 0.0072 = 0.0205 .
(10.84)
Substituting x , h and R into Eq. (10.80), we find that the minimum mean
square error is
F x = 0.0205 2 0.0072 + 0.0072 = 0.0133 .
(10.85)
The minimum mean square error is the same as the mean square value of
the EEG signal. This is what we expected, since the error of this adaptive
noise canceller is in fact the reconstructed EEG signal.
Figure 10.8 illustrates the trajectory of the LMS algorithm in the weight
space with learning rate = 0.1 . The system weights w 1 1 and w 1 2 in this
simulation were initialized arbitrarily to 0 and -2, respectively. You can
see from this figure that the LMS trajectory looks like a noisy version of
steepest descent.
2
w 1 2
-1
-2
-2
-1
w 1 1
Figure 10.8 LMS Trajectory for = 0.1
10-19
10
10 Widrow-Hoff Learning
Note that the contours in this figure reflect the fact that the eigenvalues
and eigenvectors of the Hessian matrix ( A = 2R ) are
1 = 2.16 , z 1 = 0.7071 , 2 = 0.72 , z 2 = 0.7071 .
0.7071
0.7071
(10.86)
(Refer back to our discussion in Chapter 8 on the eigensystem of the Hessian matrix.)
If the learning rate is decreased, the LMS trajectory is smoother than that
shown in Figure 10.8, but the learning proceeds more slowly. If the learning rate is increased, the trajectory is more jagged and oscillatory. In fact,
as noted earlier in this chapter, if the learning rate is increased too much
the system does not converge at all. The maximum stable learning rate is
2 2.16 = 0.926 .
In order to judge the performance of our noise canceller, consider Figure
10.9. This figure illustrates how the filter adapts to cancel the noise. The
top graph shows the restored and original EEG signals. At first the restored signal is a poor approximation of the original EEG signal. It takes
about 0.2 second (with = 0.1 ) for the filter to adjust to give a reasonable
restored signal. The mean square difference between the original and restored signal over the last half of the experiment was 0.002. This compares
favorably with the signal mean square value of 0.0133. The difference between the original and restored signal is shown in the lower graph.
Original and Restored EEG Signals
2
1
0
-1
-2
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0.5
0.4
0.45
0.5
2
1
0
-1
-2
0
0.05
0.1
0.15
0.2
0.25
Time
0.3
0.35
10-20
Adaptive Filtering
You might wonder why the error does not go to zero. This is because the
LMS algorithm is approximate steepest descent; it uses an estimate of the
gradient, not the true gradient, to update the weights. The estimate of the
gradient is a noisy version of the true gradient. This will cause the weights
to continue to change slightly, even after the mean square error is at the
minimum point. You can see this effect in Figure 10.8.
To experiment with the use of this adaptive noise cancellation filter, use the
MATLAB Neural Network Design Demonstration Adaptive Noise Cancellation (nnd10nc). A more complex noise source and actual EEG data are used
in the Demonstration Electroencephalogram Noise Cancellation (nnd10eeg).
Echo Cancellation
Another very important practical application of adaptive noise cancellation
is echo cancellation. Echoes are common in long distance telephone lines
because of impedance mismatch at the hybrid device that forms the junction between the long distance line and the customers local line. You may
have experienced this effect on international telephone calls.
Figure 10.10 illustrates how an adaptive noise cancellation filter can be
used to reduce these echoes [WiWi85]. At the end of the long distance line
the incoming signal is sent to an adaptive filter, as well as to the hybrid device. The target output of the filter is the output of the hybrid. The filter
thus tries to cancel the part of the hybrid output that is correlated with the
input signal the echo.
Phone
Hybrid
Adaptive
Filter
Adaptive
Filter
Transmission
Line
Hybrid
Phone
Transmission
Line
10
10-21
10 Widrow-Hoff Learning
Summary of Results
ADALINE
Input
Linear Neuron
Rx1
SxR
Sx1
Sx1
b
Sx1
a = purelin (Wp + b)
F x = E e = E t a = E t xTz
T
F x = c 2x h + x Rx ,
2
c = E t , h = E tz and R = E zz
Unique minimum, if it exists, is x = R h .
1
Where x =
1w
and z = p .
1
LMS Algorithm
T
W k + 1 = W k + 2e k p k
b k + 1 = b k + 2e k
Convergence Point
x = R h
1
10-22
Summary of Results
p1(k) = y(k)
p2(k) = y(k - 1)
D
D
pR(k) = y(k - R + 1)
ADALINE
y(k)
w1,1
w1,2
SxR
n(k)
a(k)
w1,R
a k = purelin Wp + b =
w 1 i y k i + 1 + b
i=1
10-23
10
10 Widrow-Hoff Learning
Solved Problems
P10.1 Consider the ADALINE filter in Figure P10.1.
Inputs
ADALINE
y(k)
w1,1
w1,2
SxR
n(k)
a(k)
w1,3
w 1 2 = 1
w 1 3 = 3 ,
10-24
Solved Problems
y0
5
a 0 = Wp 0 = w 1 1 w 1 2 w 1 3 y 1 = 2 1 3 0 = 10 .
y 2
0
Similarly, one can calculate the next outputs as
a 1 = Wp 1 = 2 1 3
4
5 = 13
0
0
a 2 = Wp 2 = 2 1 3 4 = 19
5
a 3 = Wp 3 = 2 1 3
0
0
=
12
a
=
Wp
=
,
0
2 1 3 0 = 0 .
4
0
p1 = 1 1
Category II:
and p 2 = 1 1
p3 = 2 2 .
10-25
p1 = 1 1
and p 2 = 1 1
10
10 Widrow-Hoff Learning
Category IV:
p3 = 1 0 .
p3
I
p1
II
p2
Figure P10.2 Input Vectors for Problem P10.1 (i)
The blue line in this figure is a decision boundary that separates the two
categories successfully. Since they are linearly separable, an ADALINE
network will do the job.
ii. The decision boundary passes through the points 3 0 and 0 3 . We
know these points to be the intercepts b w 1 1 and b w 1 2 . Thus, a solution
b = 3 , w 1 1 = 1 , w 1 2 = 1 ,
is satisfactory. Note that if the output of the ADALINE is positive or zero
the input vector is classified as Category I, and if the output is negative the
input vector is classified as Category II. This solution also provides for error, since the decision boundary bisects the line between p 1 and p 3 .
iii. The input vectors to be distinguished are shown in Figure P10.3. The
vectors in the figure are not linearly separable, so an ADALINE network
cannot distinguish between them.
iv. As noted in part (iii), an ADALINE cannot do the job, so there are no
values for the weights and bias that are satisfactory.
10-26
Solved Problems
p1
p3
p2
1 t = 1 , p = 1 t = 1 .
p1 =
2
1
2
1
1
These patterns occur with equal probability, and they are used to
train an ADALINE network with no bias. What does the mean
square error performance surface look like?
First we need to calculate the various terms of the quadratic function. Recall from Eq. (10.11) that the performance index can be written as
T
F x = c 2x h + x Rx .
Therefore we need to calculate c , h and R .
The probability of each input occurring is 0.5, so the probability of each target is also 0.5. Thus, the expected value of the square of the targets is
2
c = E t = 1 0.5 + 1 0.5 = 1 .
In a similar way, the cross-correlation between the input and the target can
be calculated:
h = E tz = 0.5 1 1 + 0.5 1 1 = 0 .
1
1
1
Finally, the input correlation matrix R is
10-27
10
10 Widrow-Hoff Learning
R = E zz = p 1 p 1 0.5 + p 2 p 2 0.5
= 0.5 1 1 1 + 1 1 1
1
1
= 1 0
0 1
F x = c 2x h + x Rx
w 1 1
= 1 2 w 1 1 w 1 2 0 + w 1 1 w 1 2 1 0
1
0 1 w 1 2
2
= 1 2w 1 2 + w 1 1 + w 1 2
The Hessian matrix of F x , which is equal to 2R , has both eigenvalues at
2. Therefore the contours of the performance surface will be circular. To
find the center of the contours (the minimum point), we need to solve Eq.
(10.18):
1
x = R h = 1 0
0 1
0 = 0 .
1
1
w 1 2
-1
-2
-3
-2
-1
w 1 1
10-28
Solved Problems
P10.4 Consider the system of Problem P10.3 again. Train the network using the LMS algorithm, with the initial guess set to zero and a
learning rate = 0.25 . Apply each reference pattern only once
during training. Draw the decision boundary at each stage.
Assume the input vector p 1 is presented first. The output, error and new
weights are calculated as follows:
a 0 = purelin 0 0 1 = 0 ,
1
e 0 = t0 a0 = 1 0= 1 ,
a>0
1w
1
T
1
W 1 = W 0 + 2e 0 p 0 = 0 0 + 2 --- 1 1 1 = 1
--- --- .
4
2 2
The decision boundary associated with these weights is shown to the left.
Now apply the second input vector:
a<0
1 1
a 1 = purelin 1
--- -- 2 2 1
= 0 ,
e 1 = t 1 a 1 = 1 0 = 1 ,
T
1
1- 1
W 2 = W 1 + 2e 1 p 1 = 1
--- --- + 2 -1 1 = 0 1 .
4
2 2
1w
a>0
The decision boundary associated with these weights is shown to the left.
This boundary shows real promise. It is exactly halfway between the input
vectors. You might verify for yourself that each input vector, when applied,
yields its correct associated target. (What set of weights would be optimal
if the targets associated with the two input vectors were exchanged?)
a<0
P10.5 Now consider the convergence of the system of Problems P10.3 and
P10.4. What is the maximum stable learning rate for the LMS algorithm?
2+2
ans =
4
10-29
10
10 Widrow-Hoff Learning
0
1
The diagonal terms of matrix D give the eigenvalues, 1 and 1, while the columns of V show the eigenvectors. Note, incidentally, that the eigenvectors
have the same direction as those shown in Figure P10.4.
The largest eigenvalue, max = 1 , sets the upper limit on the learning rate
at
1 max = 1 1 = 1 .
The suggested learning rate in the previous problem was 0.25, and you
found (perhaps) that the LMS algorithm converged quickly. What do you
suppose happens when the learning rate is 1.0 or larger?
P10.6 Consider the adaptive filter ADALINE shown in Figure P10.5. The
purpose of this filter is to predict the next value of the input signal
from the two previous values. Suppose that the input signal is a
stationary random process, with autocorrelation function given by
C y n = E y k y k + n
Cy 0 = 3 , Cy 1 = 1 , Cy 2 = 1 .
i. Sketch the contour plot of the performance index (mean
square error).
ii. What is the maximum stable value of the learning rate ( )
for the LMS algorithm?
iii. Assume that a very small value is used for . Sketch the path
of the weights for the LMS algorithm, starting with initial
T
guess W 0 = 0.75 0 . Explain your procedure for sketching the path.
10-30
Solved Problems
Inputs
y(k)
ADALINE
w1,1
SxR
w1,2
n(k)
a(k)
t(k) = y(k)
e(k)
F x = c 2x h + x Rx .
We can calculate the constants in the performance index as shown below:
2
c = E t k = E y k = Cy 0 = 3 ,
T
R = E zz = E
y k 1
y k 1 y k 2
y k 1 y k 2
y k 2
Cy 0 Cy 1
Cy 1 Cy 0
3 1
1 3
Cy 1
= 1 .
h = E t z = E y k y k 1 =
Cy 2
1
y k y k 2
The optimal weights are
10-31
10
10 Widrow-Hoff Learning
x = R h =
1
3 1
1 3
1 = 3 8 1 8 1 = 1 2 .
1
4 8 3 8 1
1 2
F x = A = 2R =
6 2 .
2 6
6 2
2 6
= 12 + 32 = 8 4 .
Thus,
1 = 4
2 = 8 .
v1 = 1 ,
1
2 2 v = 0
2
2 2
v2 = 1 .
1
and for 2 = 8 ,
Therefore the contours of F x will be elliptical, with the long axis of each
ellipse along the first eigenvector, since the first eigenvalue has the smallest magnitude. The ellipses will be centered at x . The contour plot is
shown in Figure P10.6.
10-32
Solved Problems
w 1 2
-1
-2
-2
-1
w 1 1
Figure P10.6 Error Contour for Problem P10.6
You might check your sketch by writing a MATLAB M-file to plot the contours.
ii. The maximum stable learning rate is the reciprocal of the maximum
eigenvalue of R , which is the same as twice the reciprocal of the largest
2
eigenvalue of the Hessian matrix F x = A :
2 max = 2 8 = 0.25 .
iii. The LMS algorithm is approximate steepest descent, so the trajectory
for small learning rates will move perpendicular to the contour lines, as
shown in Figure P10.7.
Contour Plot
0.5
x2
w 1 2
-0.5
-1
-1
-0.5
w 1x1 1
0.5
10-33
10
10 Widrow-Hoff Learning
Restored Signal
e
Contaminated
Signal
Voice
Signal
Contaminating
Noise
"Error"
Adaptively Filtered
Noise to Cancel
Contamination
Noise Path
Filter
Adaptive
Filter
Airplane Engine
Noise Source
10-34
Solved Problems
class 1: p 1 = 1 p 2 = 1 , class 2:
1
2
2 p = 2 ,
p3 =
4
1
0
class 3: p 5 = 1 p 6 = 2 , class 4: p 7 = 1 p 8 = 2 .
2
1
1
2
2
4
Figure P10.9 Input Vectors for Problem P10.8
We will use target vectors similar to the ones we introduced in Problem
P4.3, except that we will replace any targets of 0 by targets of -1. (The perceptron could only output 0 or 1.) Thus, the training set will be:
1 t = 1 p = 1 t = 1 p = 2 t = 1
p1 =
2
3
1
2
3
1
1
2
1
1
1
2 t = 1 p = 1 t = 1 p = 2 t = 1
p4 =
5
6
4
5
6
0
1
2
1
1
1
1 t = 1 p = 2 t = 1
p7 =
8
7
8
1
1
2
1
10-35
10
10 Widrow-Hoff Learning
Also, we will begin as in Problem P4.5 with the following initial weights
and biases:
W 0 = 1 0 , b 0 = 1 .
0 1
1
Now we are almost ready to train an ADALINE network using the LMS
rule. We will use a learning rate of = 0.04 , and we will present the input
vectors in order according to their subscripts. The first iteration is
a 0 = purelin (W 0 p 0 + b 0 ) = purelin 1 0 1 + 1 = 2
0 1 1
1
2
e 0 = t 0 a 0 = 1 2 = 3
1
2
3
T
W 1 = W 0 + 2e 0 p 0
= 1 0 + 2 0.04 3 1 1 = 0.76 0.24
0 1
3
0.24 0.76
b 1 = b 0 + 2e 0 = 1 + 2 0.04 3 = 0.76 .
1
3
0.76
The second iteration is
a 1 = purelin (W 1 p 1 + b 1 )
e 1 = t 1 a 1 = 1 1.04 = 2.04
1
2.04
3.04
T
W 2 = W 1 + 2e 1 p 1
=
10-36
Solved Problems
2
4
Figure P10.10 Final Decision Boundaries for Problem P10.8
P10.9 Repeat the work of Widrow and Hoff on a pattern recognition
problem from their classic 1960 paper [WiHo60]. They wanted to
design a recognition system that would classify the six patterns
shown in Figure P10.11.
Patterns
Targets
60
-60
10-37
10
10 Widrow-Hoff Learning
Input
p
16 x 1
1
16
Linear Neuron
W
1 x 16
a
1x1
n
1x1
b
1x1
a = purelin (Wp + b)
Figure P10.12 Adaptive Pattern Classifier
(Widrow and Hoff built their own machine to realize this ADALINE. According to them, it was about the size of a lunch pail.)
Now we will present the six vectors to the network in a random sequence
and adjust the weights of the network after each presentation using the
LMS algorithm with a learning rate of = 0.03 . After each adjustment of
weights, all six vectors will be presented to the network to generate their
outputs and corresponding errors. The sum of the squares of the errors will
be examined as a measure of the quality of the network.
Figure P10.13 illustrates the convergence of the network. The network is
trained to recognize these six characters in about 60 presentations, or
roughly 10 for each of the possible input vectors.
10-38
Solved Problems
The results shown in Figure P10.13 are quite like those obtained and published by Widrow and Hoff some 35 years ago. Widrow and Hoff did good
science. One can indeed duplicate their work, even decades later (without
a lunch pail).
Convergence of Error
2.5
x 10
1.5
0.5
0
0
10
20
30
40
50
60
Time Steps
70
80
90
100
10
10-39
10 Widrow-Hoff Learning
Epilogue
In this chapter we have presented the ADALINE neural network and the
LMS learning rule. The ADALINE network is very similar to the perceptron network of Chapter 4, and it has the same fundamental limitation: it
can only classify linearly separable patterns. In spite of this limitation on
the network, the LMS algorithm is in fact more powerful than the perceptron learning rule. Because it minimizes mean square error, the algorithm
is able to create decision boundaries that are more robust to noise than
those of the perceptron learning rule.
The ADALINE network and the LMS algorithm have found many practical
applications. Even though they were first presented in the late 1950s, they
are still very much in use in adaptive filtering applications. For example,
echo cancellers using the LMS algorithm are currently employed on many
long distance telephone lines. (Chapter 14 provides more extensive coverage of dynamic networks, which are widely used for filtering, prediction
and control.)
In addition to its importance as a practical solution to many adaptive filtering problems, the LMS algorithm is also important because it is the forerunner of the backpropagation algorithm, which we will discuss in
Chapters 11 through 14. Like the LMS algorithm, backpropagation is an
approximate steepest descent algorithm that minimizes mean square error. The only difference between the two algorithms is in the manner in
which the derivatives are calculated. Backpropagation is a generalization
of the LMS algorithm that can be used for multilayer networks. These more
complex networks are not limited to linearly separable problems. They can
solve arbitrary classification problems.
10-40
Further Reading
Further Reading
[AnRo89]
J. A. Anderson, E. Rosenfeld, Neurocomputing: Foundations of Research, Cambridge, MA: MIT Press, 1989.
Neurocomputing is a fundamental reference book. It contains over forty of the most important neurocomputing
writings. Each paper is accompanied by an introduction
that summarizes its results and gives a perspective on the
position of the paper in the history of the field.
[StDo84]
W. D. Stanley, G. R. Dougherty, R. Dougherty, Digital Signal Processing, Reston VA: Reston, 1984
[WiHo60]
[WiSt 85]
[WiWi 88]
B. Widrow and R. Winter, Neural nets for adaptive filtering and adaptive pattern recognition, IEEE Computer
Magazine, March 1988, pp. 2539.
This is a particularly readable paper that summarizes applications of adaptive multilayer neural networks. The networks are applied to system modeling, statistical
prediction, echo cancellation, inverse modeling and pattern
recognition.
10-41
10
10 Widrow-Hoff Learning
Exercises
E10.1 An adaptive filter ADALINE is shown in Figure E10.1. Suppose that the
weights of the network are given by
w 1 1 = 1 , w 1 2 = 4 , w 1 3 = 2 ,
and the input to the filter is
y k = 0 0 0 1 1 2 0 0 .
Find the response a k of the filter.
Inputs
ADALINE
y(k)
w1,1
w1,2
SxR
n(k)
a(k)
w1,3
Class I
Class II
10-42
Exercises
E10.3 Suppose that we have the following two reference patterns and their targets:
1 t = 1 , p = 1 t = 1 .
p1 =
2
1
2
1
1
In Problem P10.3 these input vectors to an ADALINE were assumed to occur with equal probability. Now suppose that the probability of vector p 1
is 0.75 and that the probability of vector p 2 is 0.25. Does this change of
probabilities change the mean square error surface? If yes, what does the
surface look like now? What is the maximum stable learning rate?
E10.4 In this exercise we will modify the reference pattern p 2 from Problem
P10.3:
1 t = 1 , p = 1 t = 1 .
p1 =
2
1
2
1
1
i. Assume that the patterns occur with equal probability. Find the
mean square error and sketch the contour plot.
ii. Find the maximum stable learning rate.
2+2
ans =
4
iii. Write a MATLAB M-file to implement the LMS algorithm for this
problem. Take 40 steps of the algorithm for a stable learning rate.
Use the zero vector as the initial guess. Sketch the trajectory on the
contour plot.
iv. Take 40 steps of the algorithm after setting the initial values of both
parameters to 1. Sketch the final decision boundary.
v. Compare the final parameters from parts (iii) and (iv). Explain your
results.
E10.5 We again use the reference patterns and targets from Problem P10.3, and
assume that they occur with equal probability. This time we want to train
an ADALINE network with a bias. We now have three parameters to find:
w 1 1 , w 1 2 and b .
i. Find the mean square error and the maximum stable learning rate.
2+2
ans =
4
ii. Write a MATLAB M-file to implement the LMS algorithm for this
problem. Take 40 steps of the algorithm for a stable learning rate.
Use the zero vector as the initial guess. Sketch the final decision
boundary.
iii. Take 40 steps of the algorithm after setting the initial values of all
parameters to 1. Sketch the final decision boundary.
iv. Compare the final parameters and the decision boundaries from
parts (iii) and (iv). Explain your results.
10-43
10
10 Widrow-Hoff Learning
4 .
1
1
We want to train a single-neuron ADALINE network without a bias to recognize these categories (t = 1 for Category I and t = -1 for Category II). Assume that each pattern occurs with equal probability.
i. Draw the network diagram.
ii. Take four steps of the LMS algorithm, using the zero vector as the
initial guess. (one pass through the four vectors above - present each
vector once). Use a learning rate of 0.1.
iii. What are the optimal weights?
iv. Sketch the optimal decision boundary.
v. How do you think the boundary would change if the network were
allowed to have a bias? If the boundary would change, indicate the
approximate new position on your sketch of part iv. You do not need
to perform any calculations here - just explain your reasoning.
E10.7 Suppose that we have the following three reference patterns and their targets:
3 t =
p1 =
75 ,
1
6
6 t =
p2 =
75 ,
2
3
6 t =
p3 =
75 .
3
3
Exercises
iv. Sketch the trajectory of the LMS algorithm on your contour plot. Assume a very small learning rate, and start with all weights equal to
zero. This does not require any calculations.
E10.8 Suppose that we have the following two reference patterns and their targets:
1 t =
2 t =
p1 =
1 , p2 =
1 .
1
2
2
1
4 t = 5 , p = 2 t = 2 , p = 4 t = 9 .
p1 =
2
3
1
2
3
2
4
4
The first two pair each occurs with probability of 0.25, and the third pair
occurs with probability 0.5. We want to train a single-neuron ADALINE
network without a bias to perform the desired mapping.
i. Draw the network diagram.
ii. What is the maximum stable learning rate?
iii. Perform one iteration of the LMS algorithm. Apply the input p 1 and
use a learning
rate of = 0.1 . Start from the initial weights
T
x0 = 0 0 .
10-45
10
10 Widrow-Hoff Learning
2 t = 1 , p = 4 t = 1 , p = 4 t = 1 .
p1 =
2
3
1
2
3
4
4
2
The first two pair each occurs with probability of 0.25, and the third pair
occurs with probability 0.5. We want to train a single-neuron ADALINE
network without a bias to perform the desired mapping.
E10.11 We want to train a single-neuron ADALINE network without a bias, using
the following training set, which categorizes vectors into two classes. Each
pattern occurs with equal probability.
1 t = 1 p = 2 t = 1 p = 0 t = 1 p = 1 t = 1
p1 =
2
3
4
1
2
3
4
2
1
1
0
2 t =
4 t =
2 t =
p1 =
26 , p 2 =
26 , p 3 =
26 .
1
2
3
4
2
2
10-46
Exercises
Inputs
y(k)
ADALINE
w1,1
w1,2
SxR
n(k)
a(k)
t(k) = y(k)
e(k)
10-47
10
10 Widrow-Hoff Learning
k
y k = sin ------ .
5
iii. Find the eigenvalues and eigenvectors of the Hessian matrix for the
mean square error. Locate the minimum point and sketch a rough
contour plot.
iv. Find the maximum stable learning rate for the LMS algorithm.
v. Take three steps of the LMS algorithm by hand, using a stable
learning rate. Use the zero vector as the initial guess.
2+2
ans =
4
vi. Write a MATLAB M-file to implement the LMS algorithm for this
problem. Take 40 steps of the algorithm for a stable learning rate
and sketch the trajectory on the contour plot. Use the zero vector as
the initial guess. Verify that the algorithm is converging to the optimal point.
vii. Verify experimentally that the algorithm is unstable for learning
rates greater than that found in part (iv).
E10.14 Repeat Problem P10.9, but use the numerals 1, 2 and 4, instead of the
letters T, G and F. Test the trained network on each reference pattern
and on noisy patterns. Discuss the sensitivity of the network. (Use the Neural Network Design Demonstration Linear Pattern Classification (nnd10lc).)
10-48
Objectives
11
Backpropagation
Objectives
Theory and Examples
11-1
11-2
Multilayer Perceptrons
11-2
Pattern Classification
11-3
Function Approximation
11-4
11-7
Performance Index
11-8
Chain Rule
11-9
11-11
Summary
11-13
Example
11-14
11-17
Using Backpropagation
11-18
11-18
Convergence
11-20
Generalization
11-22
Summary of Results
11-25
Solved Problems
11-27
Epilogue
11-41
Further Reading
11-42
Exercises
11-44
Objectives
In this chapter we continue our discussion of performance learning, which
we began in Chapter 8, by presenting a generalization of the LMS algorithm of Chapter 10. This generalization, called backpropagation, can be
used to train multilayer networks. As with the LMS learning law, backpropagation is an approximate steepest descent algorithm, in which the
performance index is mean square error. The difference between the LMS
algorithm and backpropagation is only in the way in which the derivatives
are calculated. For a single-layer linear network the error is an explicit linear function of the network weights, and its derivatives with respect to the
weights can be easily computed. In multilayer networks with nonlinear
transfer functions, the relationship between the network weights and the
error is more complex. In order to calculate the derivatives, we need to use
the chain rule of calculus. In fact, this chapter is in large part a demonstration of how to use the chain rule.
11-1
11
11 Backpropagation
Multilayer Perceptrons
We first introduced the notation for multilayer networks in Chapter 2. For
ease of reference we have reproduced the diagram of the three-layer perceptron in Figure 11.1. Note that we have simply cascaded three perceptron networks. The output of the first network is the input to the second
network, and the output of the second network is the input to the third network. Each layer may have a different number of neurons, and even a different transfer function. Recall from Chapter 2 that we are using
superscripts to identify the layer number. Thus, the weight matrix for the
1
first layer is written as W and the weight matrix for the second layer is
2
written W .
To identify the structure of a multilayer network, we will sometimes use
the following shorthand notation, where the number of inputs is followed
by the number of neurons in each layer:
1
RS S S .
11-2
(11.1)
Multilayer Perceptrons
Inputs
First Layer
w 11,1
p1
f1
a11
w 21,1
b1
p3
1 1
S ,R
Third Layer
a21
f2
w 31,1
b1
n12
a12
a22
f1
b1S 1
a1S 1
w 2S 2 , S 1
a1 = f 1 (W1p + b1)
n32
a32
b2
n2S 2
a31
f3
b31
b2
n1S 1
n22
n31
b2
n21
p2
pR
n11
Second Layer
f2
a2S 2
b2S 2
w 3S 3, S 2
a2 = f 2 (W2a1 + b2)
n3S 3
f3
a3S 3
b3S 3
a3 = f 3 (W3a2 + b3)
Pattern Classification
2
+2
p2
p4
To illustrate the capabilities of the multilayer perceptron for pattern classification, consider the classic exclusive-or (XOR) problem. The input/target pairs for the XOR gate are
0 t = 0 p = 0 t = 1 p = 1 t = 1 p = 1 t = 0 .
p1 =
2
3
4
1
2
3
4
0
1
0
1
This problem, which is illustrated graphically in the figure to the left, was
used by Minsky and Papert in 1969 to demonstrate the limitations of the
single-layer perceptron. Because the two categories are not linearly separable, a single-layer perceptron cannot perform the classification.
A two-layer network can solve the XOR problem. In fact, there are many
different multilayer solutions. One solution is to use two neurons in the
first layer to create two decision boundaries. The first boundary separates
p 1 from the other patterns, and the second boundary separates p 4 . Then
the second layer is used to combine the two boundaries together using an
11-3
11
11 Backpropagation
AND operation. The decision boundaries for each first-layer neuron are
shown in Figure 11.2.
w1
w1
Layer 1/Neuron 2
Layer 1/Neuron 1
a11
1
-1
1
p2
n11
-1
-1
AND Operation
n12
a12
n21
a21
-1.5
1
1.5
1
Figure 11.3 Two-Layer XOR Network
See Problems P11.1 and P11.2 for more on the use of multilayer networks
for pattern classification.
Function Approximation
Up to this point in the text we have viewed neural networks mainly in the
context of pattern classification. It is also instructive to view networks as
function approximators. In control systems, for example, the objective is to
find an appropriate feedback function that maps from measured outputs to
control inputs. In adaptive filtering (Chapter 10) the objective is to find a
function that maps from delayed values of an input signal to an appropriate output signal. The following example will illustrate the flexibility of the
multilayer perceptron for implementing functions.
11-4
Multilayer Perceptrons
2
+2
Consider the two-layer, 1-2-1 network shown in Figure 11.4. For this example the transfer function for the first layer is log-sigmoid and the transfer
function for the second layer is linear. In other words,
1 1
2
and f n = n .
f n = --------------n
1+e
Input
Log-Sigmoid Layer
w11,1
n11
Linear Layer
a11
w21,1
b11
w12,1
n12
(11.2)
a12
w21,2
b12
n2
a2
b2
1
a1 = logsig (W1p + b1)
w 1 1 = 10 , w 2 1 = 10 , b 1 = 10 , b 2 = 10 ,
2
w 1 1 = 1 , w 1 2 = 1 , b = 0 .
The network response for these parameters is shown in Figure 11.5, which
2
plots the network output a as the input p is varied over the range 2 2 .
Notice that the response consists of two steps, one for each of the log-sigmoid neurons in the first layer. By adjusting the network parameters we
can change the shape and location of each step, as we will see in the following discussion.
The centers of the steps occur where the net input to a neuron in the first
layer is zero:
1
b1
10
1
1
1
- = --------- = 1 ,
n 1 = w 1 1 p + b 1 = 0 p = --------1
10
w 1 1
(11.3)
11
11-5
11 Backpropagation
b2
10
1
1
1
- = ------ = 1 .
n 2 = w 2 1 p + b 2 = 0 p = --------1
10
w 2 1
(11.4)
-1
-2
-1
p
Figure 11.5 Nominal Response of Network of Figure 11.4
Figure 11.6 illustrates the effects of parameter changes on the network response. The blue curve is the nominal response. The other curves correspond to the network response when one parameter at a time is varied over
the following ranges:
2
1 w 1 1 1 , 1 w 1 2 1 , 0 b 2 20 , 1 b 1 .
(11.5)
Figure 11.6 (a) shows how the network biases in the first (hidden) layer can
be used to locate the position of the steps. Figure 11.6 (b) illustrates how
the weights determine the slope of the steps. The bias in the second (output) layer shifts the entire network response up or down, as can be seen in
Figure 11.6 (d).
From this example we can see how flexible the multilayer network is. It
would appear that we could use such networks to approximate almost any
function, if we had a sufficient number of neurons in the hidden layer. In
fact, it has been shown that two-layer networks, with sigmoid transfer
functions in the hidden layer and linear transfer functions in the output
layer, can approximate virtually any function of interest to any degree of
accuracy, provided sufficiently many hidden units are available (see
[HoSt89]).
To experiment with the response of this two-layer network, use the MATLAB Neural Network Design Demonstration Network Function (nnd11nf).
11-6
b2
-1
-2
-1
(a)
-1
-2
2
w 1 2
2
-1
-2
-1
w 1 1
-1
-2
(c)
-1
(b)
-1
(d)
m+1
= f
m+1
m+1 m
a +b
m+1
for m = 0 1 M 1 ,
(11.6)
where M is the number of layers in the network. The neurons in the first
layer receive external inputs:
0
a = p,
(11.7)
which provides the starting point for Eq. (11.6). The outputs of the neurons
in the last layer are considered the network outputs:
M
a = a .
11-7
(11.8)
11
11 Backpropagation
Input
First Layer
p
Rx1
1
R
W1
S1 x R
Second Layer
a1
n1
S1 x 1
f1
S1 x 1
b1
S1 x 1
S1
a1 = f 1 (W1p + b1)
Third Layer
a2
W2
n2
S2 x S1
S2 x 1
f2
W3
S2 x 1
S3 x S2
b2
S2 x 1
a3
n3
S3 x 1
f3
S3 x 1
b3
S3 x 1
S2
a2 = f 2 (W2a1 + b2)
S3
a3 = f 3 (W3a2 + b3)
Performance Index
The backpropagation algorithm for multilayer networks is a generalization
of the LMS algorithm of Chapter 10, and both algorithms use the same performance index: mean square error. The algorithm is provided with a set of
examples of proper network behavior:
{p 1, t 1} { p 2, t 2} {p Q, tQ} ,
(11.9)
where p q is an input to the network, and t q is the corresponding target output. As each input is applied to the network, the network output is compared to the target. The algorithm should adjust the network parameters
in order to minimize the mean square error:
2
Fx= Ee = E t a .
(11.10)
where x is the vector of network weights and biases (as in Chapter 10). If
the network has multiple outputs this generalizes to
T
Fx= Ee e = Et a t a .
(11.11)
As with the LMS algorithm, we will approximate the mean square error by
T
T
F x = t k a k t k a k = e k e k ,
(11.12)
where the expectation of the squared error has been replaced by the
squared error at iteration k .
The steepest descent algorithm for the approximate mean square error
(stochastic gradient descent) is
11-8
F m
m
w i j k + 1 = w i j k ---------,
m
w i j
(11.13)
F
m
m
b i k + 1 = b i k --------m- ,
b i
(11.14)
Chain Rule
For a single-layer linear network (the ADALINE) these partial derivatives
are conveniently computed using Eq. (10.33) and Eq. (10.34). For the multilayer network the error is not an explicit function of the weights in the
hidden layers, therefore these derivatives are not computed so easily.
Because the error is an indirect function of the weights in the hidden layers, we will use the chain rule of calculus to calculate the derivatives. To
review the chain rule, suppose that we have a function f that is an explicit
function only of the variable n . We want to take the derivative of f with
respect to a third variable w . The chain rule is then:
df n w
df n dn w
---------------------- = ------------ --------------- .
dn
dw
dw
2
+2
(11.15)
For example, if
n
f n = e and n = 2w , so that f n w = e
2w
(11.16)
then
df n dn w
d
f n w -
n
--------------------= ------------ --------------- = e 2 .
dn
dw
dw
(11.17)
We will use this concept to find the derivatives in Eq. (11.13) and Eq.
(11.14):
m
n i
F
F- -----------------,
---------=
m
m
m
w i j
n i w i j
(11.18)
F n
F
--------- = --------m- --------im- .
m
n i b i
b i
(11.19)
11
11-9
11 Backpropagation
The second term in each of these equations can be easily computed, since
the net input to layer m is an explicit function of the weights and bias in
that layer:
S
m
ni
m1
w i j a j
m
m1
+ bi .
(11.20)
n i
1 n i
---------- = am
, --------m- = 1 .
j
m
w i j
b i
(11.21)
F
m
s i --------m- ,
n i
(11.22)
j=1
Therefore
m
If we now define
Sensitivity
(the sensitivity of F to changes in the ith element of the net input at layer
m ), then Eq. (11.18) and Eq. (11.19) can be simplified to
F
m1
---------- = sm
,
i aj
m
w i j
(11.23)
F
--------m- = s m
i .
b i
(11.24)
m m1
w i j k + 1 = w i j k s i a j
m
b i k + 1 = b i k s i .
(11.25)
(11.26)
W k + 1 = W k s a
m
m1 T
b k + 1 = b k s ,
where
11-10
(11.27)
(11.28)
(11.29)
F
m
s --------m- =
n
F
--------mn 1
F
--------m
n 2 .
F
--------m
n m
S
(Note the close relationship between this algorithm and the LMS algorithm
of Eq. (10.33) and Eq. (10.34)).
It now remains for us to compute the sensitivities s , which requires another application of the chain rule. It is this process that gives us the term
backpropagation, because it describes a recurrence relationship in which
the sensitivity at layer m is computed from the sensitivity at layer m + 1 .
To derive the recurrence relationship for the sensitivities, we will use the
following Jacobian matrix:
m+1
m+1
m+1
m+1
m+1
m+1
n 1
n 1
n 1
---------------------------- -------------m
m
m
n 1
n 2
n S m
n 2
n 2
n 2
m+1
---------------------------- -------------n
m
m
m
.
-------------- n
n 2
n S m
m
1
n
m+1
m+1
m+1
(11.30)
n S m + 1 n S m + 1
n S m + 1
----------------------------------------
m
m
m
n 1
n 2
n S m
Next we want to find an expression for this matrix. Consider the i, j element of the matrix:
11
11-11
11 Backpropagation
m+1 m
m+1
w i l a l + b i
m+1
m
l = 1
n i
m + 1 a j
---------------------------------------------------------------------------=
=
w
i j
m
m
m
n j
n j
n j
m
m + 1 f n j
+ 1m m
- = wm
= w i j -----------------i j f n j ,
m
n j
(11.31)
where
m
f n j
m m
-.
f n j = -----------------m
n j
(11.32)
m
n
--------------- = W m + 1 F n m ,
m
n
(11.33)
where
m m
f n1
0
0
0
m
m
F n =
m m
f n2
(11.34)
m m
f nSm
We can now write out the recurrence relation for the sensitivity by using
the chain rule in matrix form:
s
n m + 1 F
F
F
m n m W m + 1 T -------------------------------------------------=
=
=
F
m
m
m+1
m+1
n n
n
n
m m
m+1 T m+1
= F (n ) W
s
.
(11.35)
Now we can see where the backpropagation algorithm derives its name.
The sensitivities are propagated backward through the network from the
last layer to the first layer:
M
s s
11-12
M1
s s .
(11.36)
tj aj
T
a
F
t a t a
j=1
- = ------------------------------- = 2 t i a i --------Mi- .
= --------M- = -----------------------------------M
M
n i
n i
n i
n i
2
si
(11.37)
Now, since
M
a
a
f n i
M
--------Mi- = --------iM- = ------------------- = f n M
i ,
M
n i
n i
n i
(11.38)
M
M M
si = 2 ti ai f ni .
(11.39)
we can write
M M
= 2F (n ) t a .
(11.40)
Summary
Lets summarize the backpropagation algorithm. The first step is to propagate the input forward through the network:
0
m+1
= f
m+1
m+1 m
a = p,
(11.41)
m+1
for m = 0 1 M 1 ,
(11.42)
(11.43)
a +b
a = a .
The next step is to propagate the sensitivities backward through the network:
s
M M
= 2F (n ) t a ,
(11.44)
11
11-13
11 Backpropagation
m m
m+1 T m+1
= F (n ) W
s
, for m = M 1 2 1 .
(11.45)
Finally, the weights and biases are updated using the approximate steepest descent rule:
m
W k + 1 = W k s a
m
m1 T
(11.46)
b k + 1 = b k s .
(11.47)
Example
2
+2
To illustrate the backpropagation algorithm, lets choose a network and apply it to a particular problem. To begin, we will use the 1-2-1 network that
we discussed earlier in this chapter. For convenience we have reproduced
the network in Figure 11.8.
Next we want to define a problem for the network to solve. Suppose that we
want to use the network to approximate the function
(11.48)
To obtain our training set we will evaluate this function at several values
of p .
Input
Log-Sigmoid Layer
w11,1
p
w12,1
n11
a11
Linear Layer
w21,1
b11
n12
a12
b12
w21,2
n2
a2
b2
1
a1 = logsig (W1p + b1)
11-14
Example
1
1
2
2
W 0 = 0.27 , b 0 = 0.48 , W 0 = 0.09 0.17 , b 0 = 0.48 .
0.41
0.13
The response of the network for these initial values is illustrated in Figure
11.9, along with the sine function we wish to approximate.
3
2.5
1.5
0.5
0.5
1
2
1.5
0.5
0.5
1.5
p
Figure 11.9 Initial Network Response
Next, we need to select a training set {p 1, t 1} {p 2, t 2} {p Q, tQ} . In this
case, we will sample the function at 21 points in the range [-2,2] at equally
spaced intervals of 0.2. The training points are indicated by the circles in
Figure 11.9.
Now we are ready to start the algorithm. The training points can be presented in any order, but they are often chosen randomly. For our initial input we will choose p = 1 , which is the 16th training point:
0
a = p = 1.
The output of the first layer is then
1
1
1 0
1
a = f W a + b = logsig 0.27 1 + 0.48 = logsig 0.75
0.41
0.54
0.13
1
-----------------0.75
1
e
+
=
= 0.321 .
0.368
1 -----------------1+e
0.54
11
11-15
11 Backpropagation
2
2
2 1
2
a = f W a + b = purelin ( 0.09 0.17 0.321 + 0.48 ) = 0.446 .
0.368
2
e = t a = 1 + sin --- p a = 1 + sin --- 1 0.446 = 1.261 .
4
4
The next stage of the algorithm is to backpropagate the sensitivities. Before we begin the backpropagation, recall that we will need the derivatives
1
2
of the transfer functions, f (n) and f (n) . For the first layer
n
1 1
e
1 -
1
d --------------- = 1 a1 a1 .
- --------------f n =
= -----------------------2 = 1 --------------
n
n
dn 1 + e
1+e
1+e
1 + e
For the second layer we have
2
f n = d n = 1 .
dn
The first layer sensitivity is then computed by backpropagating the sensitivity from the second layer, using Eq. (11.45):
1
1 1
1 a1 a1
0
1
2 T 2
0.09
s = F (n ) W s =
2.522
1
1
1 a 2 a 2 0.17
0
0
0.09
= 1 0.321 0.321
2.522
0
1 0.368 0.368 0.17
0.227 = 0.0495 .
= 0.218 0
0 0.233 0.429
0.0997
The final stage of the algorithm is to update the weights. For simplicity, we
will use a learning rate = 0.1 . (In Chapter 12 the choice of learning rate
will be discussed in more detail.) From Eq. (11.46) and Eq. (11.47) we have
11-16
1 T
1
1
1
b 1 = b 0 s = 0.48 0.1 0.0495 = 0.475 .
0.13
0.0997
0.140
The algorithm described above is the stochastic gradient descent algorithm, which involves on-line or incremental training, in which the network weights and biases are updated after each input is presented (as with
the LMS algorithm of Chapter 10). It is also possible to perform batch training, in which the complete gradient is computed (after all inputs are applied to the network) before the weights and biases are updated. For
example, if each input occurs with equal probability, the mean square error
performance index can be written
Q
1
F x = E e e = E t a t a = ---Q
T
tq aq
tq aq .
(11.49)
q=1
11
11-17
11 Backpropagation
1
T
T
F x = ---- t q a q t q a q = ---- t q a q t q a q . (11.50)
Q
Q
q=1
q=1
Therefore, the total gradient of the mean square error is the mean of the
gradients of the individual squared errors. Therefore, to implement a batch
version of the backpropagation algorithm, we would step through Eq.
(11.41) through Eq. (11.45) for all of the inputs in the training set. Then,
the individual gradients would be averaged to get the total gradient. The
update equations for the batch steepest descent algorithm would then be
W k + 1 = W k ---Q
m
Q
m1 T
sq aq
m
(11.51)
q=1
b k + 1 = b k ---Q
m
sq .
m
(11.52)
q=1
Using Backpropagation
In this section we will present some issues relating to the practical implementation of backpropagation. We will discuss the choice of network architecture, and problems with network convergence and generalization. (We
will discuss implementation issues again in Chapter 12, which investigates
procedures for improving the algorithm.)
For our first example lets assume that we want to approximate the following functions:
i
g p = 1 + sin ----- p for 2 p 2 ,
4
(11.53)
11-18
Using Backpropagation
For this first example we will use a 1-3-1 network, where the transfer function for the first layer is log-sigmoid and the transfer function for the second layer is linear. Recall from our example on page 11-5 that this type of
two-layer network can produce a response that is a sum of three log-sigmoid functions (or as many log-sigmoids as there are neurons in the hidden
layer). Clearly there is a limit to how complex a function this network can
implement. Figure 11.10 illustrates the response of the network after it has
been trained to approximate g p for i = 1 2 4 8 . The final network responses are shown by the blue lines.
3
i = 2
i = 1
2
-1
-2
-1
-1
-2
i = 4
-1
-2
-1
-1
-1
-2
i = 8
-1
In the next example we will approach the problem from a slightly different
perspective. This time we will pick one function g p and then use larger
and larger networks until we are able to accurately represent the function.
For g p we will use
6
g p = 1 + sin ------ p for 2 p 2 .
4
(11.54)
11
11 Backpropagation
1-3-1
1-2-1
2
-1
-2
-1
-1
-2
-1
1-4-1
1-5-1
-1
-2
-1
-1
-2
-1
Convergence
In the previous section we presented some examples in which the network
response did not give an accurate approximation to the desired function,
even though the backpropagation algorithm produced network parameters
that minimized mean square error. This occurred because the capabilities
of the network were inherently limited by the number of hidden neurons it
contained. In this section we will provide an example in which the network
is capable of approximating the function, but the learning algorithm does
not produce network parameters that produce an accurate approximation.
In the next chapter we will discuss this problem in more detail and explain
why it occurs. For now we simply want to illustrate the problem.
11-20
Using Backpropagation
2
+2
(11.55)
To approximate this function we will use a 1-3-1 network, where the transfer function for the first layer is log-sigmoid and the transfer function for
the second layer is linear.
Figure 11.12 illustrates a case where the learning algorithm converges to
a solution that minimizes mean square error. The thin blue lines represent
intermediate iterations, and the thick blue line represents the final solution, when the algorithm has converged. (The numbers next to each curve
indicate the sequence of iterations, where 0 represents the initial condition
and 5 represents the final solution. The numbers do not correspond to the
iteration number. There were many iterations for which no curve is represented. The numbers simply indicate an ordering.)
3
1
1
3
2
4
0
-1
-2
-1
11
11-21
11 Backpropagation
3
4
2
0
1
-1
-2
-1
Generalization
In most cases the multilayer network is trained with a finite number of examples of proper network behavior:
{p 1, t 1} { p 2, t 2} {p Q, tQ} .
(11.56)
This training set is normally representative of a much larger class of possible input/output pairs. It is important that the network successfully generalize what it has learned to the total population.
2
+2
For example, suppose that the training set is obtained by sampling the following function:
g p = 1 + sin --- p ,
4
(11.57)
at the points p = 2 1.6 1.2 1.6 2 . (There are a total of 11 input/target pairs.) In Figure 11.14 we see the response of a 1-2-1 network that has
11-22
Using Backpropagation
been trained on this data. The black line represents g p , the blue line represents the network response, and the + symbols indicate the training set.
3
-1
-2
-1
-1
-2
-1
11
11 Backpropagation
eters and is therefore much more restricted in the types of functions that it
can implement.
For a network to be able to generalize, it should have fewer parameters than
there are data points in the training set. In neural networks, as in all modeling problems, we want to use the simplest network that can adequately
represent the training set. Dont use a bigger network when a smaller network will work (a concept often referred to as Ockhams Razor).
An alternative to using the simplest network is to stop the training before
the network overfits. A reference to this procedure and other techniques to
improve generalization are given in Chapter 13.
To experiment with generalization in neural networks, use the MATLAB
Neural Network Design Demonstration Generalization (nnd11gn).
11-24
Summary of Results
Summary of Results
Multilayer Network
Input
First Layer
p
Rx1
1
R
W1
S1 x R
Second Layer
a1
n1
S1 x 1
S1 x 1
b1
S1 x 1
S1
a1 = f 1 (W1p + b1)
Third Layer
a2
W2
n2
S2 x S1
S2 x 1
S2 x 1
b2
S2 x 1
W3
S3 x S2
a3
n3
S3 x 1
S3 x 1
b3
S3 x 1
S2
a2 = f 2 (W2a1 + b2)
S3
a3 = f 3 (W3a2 + b3)
Backpropagation Algorithm
Performance Index
T
Fx= Ee e = Et a t a
T
T
F x = e k e k = t k a k t k a k
Sensitivity
F
m
s --------m- =
n
F
--------mn 1
F
--------mn 2
F
--------m
n S m
11
11-25
11 Backpropagation
Forward Propagation
0
a = p,
a
m+1
= f
m+1
m+1 m
a +b
m+1
for m = 0 1 M 1 ,
a = a .
Backward Propagation
s
s
M M
= 2F (n ) t a ,
m m
m+1 T m+1
= F (n ) W
s
, for m = M 1 2 1 ,
where
m m
f n 1
f n2
m
m
F n =
0
m
m m
f n S m
0
m
f n j
m m
-.
f n j = -----------------m
n j
W k + 1 = W k s a
m
m1 T
b k + 1 = b k s .
11-26
Solved Problems
Solved Problems
P11.1 Consider the two classes of patterns that are shown in Figure
P11.1. Class I represents vertical lines and Class II represents horizontal lines.
Class I
Class II
Figure P11.1 Pattern Classes for Problem P11.1
i. Are these categories linearly separable?
ii. Design a multilayer network to distinguish these categories.
i. Lets begin by converting the patterns to vectors by scanning each 2X2
grid one column at a time. Each white square will be represented by a -1
and each blue square by a 1. The vertical lines (Class I patterns) then become
1
1
p 1 = 1 and p 2 = 1 ,
1
1
1
1
and the horizontal lines (Class II patterns) become
1
1
1
and p 4 = 1 .
p3 =
1
1
1
1
In order for these categories to be linearly separable we must be able to
place a hyperplane between the two categories. This means there must be
a weight matrix W and a bias b such that
Wp 1 + b 0 , Wp 2 + b 0 , Wp 3 + b 0 , Wp 4 + b 0 .
These conditions can be converted to
11
11-27
11 Backpropagation
w 1 1 w 1 2 w 1 3 w 1 4
1
1 =
w 1 1 + w 1 2 w 1 3 w 1 4 0 ,
1
1
w 1 1 w 1 2 + w 1 3 + w 1 4 0 ,
w 1 1 w 1 2 + w 1 3 w 1 4 0 ,
w 1 1 + w 1 2 w 1 3 + w 1 4 0 .
The first two conditions reduce to
w 1 1 + w 1 2 w 1 3 + w 1 4 and w 1 3 + w 1 4 w 1 1 + w 1 2 ,
which are contradictory. The final two conditions reduce to
w 1 1 + w 1 3 w 1 2 + w 1 4 and w 1 2 + w 1 4 w 1 1 + w 1 3 ,
which are also contradictory. Therefore there is no hyperplane that can
separate these two categories.
ii. There are many different multilayer networks that could solve this problem. We will design a network by first noting that for the Class I vectors
either the first two elements or the last two elements will be 1. The Class
II vectors have alternating 1 and -1 patterns. This leads to the network
shown in Figure P11.2.
AND Operations
Inputs
p1
p2
p3
p4
n11
OR Operation
a11
2
-1
1
n2
1
a2
1
n21
a21
-1
1
11-28
Solved Problems
The first neuron in the first layer tests the first two elements of the input
vector. If they are both 1 it outputs a 1, otherwise it outputs a -1. The
second neuron in the first layer tests the last two elements of the input vector in the same way. Both of the neurons in the first layer perform AND operations. The second layer of the network tests whether either of the
outputs of the first layer are 1. It performs an OR operation. In this way,
the network will output a 1 if either the first two elements or the last two
elements of the input vector are both 1.
P11.2 Figure P11.3 illustrates a classification problem, where Class I vectors are represented by light circles, and Class II vectors are represented by dark circles. These categories are not linearly
separable. Design a multilayer network to correctly classify these
categories.
8
9
11
10
11-29
11
11 Backpropagation
1 T
1
0
0
0
1
0
0
0
1
0
0
0
0
1
1
0
0
1
0
0
0
0
0
1
0
0
1
1
0
1
1
1
0
0
1
0
0
3
1 , bT = 3 .
0
3
1
3
The four decision boundaries for the second layer are shown in Figure
P11.5. For example, the neuron 2 decision boundary is obtained by combining the boundaries 5, 6, 9 and 11 from layer 1. This can be seen by looking
2
at row 2 of W .
1
4
W = 1 1 1 1 ,b = 3 .
The complete network is shown in Figure P11.6.
The procedure that we used to develop this network can be used to solve
classification problems with arbitrary decision boundaries as long as we
have enough neurons in the hidden layers. The idea is to use the first layer
to create a number of linear boundaries, which can be combined by using
AND neurons in the second layer and OR neurons in the third layer. The
decision regions of the second layer are convex, but the final decision
boundaries created by the third layer can have arbitrary shapes.
11-30
Solved Problems
Input
p
2x1
1
2
Initial Decisions
W1
11 x 2
AND Operations
a1
n1
11 x 1
4x1
11
1x1
n3
1x4
4x1
b2
a3
W3
4x1
n2
4 x 11
11 x 1
b1
a2
W2
11 x 1
OR Operation
1x1
b3
1x1
a = W p+b
2
2 1
2 1
a = W a + b = W W p + W b + b ,
3
3 2
2 1
3 2
a = W a + b = W W W p + W W b + W b + b .
If we continue this process we can see that for an M-layer linear network,
the equivalent single-layer linear network would have the following weight
matrix and bias vector
M
W = W W
M1
W W ,
11
11-31
11 Backpropagation
b = W W
M1
W b + W W
M1
W b + + b .
3
P11.4 The purpose of this problem is to illustrate the use of the chain
rule. Consider the following dynamic system:
y k + 1 = fyk .
We want to choose the initial condition y 0 so that at some final
time k = K the system output y K will be as close as possible to
some target output t . We will minimize the performance index
F y 0 = t yK
Fy0 .
y0
Find a procedure for computing this using the chain rule.
The gradient is
2
t y K
F y0 =
= 2t yK
y K .
y0
y0
y 0
The key term is
yK
,
y0
which cannot be computed directly, since y K is not an explicit function of
y 0 . Lets define an intermediate term
rk
y k .
y 0
y k + 1 y k
y k + 1
y k
y 0
= -------------------- = f y k .
y k
y k
Therefore the recursive equation for the computation of r k is
11-32
Solved Problems
r k + 1 = f y k r k .
This is initialized at k = 0 :
y 0
r 0 = ------------- = 1 .
y 0
The total procedure for computing the gradient is then
r0 = 1 ,
r k + 1 = f y k r k , for k = 0 1 K 1 ,
F y 0 = 2 t y K r K .
y0
P11.5 Consider the two-layer network shown in Figure P11.8. The initial
weights and biases are set to
1
w = 1 , b = 1 , w = 2 , b = 1 .
An input/target pair is given to be
( p = 1 , t = 1 ) .
2
ii. Using part (i) find e w at the initial weights and biases.
iii. Repeat part (ii) using backpropagation and compare results.
Inputs
Log-Sigmoid Layer
w1
n1
a1
Linear Layer
w2
a 1 = logsig (w 1 p + b 1)
a2
b2
n2
1
a 2 = purelin (w 2 a 1 + b 2)
11
11-33
11 Backpropagation
2
2
1
2
2 2
- + b 2 .
e = t a = t w --------------------------------------------------------1
1
1 + exp w p + b
1
e
e
1
1
-----------= 2e --------1- = 2e w -----------------------------------------------------------2- exp w p + b p
1
1
1
w
w
1 + exp w p + b
1
+
exp
11 + 1
1 + exp w p + b
2
2 1
a = w a + b = 2 0.8808 + 1 = 0.7616
2
e = t a = 1 0.7616 = 1.7616
2
2
1
e
1
1
-----------= 2e w -----------------------------------------------------------2- exp w p + b p
1
1
1
w
1 + exp w p + b
1
= 2 1.7616 2 ----------------------------------------------------------2- exp 1 1 + 1 1
1 + exp 1 1 + 1
1
= 3.5232 0.2707 -------------------2- = 0.7398 .
1.289
iii. To backpropagate the sensitivities we use Eq. (11.44) and Eq. (11.45):
2 2
2
s = 2F (n ) t a = 2 1 1 0.7616 = 3.5232 ,
1 1
1
2 T 2
1
1
2
s = F (n ) W s = a 1 a 2 s
e
1 0
1
-----------= s a = s p = 0.7398 1 = 0.7398 .
1
w
This agrees with our result from part (ii).
11-34
Solved Problems
P11.6 Earlier in this chapter we showed that if the neuron transfer function is log-sigmoid,
1
-,
a = f n = --------------n
1+e
then the derivative can be conveniently computed by
fn = a1 a .
Find a convenient way to compute the derivative for the hyperbolic tangent sigmoid:
n
e e .
a = f n = tansig n = ----------------n
n
e +e
Computing the derivative directly we find
n
n
n
n
n
n
df n
e e -
e e - n n e + e
d -------------------------------------------------------e
=
+
f n = ------------ =
n
n
n
n 2
dn
d n e + e n
e +e
e + e
n
n 2
e e
2
= 1 -------------------------2 = 1 a .
n
n
e + e
P11.7 For the network shown in Figure P11.9 the initial weights and biases are chosen to be
1
w 0 = 1 , b 0 = 1 , w 0 = 2 , b 0 = 1 .
An input/target pair is given to be
( p = 1 , t = 1 ) .
Perform one iteration of backpropagation with = 1 .
11
11-35
11 Backpropagation
Inputs
Tan-Sigmoid Layer
w1
n1
Tan-Sigmoid Layer
w2
a1
b1
n2
a2
b2
a 1 = tansig (w 1 p + b 1)
a 2 = tansig (w 2 a 1 + b 2)
n = w p + b = 1 1 + 1 = 2
1
exp n exp n
exp 2 exp 2 1
1
- = ------------------------------------------= 0.964
a = tansig n = -----------------------------------------------1
1
exp
2 + exp 2
exp n + exp n
2
2 1
n = w a + b = 2 0.964 + 1 = 0.928
2
exp n exp n
exp 0.928 exp 0.928
2
2
- = ----------------------------------------------------------------a = tansig n = -----------------------------------------------2
2
exp
0.928 + exp 0.928
exp n + exp n
= 0.7297
2
e = t a = 1 0.7297 = 1.7297
Now we backpropagate the sensitivities using Eq. (11.44) and Eq. (11.45).
2 2
2
2 2
2
s = 2F (n ) t a = 2 1 a e = 2 1 0.7297 1.7297
= 1.6175
1 1
1
2 T 2
1 2
2 2
2
s = F (n ) W s = 1 a w s = 1 0.964 2 1.6175
= 0.2285
Finally, the weights and biases are updated using Eq. (11.46) and Eq.
(11.47):
2
1 T
11-36
Solved Problems
0 T
w 1 = w 0 s a = 1 1 0.2285 1 = 0.7715 ,
2
b 1 = b 0 s = 1 1 1.6175 = 2.6175 ,
1
b 1 = b 0 s = 1 1 0.2285 = 0.7715 .
P11.8 In Figure P11.10 we have a network that is a slight modification to
the standard two-layer feedforward network. It has a connection
from the input directly to the second layer. Derive the backpropagation algorithm for this network.
Input
Layer 1
Layer 2
W2,1
p
Rx1
1
R
a1
W1
n1
S1 x R
f1
S1 x 1
S1 x 1
n2
S2 x S1
b1
S1 x 1
a2
W2
S2 x 1
f2
S2 x 1
b2
S2 x 1
S1
S2
n = W p+b ,
1
a = f (n ) = f (W p + b ) ,
2
2 1
n = W a +W
2
2 1
2 1
p+b ,
a = f (n ) = f (W a + W
2 1
p+b ).
The backpropagation equations for the sensitivities will not change from
those for a standard two-layer network. The sensitivities are the derivatives of the squared error with respect to the net inputs; these derivatives
dont change, since we are simply adding a term to the net input.
Next we need the elements of the gradient for the weight update equations.
For the standard weights and biases we have
11
11-37
11 Backpropagation
n i
F
F
m1
-------------------------- = sm
=
,
i aj
m
m
m
w i j
n i w i j
m
F
F n
--------m- = --------m- --------im- = s m
i .
n i b i
b i
1
n i
n i
F
F
2
-------2- -----------------------.
-----------=
=
s
i
2 1
2 1
2 1
w i j
n i w i j
w i j
To find the derivative on the right-hand side of this equation note that
S
2
ni
R
2 1
w i j a j
j=1
2 1
w i j p j + bi .
2
j=1
Therefore
2
n i
F
------------ = p j and ------------- = s 2i p j .
2 1
2 1
w i j
w i j
W k + 1 = W k s a
m
m1 T
, m = 1 2 ,
b k + 1 = b k s , m = 1 2 .
W
2 1
k + 1 = W
2 1
0 T
k s a = W
2 1
k s p .
The main point of this problem is that the backpropagation concept can be
used on networks more general than the standard multilayer feedforward
network.
P11.9 Find an algorithm, based on the backpropagation concept, that
can be used to update the weights w 1 and w 2 in the recurrent network shown in Figure P11.11.
11-38
Solved Problems
Inputs
w2
p(k)
w1
n(k)
a(k + 1)
a(k)
a(0)
2
2
Fx = tk ak = e k .
For our weight updates we will use the steepest descent algorithm:
F x .
w i =
wi
These derivatives can be computed as follows:
a k
2
t k a k = 2 t k a k ------------- .
Fx =
wi
wi
w i
Therefore, the key terms we need to compute are
a k
------------.
w i
To compute these terms we first need to write out the network equation:
a k + 1 = purelin w 1 p k + w 2 a k = w 1 p k + w 2 a k .
Next we take the derivative of both sides of this equation with respect to
the network weights:
a k + 1
a k
----------------------- = p k + w 2 ------------- ,
w 1
w 1
a k
a k + 1 -
---------------------= a k + w 2 ------------- .
w 2
w 2
11-39
11
11 Backpropagation
(Note that we had to take account of the fact that a k is itself a function
of w 1 and w 2 .) These two recursive equations are then used to compute the
derivatives needed for the steepest descent weight update. The equations
are initialized with
a 0
a 0
-------------- = 0 , -------------- = 0 ,
w 1
w 2
since the initial condition is not a function of the weight.
To illustrate the process, lets say that a 0 = 0 . The first network update
would be
a 1 = w1 p 0 + w2 a 0 = w1 p 0 .
The first derivatives would be computed:
a 1
a 0
a 1
a 0
-------------- = p 0 + w 2 -------------- = p 0 , -------------- = a 0 + w 2 -------------- = 0 .
w 1
w 1
w 2
w 2
The first weight updates would be
a 1
F x
w i =
= 2 t 1 a 1 --------------
wi
w i
w 1 = 2 t 1 a 1 p 0
w 2 = 2 t 1 a 1 0 = 0 .
This algorithm is a type of dynamic backpropagation, in which the gradient
is computed by means of a difference equation.
P11.10 Show that backpropagation reduces to the LMS algorithm for a
single-layer linear network (ADALINE).
The sensitivity calculation for a single-layer linear network would be:
1 1
1
s = 2F (n ) t a = 2 I t a = 2e ,
0 T
W k + 1 = W k s a = W k 2e p = W k + 2ep
1
b k + 1 = b k s = b k 2e = b k + 2e .
This is identical to the LMS algorithm of Chapter 10.
11-40
Epilogue
Epilogue
In this chapter we have presented the multilayer perceptron network and
the backpropagation learning rule. The multilayer network is a powerful
extension of the single-layer perceptron network. Whereas the single-layer
network is only able to classify linearly separable patterns, the multilayer
network can be used for arbitrary classification problems. In addition, multilayer networks can be used as universal function approximators. It has
been shown that a two-layer network, with sigmoid-type transfer functions
in the hidden layer, can approximate any practical function, given enough
neurons in the hidden layer.
The backpropagation algorithm is an extension of the LMS algorithm that
can be used to train multilayer networks. Both LMS and backpropagation
are approximate steepest descent algorithms that minimize squared error.
The only difference between them is in the way in which the gradient is calculated. The backpropagation algorithm uses the chain rule in order to
compute the derivatives of the squared error with respect to the weights
and biases in the hidden layers. It is called backpropagation because the
derivatives are computed first at the last layer of the network, and then
propagated backward through the network, using the chain rule, to compute the derivatives in the hidden layers.
One of the major problems with backpropagation has been the long training times. It is not feasible to use the basic backpropagation algorithm on
practical problems, because it can take weeks to train a network, even on
a large computer. Since backpropagation was first popularized, there has
been considerable work on methods to accelerate the convergence of the algorithm. In Chapter 12 we will discuss the reasons for the slow convergence of backpropagation and will present several techniques for
improving the performance of the algorithm.
Another key problem in training multilayer networks is overfitting. The
network may memorize the data in the training set, but fail to generalize
to new situations. In Chapter 13 we will describe in detail training procedures that can be used to produce networks with excellent generalization.
This chapter has focused mainly on the theoretical development of the
backpropagation learning rule for training multilayer networks. Practical
aspects of training networks with this method are discussed in Chapter 22.
Real-world case studies that demonstrate how to train and validate multilayer networks are provided in Chapter 23 (function approximation), Chapter 24 (probability estimation) and Chapter 25 (pattern recognition).
11
11-41
11 Backpropagation
Further Reading
[HoSt89]
[LeCu85]
[Park85]
D. B. Parker, Learning-logic: Casting the cortex of the human brain in silicon, Technical Report TR-47, Center for
Computational Research in Economics and Management
Science, MIT, Cambridge, MA, 1985.
David Parker independently derived the backpropagation
algorithm at about the same time as Le Cun and Rumelhart, Hinton and Williams. This report describes his algorithm.
[RuHi86]
[RuMc86]
D. E. Rumelhart and J. L. McClelland, eds., Parallel Distributed Processing: Explorations in the Microstructure of
Cognition, vol. 1, Cambridge, MA: MIT Press, 1986.
This book was one of the two key influences in the resurgence of interest in the neural networks field during the
1980s. Among other topics, it presents the backpropagation
algorithm for training multilayer neural networks.
[Werbo74]
Further Reading
11
11-43
11 Backpropagation
Exercises
E11.1 Design multilayer networks to perform the classifications illustrated in
Figure E11.1. The network should output a 1 whenever the input vector is
in the shaded region (or on the boundary) and a -1 otherwise. Draw the network diagram in abbreviated notation and show the weight matrices and
bias vectors.
i.
ii.
iii.
iv.
11-44
Exercises
i.
ii.
2
2
2
2
iii.
iv.
2
2
2
2
Linear Layer 1
Inputs
p1
-2
-1
p2
1
3
n 11
Linear Layer 2
a 11
1
-0.5
1
n 12
a 12
n 21
a 21
0.5
-0.5
1
11
11-45
11 Backpropagation
E11.4 Use the chain rule to find the derivative f w in the following cases:
2
i. f n = sin n , n w = w .
ii. f n = tanh n , n w = 5w .
iii. f n = exp n , n w = cos w .
iv. f n = logsig n , n w = exp w .
E11.5 Consider again the backpropagation example that begins on page 11-14.
2
ii. Using part (i), find e w 1 1 at the initial weights and biases.
iii. Compare the results of part (ii) with the backpropagation results described in the text.
E11.6 For the network shown in Figure E11.4 the initial weights and biases are
chosen to be
1
w 0 = 1 , b 0 = 2 , w 0 = 1 , b 0 = 1 .
The network transfer functions are
1
1
2
2
f n = n , f n = --- ,
n
and an input/target pair is given to be
p = 1 t = 1 .
Perform one iteration of backpropagation with = 1 .
Inputs
Layer 1
w1
n1
Layer 2
f1
b1
1
a 1 = f 1(w 1 p + b 1)
a1
w2
n2
f2
a2
b2
1
a 2 = f 2 (w 2 a 1 + b 2)
11-46
Exercises
Inputs
Linear Layer
1
w 1,1
Linear Layer
1
n1
a1
w21,1
b11
p
1
w 2,1
a2
n2
a2
n11
1
b1
2
w 1,2 1
b12
1
1
a = purelin(W p + b )
2 1
a = purelin(W a + b )
W 0 =
1
1 , W2 0 =
2 , b2 0 =
1 1 , b 0 =
3
1
1
i. Apply the input to the network and make one pass forward through
the network to compute the output and the error.
ii. Compute the sensitivities by backpropagating through the network.
2
f n = n ,
and an input/target pair is given to be
1 t = 8 .
p =
1
2
11
11-47
11 Backpropagation
Inputs
Layer 1
1
p1
-1
f1
a 11
p2
n 11
n 12
f1
a 12
1
Figure E11.6 Single-Layer Network for Exercise E11.8
E11.9 We want to train the network in Figure E11.7 using the standard backpropagation algorithm (approximate steepest descent).
Inputs
p1
p2
w1,1
n
S
w1,2
f(n) = n2
b
1
a = (Wp + b)
1 t=
p =
0
1
11-48
Exercises
iv. Compute the gradient of the squared error with respect to the
weights and bias.
v. Update the weights and bias (assume a learning rate of = 0.1).
E11.10 Consider the following multilayer perceptron network. (The transfer func2
Inputs
p
2x1
Square
- Title
Law
1 Layer
a1
W1
n1
2x2
Linear
- TitleLayer
2-
2x1
W2
2x1
1x2
a2
n2
1x1
1x1
2x1
1x1
- Exp 1 -1p+b1)
a1 = square(W
- Exp 2 2-a1+b2)
a2 = purelin(W
1 t=
p =
2
1
11
11-49
11 Backpropagation
Layer 1
Inputs
w1
SxR
Layer 2
n1
a1
w2
n2
SxR
b1
a2
b2
a1 = (w1p+b1) 3
a2 = (w2a1+b2) 2
w 0 = 2 b 0 = 1 w 0 = 1 b 0 = 2 .
An input/target pair is given to be
p 1 = 1 t 1 = 0 ,
Perform one iteration of backpropagation (steepest descent) with = 1.
E11.12 Consider the multilayer perceptron network in Figure E11.10. (The trans3
Inputs
p1
2x1
Linear Layer
a1
2x1
n1
2x2
a2
1x2
2x1
1
2
1x1
b1
2x1
1
S
1
a = cube(W p + b )
b2
1x1
2
1
2 1
a = W a +b
11-50
1x1
Exercises
1
1
2
2
W 0 = 1 1 , b 0 = 1 , W 0 = 1 1 , b 0 = 1 .
1 0
2
1 t =
p =
1 .
1
E11.13 Someone has proposed that the standard multilayer network should be
modified to include a scalar gain at each layer. This means that the net input at layer m would be computed as
n
m m1
= W a
+b ,
where is the scalar gain at layer m. This gain would be trained like the
weights and biases of the network. Modify the backpropagation algorithm
(Eq. (11.41) to Eq. (11.47)) for this new network. (There will need to be a
m
new equation added to update , but some of the other equations may
have to be modified as well.)
E11.14 Consider the two-layer network shown in Figure E11.11.
Inputs
Log-Sigmoid Layer
1
n1
Linear Layer
1
a1
2
-1
p
1
1
n2
S
1
a12
n2
a2
-1
3
1
1
Figure E11.11 Two-Layer Network for Exercise E11.14
i. If p = 1, use a (slightly) modified form of backpropagation (as developed in Eq. (11.41) through Eq. (11.47)) to find
11
11-51
11 Backpropagation
,
2
,
1
2
1
n1 n2
.
2
a
.
p
Your answers to both parts should be numerical.
E11.15 Consider the network shown in Figure E11.12, where the inputs to the neuron involve both the original inputs and their product. This is a type of
higher-order network.
Inputs
p1
Log-Sigmoid Layer
w1
w1,2
p2
w2
1
a = logsig(w1 p1 + w2 p2 + w1,2 p1 p2 + b)
Figure E11.12 Higher-Order Network
i. Find a learning rule for the network parameters, using the approximate steepest descent algorithm (as was done for backpropagation).
ii. For the following initial parameter values, inputs and target, perform one iteration of your learning rule with learning rate = 1:
w 1 = 1 w 2 = 1 w 1 2 = 0.5 b 1 = 1 p 1 = 0 p 2 = 1 t = 0.75
E11.16 In Figure E11.13 we have a two-layer network that has an additional connection from the input directly to the second layer. Derive the backpropagation algorithm for this network.
11-52
Exercises
Inputs
Layer 1
Layer 2
w 2,1
w1
n1
a1
f1
w2
b1
n2
a2
f2
b2
a 1 = f 1(w 1 p + b 1)
a 2 = f 2 (w 2 a 1 + w 2,1 p + b 2)
m+1
= W
m+1 m
a +b
m+1
or
m+1
ni
w i j
m+1 m
aj
m+1
+ bi
j=1
w i j
m+1
m 2
aj
j=1
E11.18 Consider again the net input calculation, as described in Exercise E11.17.
If the net input calculation is changed to the following equation (multiply
by the bias, instead of add), how will the sensitivity backpropagation (Eq.
(11.35)) change?
m
m+1
ni
m + 1 m
m+1
.
= w i j a j b i
j = 1
E11.19 Consider the system shown in Figure E11.14. There are a series of stages,
with different transfer functions in each stage. (There are no weights or biM
ases.) We want to take the derivative of the output of this system ( a ) with
respect to the input of the system ( p ). Derive a recursive algorithm that
you can use to compute this derivative. Use the concepts that we used to
derive the backpropagation algorithm, and use the following intermediate
variable in your algorithm:
11-53
11
11 Backpropagation
a
i
q = ---------i- .
a
f2
f1
F
--------2- .
w
What form will the chain rule take in this case?
E11.22 The standard steepest descent backpropagation algorithm, which is summarized in Eq. (11.41) through Eq. (11.47), was designed to minimize the
performance function that was the sum of squares of the network errors, as
given in Eq. (11.12). Suppose that we want to change the performance function to the sum of the fourth powers of the errors (e4) plus the sum of the
squares of the weights and biases in the network. Show how Eq. (11.41)
11-54
Exercises
through Eq. (11.47) will change for this new performance function. (You
don't need to rederive any steps which are already given in this chapter and
do not change.)
E11.23 Repeat Problem P11.4 using the backward method described below.
In Problem P11.4. we had the dynamic system
y k + 1 = fyk .
We had to choose the initial condition y 0 so that at some final time k = K
the system output y K would be as close as possible to some target output
t . We minimized the performance index
2
Fy0 = t yK = e K
using steepest descent, so we needed the gradient
Fy0 .
y0
We developed a procedure for computing this gradient using the chain rule.
The procedure involved a recursive equation for the term
rk
y k ,
y 0
which evolved forward in time. The gradient can also be computed in a different way by evolving the term
qk
2
e K
yk
p(k)
S
a(k-1)
n(k)
a(k)
D
a(k) = p(k) + w a(k-1)
Figure E11.15 Recurrent Network
11
11-55
11 Backpropagation
We want to find the weight value w so that at some final time k = K the
system output a K will be as close as possible to some target output t . We
2
will minimize the performance index F w = t a K using steepest descent, so we need the gradient F w /w .
i. Find a general procedure to compute this gradient using the chain
rule. Develop an equation to evolve the following term forward
through time:
s k
ak .
w
Show each step of your entire procedure carefully. This will involve
updating s k and also computing the gradient F w /w .
ii. Assume that K = 3 . Write out the complete expression for a 3 as
a function of p 1 , p 2 , p 3 and w (assuming a 0 = 0 ). Take the
derivative of this expression with respect to w , and show that it
equals s 3 .
2+2
ans =
4
11-56
Objectives
12
12
Variations on
Backpropagation
Objectives
12-1
12-2
Drawbacks of Backpropagation
12-3
12-3
Convergence Example
12-7
12-9
Momentum
12-9
12-12
12-14
Conjugate Gradient
12-14
Levenberg-Marquardt Algorithm
12-19
Summary of Results
12-28
Solved Problems
12-32
Epilogue
12-46
Further Reading
12-47
Exercises
12-50
Objectives
The backpropagation algorithm introduced in Chapter 11 was a major
breakthrough in neural network research. However, the basic algorithm is
too slow for most practical applications. In this chapter we present several
variations of backpropagation that provide significant speedup and make
the algorithm more practical.
We will begin by using a function approximation example to illustrate why
the backpropagation algorithm is slow in converging. Then we will present
several modifications to the algorithm. Recall that backpropagation is an
approximate steepest descent algorithm. In Chapter 9 we saw that steepest
descent is the simplest, and often the slowest, minimization method. The
conjugate gradient algorithm and Newtons method generally provide faster convergence. In this chapter we will explain how these faster procedures
can be used to speed up the convergence of backpropagation.
12-1
12 Variations on Backpropagation
SDBP
We should emphasize that all of the algorithms that we will describe in this
chapter use the backpropagation procedure, in which derivatives are processed from the last layer of the network to the first. For this reason they
could all be called backpropagation algorithms. The differences between
the algorithms occur in the way in which the resulting derivatives are used
to update the weights. In some ways it is unfortunate that the algorithm
we usually refer to as backpropagation is in fact a steepest descent algorithm. In order to clarify our discussion, for the remainder of this chapter
we will refer to the basic backpropagation algorithm as steepest descent
backpropagation (SDBP).
In the next section we will use a simple example to explain why SDBP has
problems with convergence. Then, in the following sections, we will present
various procedures to improve the convergence of the algorithm.
12-2
Drawbacks of Backpropagation
12
Drawbacks of Backpropagation
Recall from Chapter 10 that the LMS algorithm is guaranteed to converge
to a solution that minimizes the mean squared error, so long as the learning rate is not too large. This is true because the mean squared error for a
single-layer linear network is a quadratic function. The quadratic function
has only a single stationary point. In addition, the Hessian matrix of a quadratic function is constant, therefore the curvature of the function in a given direction does not change, and the function contours are elliptical.
SDBP is a generalization of the LMS algorithm. Like LMS, it is also an approximate steepest descent algorithm for minimizing the mean squared error. In fact, SDBP is equivalent to the LMS algorithm when used on a
single-layer linear network. (See Problem P11.10.) When applied to multilayer networks, however, the characteristics of SDBP are quite different.
This has to do with the differences between the mean squared error performance surfaces of single-layer linear networks and multilayer nonlinear
networks. While the performance surface for a single-layer linear network
has a single minimum point and constant curvature, the performance surface for a multilayer network may have many local minimum points, and
the curvature can vary widely in different regions of the parameter space.
This will become clear in the example that follows.
Input
Log-Sigmoid Layer
w11,1
p
w12,1
n11
a11
Log-Sigmoid Layer
w21,1
b11
n12
a12
b12
w21,2
n2
a2
b2
1
a1 = logsig (W1p + b1)
12-3
12 Variations on Backpropagation
the response of the same 1-2-1 network, with the following values for the
weights and biases:
1
(12.1)
w 1 1 = 1 , w 1 2 = 1 , b = 1 .
(12.2)
w 1 1 = 10 , w 2 1 = 10 , b 1 = 5 , b 2 = 5 ,
2
The network response for these parameters is shown in Figure 12.2, which
2
plots the network output a as the input p is varied over the range 2 2 .
1
0.75
0.5
0.25
0
-2
-1
p
Figure 12.2 Nominal Function
We want to train the network of Figure 12.1 to approximate the function
displayed in Figure 12.2. The approximation will be exact when the network parameters are set to the values given in Eq. (12.1) and Eq. (12.2).
This is, of course, a very contrived problem, but it is simple and it illustrates some important concepts.
Lets now consider the performance index for our problem. We will assume
that the function is sampled at the values
p = 2 1.9 1.8 1.9 2 ,
(12.3)
and that each occurs with equal probability. The performance index will be
the sum of the squared errors at these 41 points. (We wont bother to find
the mean squared error, which just requires dividing by 41.)
In order to be able to graph the performance index, we will vary only two
parameters at a time. Figure 12.3 illustrates the squared error when only
1
2
w 1 1 and w 1 1 are being adjusted, while the other parameters are set to
their optimal values given in Eq. (12.1) and Eq. (12.2). Note that the mini1
2
mum error will be zero, and it will occur when w 1 1 = 10 and w 1 1 = 1 , as
indicated by the open blue circle in the figure.
12-4
Drawbacks of Backpropagation
There are several features to notice about this error surface. First, it is
clearly not a quadratic function. The curvature varies drastically over the
parameter space. For this reason it will be difficult to choose an appropriate learning rate for the steepest descent algorithm. In some regions the
surface is very flat, which would allow a large learning rate, while in other
regions the curvature is high, which would require a small learning rate.
(Refer to discussions in Chapters 9 and 10 on the choice of learning rate for
the steepest descent algorithm.)
It should be noted that the flat regions of the performance surface should
not be unexpected, given the sigmoid transfer functions used by the network. The sigmoid is very flat for large inputs.
A second feature of this error surface is the existence of more than one local
1
minimum point. The global minimum point is located at w 1 1 = 10 and
2
1
w 1 1 = 1 , along the valley that runs parallel to the w 1 1 axis. However,
there is also a local minimum, which is located in the valley that runs par2
allel to the w 1 1 axis. (This local minimum is actually off the graph at
1
2
w 1 1 = 0.88 , w 1 1 = 38.6 .) In the next section we will investigate the performance of backpropagation on this surface.
15
10
10
5
2
w 1 1
0
-5
-5
0
2
w 1 1
-5
-5
10
10
15
15
10
1
1 1
15
w 1 1
1
Figure 12.4 illustrates the squared error when w 1 1 and b 1 are being adjusted, while the other parameters are set to their optimal values. Note
1
that the minimum error will be zero, and it will occur when w 1 1 = 10 and
1
b 1 = 5 , as indicated by the open blue circle in the figure.
Again we find that the surface has a very contorted shape, steep in some
regions and very flat in others. Surely the standard steepest descent algorithm will have some trouble with this surface. For example, if we have an
1
1
initial guess of w 1 1 = 0 , b 1 = 10 , the gradient will be very close to zero,
12-5
12
12 Variations on Backpropagation
and the steepest descent algorithm would effectively stop, even though it is
not close to a local minimum point.
15
2.5
5
2
1.5
b1
-5
0.5
0
-10
-15
0
1
w 1 1
-25
-10
10
20
10
20
30
30
-20
-30
-10
10
20
1
1
1
1 1
Figure 12.5 illustrates the squared error when b 1 and b 2 are being adjusted, while the other parameters are set to their optimal values. The mini1
1
mum error is located at b 1 = 5 and b 2 = 5 , as indicated by the open blue
circle in the figure.
This surface illustrates an important property of multilayer networks: they
have a symmetry to them. Here we see that there are two local minimum
points and they both have the same value of squared error. The second solution corresponds to the same network being turned upside down (i.e., the
top neuron in the first layer is exchanged with the bottom neuron). It is because of this characteristic of neural networks that we do not set the initial
weights and biases to zero. The symmetry causes zero to be a saddle point
of the performance surface.
This brief study of the performance surfaces for multilayer networks gives
us some hints as to how to set the initial guess for the SDBP algorithm.
First, we do not want to set the initial parameters to zero. This is because
the origin of the parameter space tends to be a saddle point for the performance surface. Second, we do not want to set the initial parameters to large
values. This is because the performance surface tends to have very flat regions as we move far away from the optimum point.
Typically we choose the initial weights and biases to be small random values. In this way we stay away from a possible saddle point at the origin
without moving out to the very flat regions of the performance surface. (Another procedure for choosing the initial parameters is described in
[NgWi90].) As we will see in the next section, it is also useful to try several
different initial guesses, in order to be sure that the algorithm converges to
a global minimum point.
12-6
Drawbacks of Backpropagation
12
10
1.4
5
b1
0.7
0
0
-10
-5
-10
-5
1
b1
-10
-10
-5
10
-5
5
10
1
2
10
b1
1
Convergence Example
Batching
Now that we have examined the performance surface, lets investigate the
performance of SDBP. For this section we will use a variation of the standard algorithm, called batching, in which the parameters are updated only
after the entire training set has been presented. The gradients calculated
at each training example are averaged together to produce a more accurate
estimate of the gradient. (If the training set is complete, i.e., covers all possible input/output pairs, then the gradient estimate will be exact.)
In Figure 12.6 we see two trajectories of SDBP (batch mode) when only two
1
2
parameters, w 1 1 and w 1 1 are adjusted. For the initial condition labeled
a the algorithm does eventually converge to the optimal solution, but the
convergence is slow. The reason for the slow convergence is the change in
curvature of the surface over the path of the trajectory. After an initial
moderate slope, the trajectory passes over a very flat surface, until it falls
into a very gently sloping valley. If we were to increase the learning rate,
the algorithm would converge faster while passing over the initial flat surface, but would become unstable when falling into the valley, as we will see
in a moment.
Trajectory b illustrates how the algorithm can converge to a local minimum point. The trajectory is trapped in a valley and diverges from the optimal solution. If allowed to continue the trajectory converges to
1
2
w 1 1 = 0.88 , w 1 1 = 38.6 . The existence of multiple local minimum points
is typical of the performance surface of multilayer networks. For this reason it is best to try several different initial guesses in order to ensure that
a global minimum has been obtained. (Some of the local minimum points
may have the same value of squared error, as we saw in Figure 12.5, so we
would not expect the algorithm to converge to the same parameter values
for each initial guess. We just want to be sure that the same minimum error
is obtained.)
12-7
12 Variations on Backpropagation
15
10
w 1 1
a
-5
-5
10
15
w 1 1
1.5
1
2
0.5
0 0
10
10
Iteration Number
10
0 0
10
10
10
Iteration Number
10
12-8
1.5
10
Squared Error
2
5
1 1
0.5
0
0 0
10
-5
-5
10
10
10
Iteration Number
10
15
w 1 1
Momentum
The first method we will discuss is the use of momentum. This is a modification based on our observation in the last section that convergence might
be improved if we could smooth out the oscillations in the trajectory. We
can do this with a low-pass filter.
Before we apply momentum to a neural network application, lets investigate a simple example to illustrate the smoothing effect. Consider the following first-order filter:
12-9
12
12 Variations on Backpropagation
y k = y k 1 + 1 w k ,
(12.4)
where w k is the input to the filter, y k is the output of the filter and
is the momentum coefficient that must satisfy
01.
(12.5)
The effect of this filter is shown in Figure 12.9. For these examples the input to the filter was taken to be the sine wave:
2k
w k = 1 + sin --------- ,
16
(12.6)
and the momentum coefficient was set to = 0.9 (left graph) and = 0.98
(right graph). Here we can see that the oscillation of the filter output is less
than the oscillation in the filter input (as we would expect for a low-pass
filter). In addition, as is increased the oscillation in the filter output is
reduced. Notice also that the average filter output is the same as the average filter input, although as is increased the filter output is slower to respond.
2
1.5
1.5
0.5
0.5
0
0
50
100
150
a) = 0.9
200
0
0
50
100
b) = 0.98
150
200
W k = s a
m
m1 T
b k = s .
12-10
(12.7)
(12.8)
Momentum
MOBP
W k = W k 1 1 s a
m
m1 T
(12.9)
b k = b k 1 1 s .
(12.10)
1.5
Squared Error
10
2
5
1 1
0.5
0
-5
-5
0 0
10
0
10
10
10
Iteration Number
10
15
w 1 1
12-11
12
12 Variations on Backpropagation
There are many different approaches for varying the learning rate. We will
describe a very straightforward batching procedure [VoMa88], where the
learning rate is varied according to the performance of the algorithm. The
rules of the variable learning rate backpropagation algorithm (VLBP) are:
1. If the squared error (over the entire training set) increases by more
than some set percentage (typically one to five percent) after a
weight update, then the weight update is discarded, the learning rate
is multiplied by some factor 0 1 , and the momentum coefficient
(if it is used) is set to zero.
2. If the squared error decreases after a weight update, then the weight
update is accepted and the learning rate is multiplied by some factor
1 . If has been previously set to zero, it is reset to its original value.
3. If the squared error increases by less than , then the weight update
is accepted but the learning rate is unchanged. If has been previously
set to zero, it is reset to its original value.
(See Problem P12.3 for a numerical example of VLBP.)
To illustrate VLBP, lets apply it to the function approximation problem of
the previous section. Figure 12.11 displays the trajectory for the algorithm
using the same initial guess, initial learning rate and momentum coefficient as was used in Figure 12.10. The new parameters were assigned the
values
= 1.05 , = 0.7 and = 4% .
12-12
(12.11)
12
15
10
w 1 1
-5
-5
10
15
w 1 1
60
Squared Error
40
0.5
20
0 0
10
10
10
Iteration Number
10
0 0
10
Learning Rate
10
10
Iteration Number
10
12-13
12 Variations on Backpropagation
has been in the same direction for several iterations. If the direction of the
parameter change alternates, then the learning rate is reduced. The SuperSAB algorithm of Tollenaere [Toll90] is similar to the delta-bar-delta
rule, but it has more complex rules for adjusting the learning rates.
Another heuristic modification to SDBP is the Quickprop algorithm of
Fahlman [Fahl88]. It assumes that the error surface is parabolic and concave upward around the minimum point and that the effect of each weight
can be considered independently.
The heuristic modifications to SDBP can often provide much faster convergence for some problems. However, there are two main drawbacks to these
methods. The first is that the modifications require that several parameters be set (e.g., , and ), while the only parameter required for SDBP
is the learning rate. Some of the more complex heuristic modifications can
have five or six parameters to be selected. Often the performance of the algorithm is sensitive to changes in these parameters. The choice of parameters is also problem dependent. The second drawback to these
modifications to SDBP is that they can sometimes fail to converge on problems for which SDBP will eventually find a solution. Both of these drawbacks tend to occur more often when using the more complex algorithms.
To experiment with VLBP, use the MATLAB Neural Network Design Demonstration Variable Learning Rate Backpropagation (nnd12vl).
Conjugate Gradient
In Chapter 9 we presented three numerical optimization techniques: steepest descent, conjugate gradient and Newtons method. Steepest descent is
the simplest algorithm, but is often slow in converging. Newtons method
is much faster, but requires that the Hessian matrix and its inverse be calculated. The conjugate gradient algorithm is something of a compromise; it
does not require the calculation of second derivatives, and yet it still has
the quadratic convergence property. (It converges to the minimum of a quadratic function in a finite number of iterations.) In this section we will describe how the conjugate gradient algorithm can be used to train
12-14
CGBP
multilayer networks. We will call this algorithm conjugate gradient backpropagation (CGBP).
Lets begin by reviewing the conjugate gradient algorithm. For ease of reference, we will repeat the algorithm steps from Chapter 9 (page 9-18):
1. Select the first search direction p 0 to be the negative of the gradient,
as in Eq. (9.59):
p0 = g0 ,
(12.12)
where
g k F x
x = xk
(12.13)
(12.14)
3. Select the next search direction according to Eq. (9.60), using Eq.
(9.61), Eq. (9.62), or Eq. (9.63) to calculate k :
pk = gk + k pk 1 ,
(12.15)
with
T
g k 1 g k
gk gk
g k 1 g k
k = -------------------------- or k = ---------------------- or k = ----------------------.
T
T
T
g k 1 p k 1
gk 1 gk 1
gk 1 gk 1
(12.16)
12-15
12
12 Variations on Backpropagation
Interval Location
(12.17)
(12.18)
F(x)
8
4
2
x
a1
b1
a2
b2
a3
b3
a4
a5
b4
b5
Now that we have located an interval containing the minimum, the next
step in the linear search is interval reduction. This will involve evaluating
the function at points inside the interval [a 5, b 5] , which was selected in the
interval location step. From Figure 12.14 we can see that we will need to
evaluate the function at two internal points (at least) in order to reduce the
size of the interval of uncertainty. Figure 12.14 (a) shows that one internal
function evaluation does not provide us with any information on the location of the minimum. However, if we evaluate the function at two points c
and d , as in Figure 12.14 (b), we can reduce the interval of uncertainty. If
12-16
F(x)
The procedure described above suggests a method for reducing the size of
the interval of uncertainty. We now need to decide how to determine the locations of the internal points c and d . There are several ways to do this
(see [Scal85]). We will use a method called the Golden Section search,
which is designed to reduce the number of function evaluations required.
At each iteration one new function evaluation is required. For example, in
the case illustrated in Figure 12.14 (b), point a would be discarded and
point c would become the new a . Then point d would become the new point
c , and a new d would be placed between the original points d and b . The
trick is to place the new point so that the interval of uncertainty will be reduced as quickly as possible.
The algorithm for the Golden Section search is as follows [Scal85]:
= 0.618
Set
c1 = a1 + 1 b1 a1 , Fc = F c1 .
d1 = b1 1 b1 a1 , Fd = F d1 .
For k = 1 2 repeat
If F c F d then
Set
ak + 1 = ak ; bk + 1 = dk ; dk + 1 = ck
ck + 1 = ak + 1 + 1 bk + 1 ak + 1
Fd = Fc ; Fc = F ck + 1
else
12-17
12
12 Variations on Backpropagation
Set
ak + 1 = ck ; bk + 1 = bk ; ck + 1 = dk
dk + 1 = bk + 1 1 bk + 1 ak + 1
Fc = Fd ; Fd = F dk + 1
end
end until b k + 1 a k + 1 tol
Where tol is the accuracy tolerance set by the user.
(See Problem P12.4 for a numerical example of the interval location and interval reduction procedures.)
There is one more modification to the conjugate gradient algorithm that
needs to be made before we apply it to neural network training. For quadratic functions the algorithm will converge to the minimum in at most n
iterations, where n is the number of parameters being optimized. The
mean squared error performance index for multilayer networks is not quadratic, therefore the algorithm would not normally converge in n iterations. The development of the conjugate gradient algorithm does not
indicate what search direction to use once a cycle of n iterations has been
completed. There have been many procedures suggested, but the simplest
method is to reset the search direction to the steepest descent direction
(negative of the gradient) after n iterations [Scal85]. We will use this method.
Lets now apply the conjugate gradient algorithm to the function approximation example that we have been using to demonstrate the other neural
network training algorithms. We will use the backpropagation algorithm to
compute the gradient (using Eq. (11.23) and Eq. (11.24)) and the conjugate
gradient algorithm to determine the weight updates. This is a batch mode
algorithm, as the gradient is computed after the entire training set has
been presented to the network.
Figure 12.15 shows the intermediate steps of the CGBP algorithm for the
first three iterations. The interval location process is illustrated by the
open blue circles; each one represents one evaluation of the function. The
final interval is indicated by the larger open black circles. The black dots in
Figure 12.15 indicate the location of the new interior points during the
Golden Section search, one for each iteration of the procedure. The final
point is indicated by a blue dot.
Figure 12.16 shows the total trajectory to convergence. Notice that the
CGBP algorithm converges in many fewer iterations than the other algorithms that we have tested. This is a little deceiving, since each iteration of
CGBP requires more computations than the other methods; there are
many function evaluations involved in each iteration of CGBP. Even so,
CGBP has been shown to be one of the fastest batch training algorithms for
multilayer networks [Char92].
12-18
12
15
10
w 1 1
-5
-5
10
15
w 1 1
1.5
Squared Error
10
1
2
w 1 1
0.5
0
-5
-5
0 0
10
0
10
10
Iteration Number
10
15
w 1 1
Levenberg-Marquardt Algorithm
The Levenberg-Marquardt algorithm is a variation of Newtons method
that was designed for minimizing functions that are sums of squares of other nonlinear functions. This is very well suited to neural network training
where the performance index is the mean squared error.
Basic Algorithm
Lets begin by considering the form of Newtons method where the performance index is a sum of squares. Recall from Chapter 9 that Newtons
method for optimizing a performance index F x is
12-19
12 Variations on Backpropagation
xk + 1 = xk Ak gk ,
where A k 2F x
x = xk
(12.19)
and g k F x
x = xk
Fx =
vi x
2
= v x v x ,
(12.20)
i=1
v i x
F x
-.
F x j = -------------- = 2 v i x -------------x j
x j
(12.21)
i=1
F x = 2J x v x ,
(12.22)
where
v 1 x v 1 x
v 1 x
--------------- ---------------- --------------x 1
x 2
x n
Jx =
v 2 x v 2 x
v 2 x
--------------- ---------------- --------------x 1
x 2
x n
v N x v N x
v N x
---------------- ---------------- ---------------x 1
x 2
x n
Jacobian Matrix
(12.23)
k j
vi x
v i x v i x
- --------------- + v i x ----------------.
-------------x k x j
x k x j
i=1
Fx
= ----------------- = 2
x k x j
(12.24)
2F x = 2J x J x + 2S x ,
where
12-20
(12.25)
12
vi x 2vi x .
Sx =
(12.26)
i=1
2F x 2J x J x .
Gauss-Newton
(12.27)
If we then substitute Eq. (12.27) and Eq. (12.22) into Eq. (12.19), we obtain
the Gauss-Newton method:
T
x k + 1 = x k 2J x k J x k 2J x k v x k
T
1 T
= x k J x k J x k J x k v x k .
(12.28)
(12.29)
To see how this matrix can be made invertible, suppose that the eigenvalues and eigenvectors of H are 1 2 n and z 1 z 2 z n . Then
Gz i = H + I z i = Hz i + z i = i z i + z i = i + z i .
(12.30)
1 T
x k + 1 = x k J x k J x k + k I J x k v x k .
(12.31)
or
T
1 T
x k = J x k J x k + k I J x k v x k .
(12.32)
This algorithm has the very useful feature that as k is increased it approaches the steepest descent algorithm with small learning rate:
12-21
12 Variations on Backpropagation
1 T
1
x k + 1 x k ----- J x k v x k = x k -------- F x , for large k ,
k
2 k
(12.33)
tq aq
Fx =
q=1
Q
tq aq
Q
T
eq eq
q=1
e j q
N
2
q = 1j = 1
vi
i=1
,
(12.34)
12-22
the basic concept is simple, the details of the implementation can be a little
tricky. For that reason you may want to skim through the rest of this section on your first reading, in order to obtain an overview of the general flow
of the presentation, and return later to pick up the details. It may also be
helpful to review the development of the backpropagation algorithm in
Chapter 11 before proceeding.
Before we present the procedure for computing the Jacobian, lets take a
closer look at its form (Eq. (12.23)). Note that the error vector is
T
v = v 1 v 2 v N = e 1 1 e 2 1 e M e 1 2 e M ,
S 1
S Q
(12.35)
x = x 1 x 2 x n = w 11 1 w 11 2 w 11 b 11 b 1 1 w 21 1 b MM , (12.36)
S R
S
S
N = QS
and n = S R + 1 + S S + 1 + + S S
1
M1
+ 1 .
Jx =
e S M 1 e S M 1
e S M 1 e SM 1
-------------------------
-------------- -------------
1
1
1
1
w 1 1 w 1 2
w S 1 R b 1
(12.37)
e 1 2 e 1 2
e 1 2 e 1 2
------------ ------------ -------------- -----------
1
1
1
1
w 1 1 w 1 2
w S 1 R b 1
The terms in this Jacobian matrix can be computed by a simple modification to the backpropagation algorithm.
Standard backpropagation calculates terms like
T
e q e q
F x
-------------- = --------------.
x l
x l
12-23
(12.38)
12
12 Variations on Backpropagation
For the elements of the Jacobian matrix that are needed for the LevenbergMarquardt algorithm we need to calculate terms like
v
e k q
.
J h l = -------h = ----------x l
x l
(12.39)
(12.40)
where the first term on the right-hand side was defined as the sensitivity:
F
m
s i --------m- .
n i
Marquardt Sensitivity
(12.41)
The backpropagation process computed the sensitivities through a recurrence relationship from the last layer backward to the first layer. We can
use the same concept to compute the terms needed for the Jacobian matrix
(Eq. (12.37)) if we define a new Marquardt sensitivity:
v h
e k q
m
,
- = ----------s i h ---------m
m
n i q
n i q
(12.42)
J h l
v
e k q
e k q n i q
n i q
m
m
m1
- = s i h ---------- = s i h a j q , (12.43)
---------= -------h = ----------= ----------m
m
m
m
x l
w i j
n i q w i j
w i j
or if x l is a bias,
m
e k q n i q
n i q
v
e k q
m
m
---------- = s i h ---------- = s i h .
J h l = -------h = ----------= ----------m
m
m
m
x l
b i
n i q b i
b i
(12.44)
12-24
s i h
12
v h
e k q
t k q a k q
a k q
= ---------- = ----------= ------------------------------ = ----------M
M
M
M
n i q
n i q
n i q
n i q
M M
f n i q for i = k
.
=
for i k
(12.45)
Therefore when the input p q has been applied to the network and the corM
responding network output a q has been computed, the Levenberg-Marquardt backpropagation is initialized with
M
S q = F n q ,
M
(12.46)
M
M
where F n is defined in Eq. (11.34). Each column of the matrix S q
must be backpropagated through the network using Eq. (11.35) to produce
one row of the Jacobian matrix. The columns can also be backpropagated
together using
m m
m
m+1 T m+1
S q = F (n q ) W
S q .
(12.47)
The total Marquardt sensitivity matrices for each layer are then created by
augmenting the matrices computed for each input:
S
= S 1 S 2 S Q .
(12.48)
Note that for each input that is presented to the network we will backpropM
agate S sensitivity vectors. This is because we are computing the derivatives of each individual error, rather than the derivative of the sum of
squares of the errors. For every input applied to the network there will be
M
S errors (one for each element of the network output). For each error
there will be one row of the Jacobian matrix.
After the sensitivities have been backpropagated, the Jacobian matrix is
computed using Eq. (12.43) and Eq. (12.44). See Problem P12.5 for a numerical illustration of the Jacobian computation.
LMBP
12 Variations on Backpropagation
10
w 1 1
-5
-5
10
15
w 1 1
12-26
Figure 12.18 shows the path of the LMBP trajectory to convergence, with
0 = 0.01 and = 5 . Note that the algorithm converges in fewer iterations than any of the methods we have discussed so far. Of course this algorithm also requires more computation per iteration than any of the other
algorithms, since it involves a matrix inversion. Even given the large number of computations, however, the LMBP algorithm appears to be the fastest neural network training algorithm for moderate numbers of network
parameters [HaMe94].
15
1.5
Squared Error
10
1
2
w 1 1
0.5
0
-5
-5
0 0
10
0
10
10
Iteration Number
10
15
w 1 1
12-27
12
12 Variations on Backpropagation
Summary of Results
Heuristic Variations of Backpropagation
Batching
The parameters are updated only after the entire training set has been presented. The gradients calculated for each training example are averaged
together to produce a more accurate estimate of the gradient. (If the training set is complete, i.e., covers all possible input/output pairs, then the gradient estimate will be exact.)
W k = W k 1 1 s a
m
b k = b k 1 1 s
m1 T
12-28
Summary of Results
12
x
a1
b1
a2
b2
a3
b3
a4
a5
b4
b5
c1 = a1 + 1 b1 a1 , Fc = F c1 .
d1 = b1 1 b1 a1 , Fd = F d1 .
For k = 1 2 repeat
If F c F d then
Set
ak + 1 = ak ; bk + 1 = dk ; dk + 1 = ck
ck + 1 = ak + 1 + 1 bk + 1 ak + 1
Fd = Fc ; Fc = F ck + 1
else
Set
ak + 1 = ck ; bk + 1 = bk ; ck + 1 = dk
dk + 1 = bk + 1 1 bk + 1 ak + 1
Fc = Fd ; Fd = F dk + 1
end
end until b k + 1 a k + 1 tol
12-29
12 Variations on Backpropagation
x k = J x k J x k + k I J x k v x k
T
v = v 1 v 2 v N = e 1 1 e 2 1 e M e 1 2 e M
S 1
S Q
T
x = x 1 x 2 x n = w 11 1 w 11 2 w 11
S R
N = QS
b1 b
1
1
S
w 1 1 b
M
and n = S R + 1 + S S + 1 + + S S
M1
M
M
S
+ 1
e 1 1 e 1 1
e 1 1 e 1 1
------------ ------------ -------------- -----------
1
1
1
1
w 1 1 w 1 2
w 1
b 1
S R
e 2 1 e 2 1
e 2 1 e 2 1
------------ ------------ -------------- -----------
1
1
1
1
w 1 1 w 1 2
w S 1 R b 1
Jx =
e S M 1 e SM 1
e S M 1 e SM 1
-------------------------- -------------- -------------
1
1
1
1
w 1 1 w 1 2
w S 1 R b 1
e 1 2 e 1 2
e 1 2 e 1 2
------------ ------------ -------------- -----------
1
1
1
1
w 1 1 w 1 2
w S 1 R b 1
J h l
e k q n i q
n i q
v
e k q
m
m
m1
---------- = s i h ---------- = s i h a j q for weight x l
= -------h = ----------= ----------m
m
m
m
x l
w i j
n i q w i j
w i j
m
v
e k q
e k q n i q
n i q
m
m
- = s i h ---------- = s i h for bias x l
--------- J h l = -------h = ----------= ----------m
m
m
m
x l
n i q b i
b i
b i
v h
e k q
m
M
- = ----------s i h ---------(Marquardt Sensitivity) where h = q 1 S + k
m
m
n i q
n i q
M
S q = F n q
M
m
m m
m+1 T m+1
S q = F (n q ) W
S q
12-30
= S 1 S 2 S Q
Summary of Results
Levenberg-Marquardt Iterations
1. Present all inputs to the network and compute the corresponding network outputs (using Eq. (11.41) and Eq. (11.42)) and the errors
M
e q = t q a q . Compute the sum of squared errors over all inputs, F x ,
using Eq. (12.34).
2. Compute the Jacobian matrix, Eq. (12.37). Calculate the sensitivities
with the recurrence relations Eq. (12.47), after initializing with Eq.
(12.46). Augment the individual matrices into the Marquardt sensitivities using Eq. (12.48). Compute the elements of the Jacobian matrix
with Eq. (12.43) and Eq. (12.44).
3. Solve Eq. (12.32) to obtain x k .
4. Recompute the sum of squared errors using x k + x k . If this new sum
of squares is smaller than that computed in step 1, then divide by ,
let x k + 1 = x k + x k and go back to step 1. If the sum of squares is not
reduced, then multiply by and go back to step 3.
12-31
12
12 Variations on Backpropagation
Solved Problems
P12.1 We want to train the network shown in Figure P12.1 on the training set
p 1 = 3 t 1 = 0.5 ,
p 2 = 2 t 2 = 1 ,
1
a = logsig (w p + b)
Figure P12.1 Network for Problem P12.1
Lets begin by computing the direction of the initial step if batching is not
used. In this case the first step is computed from the first input/target pair.
The forward and backpropagation steps are
1
a = logsig wp + b = ------------------------------------------------------------------- = 0.2592
1 + exp 0.4 3 + 0.15
e = t a = 0.5 0.2592 = 0.2408
Solved Problems
1 0.2774
1
---
+ 0.2243 = --- 0.0531 = 0.0265 .
2 0.0925
2 0.2047
0.1122
0.1023
The results are illustrated in Figure P12.2. The blue circle indicates the initial guess. The two blue arrows represent the directions of the partial gradients for each of the two input/target pairs, and the black arrow
represents the direction of the total gradient. The function that is plotted
is the sum of squared errors for the entire training set. Note that the individual partial gradients can point in quite different directions than the true
gradient. However, on the average, over several iterations, the path will
generally follow the steepest descent trajectory.
12-33
12
12 Variations on Backpropagation
The relative effectiveness of the batch mode over the incremental approach
depends very much on the particular problem. The incremental approach
requires less storage, and, if the inputs are presented randomly to the network, the trajectory is stochastic, which makes the algorithm somewhat
less likely to be trapped in a local minimum. It may also take longer to converge than the batch mode algorithm.
4
1.5
2
0.5
0
-4
-2
-4
-2
-2
2
4
-4
-4
-2
w
Figure P12.2 Effect of Batching in Problem P12.1
P12.2 In Chapter 9 we proved that the steepest descent algorithm, when
applied to a quadratic function, would be stable if the learning
rate was less than 2 divided by the maximum eigenvalue of the
Hessian matrix. Show that if a momentum term is added to the
steepest descent algorithm there will always be a momentum coefficient that will make the algorithm stable, regardless of the learning rate. Follow the format of the proof on page 9-6.
The standard steepest descent algorithm is
x k = F x k = g k ,
If we add momentum this becomes
x k = x k 1 1 g k .
Recall from Chapter 8 that the quadratic function has the form
1 T
T
F x = --- x Ax + d x + c ,
2
and the gradient of the quadratic function is
F x = Ax + d .
12-34
Solved Problems
If we now insert this expression into our expression for the steepest descent
algorithm with momentum we obtain
x k = x k 1 1 Ax k + d .
Using the definition x k = x k + 1 x k this can be rewritten
x k + 1 x k = x k x k 1 1 Ax k + d
or
x k + 1 = 1 + I 1 A x k x k 1 1 d .
Now define a new vector
x k =
xk 1
xk
0
I
0
= Wx k + v .
x k +
I 1 + I 1 A
1 d
0 I where T = 1 + I 1 A .
I T
Wz
w w
= z , or
0 I z1 = w z1 .
w
I T z w
z2
2
w w
w w
z 2 = z 1 and z 1 + Tz 2 = z 2 .
w
12-35
12
12 Variations on Backpropagation
w w
t w
w w
z 2 = z 1 and z 1 + z 2 = z 2 .
If we substitute the first equation into the second equation we find
w
w
t w
w w
w 2
t
w
-----w- z 2 + z 2 = z 2 or + z 2 = 0 .
+ = 0 .
From the quadratic formula we have
t 2
4
= -------------------------------------- .
2
Note that if the eigenvalues are complex then their magnitude will be
:
t 2
t 2
4
----------- + ----------------------- =
4
4
.
t
(This is true only for real . We will show later that is real.) Since is
between 0 and 1, the magnitude of the eigenvalue must be less than 1. It
remains to show that there exists some range of for which all of the eigenvalues are complex.
w
4 0 or 2 .
t
Lets now consider the eigenvalues of T . These eigenvalues can be expressed in terms of the eigenvalues of A . Let 1 2 n and
z 1 z 2 z n be the eigenvalues and eigenvectors of the Hessian matrix.
Then
Tz i = 1 + I 1 A z i = 1 + z i 1 Az i
t
= 1 + z i 1 i z i = 1 + 1 i z i = i z i
12-36
Solved Problems
i = 1 + 1 i .
t
(Note that i is real, since , and i for symmetric A are real.) Therew
fore, in order for to be complex we must have
t
2 or 1 + 1 i 2 .
For = 1 both sides of the inequality will equal 2. The function on the
right of the inequality, as a function of , has a slope of 1 at = 1 . The
function on the left of the inequality has a slope of 1 + i . Since the eigenvalues of the Hessian will be positive real numbers if the function has a
strong minimum, and the learning rate is a positive number, this slope
must be greater than 1. This shows that the inequality will always hold for
close enough to 1.
To summarize the results, we have shown that if a momentum term is added to the steepest descent algorithm on a quadratic function, then there
will always be a momentum coefficient that will make the algorithm stable,
regardless of the learning rate. In addition we have shown that if is close
enough to 1, then the magnitudes of the eigenvalues of W will be . It can
be shown (see [Brog91]) that the magnitudes of the eigenvalues determine
how fast the algorithm will converge. The smaller the magnitude, the faster the convergence. As the magnitude approaches 1, the convergence time
increases.
We can demonstrate these results using the example on page 9-7. There we
showed that the steepest descent algorithm, when applied to the function
2
2
F x = x 1 + 25x 2 , was unstable for a learning rate 0.4 . In Figure P12.3
we see the steepest descent trajectory (with momentum) with = 0.041
and = 0.2 . Compare this trajectory with Figure 9.3, which uses the same
learning rate but no momentum.
12-37
12
12 Variations on Backpropagation
0.5
-0.5
-1
-1
-0.5
0.5
F x = x 1 + 25x 2 ,
starting from the initial guess
x 0 = 0.5 ,
0.5
and use the following values for the algorithm parameters:
= 0.05 , = 0.2 , = 1.5 , = 0.5 , = 5% .
The first step is to evaluate the function at the initial guess:
1
1 T
F x 0 = --- x 0 2 0 x 0 = --- 0.5 0.5 2 0 0.5 = 6.5 .
2
2
0 50 0.5
0 50
The next step is to find the gradient:
F x =
Fx
x1
Fx
x2
2x 1
50x 2
12-38
Solved Problems
12
g 0 = F x
x = x0
1 .
25
With the initial learning rate of = 0.05 , the tentative first step of the algorithm is
x 0 = x 1 1 g 0 = 0.2 0 0.8 0.05 1 = 0.04
0
25
1
t
x 1 = x 0 + x 0 = 0.5 + 0.04 = 0.46 .
0.5
1
0.5
To verify that this is a valid step we must test the value of the function at
this new point:
1
1 t T
t
t
F x 1 = --- x 1 2 0 x 1 = --- 0.46 0.5 2 0 0.46 = 6.4616 .
2
2
0 50 0.5
0 50
This is less than F x 0 . Therefore this tentative step is accepted and the
learning rate is increased:
t
x 1 = x 1 = 0.46 , F x 1 = 6.4616 and = = 1.5 0.05 = 0.075 .
0.5
12-39
12 Variations on Backpropagation
1
1 t T
t
t
F x 3 = --- x 3 2 0 x 3 = --- 0.4255 0.4375 2 0 0.4255 = 4.966
2
2
0 50 0.4375
0 50
This is less than F x 2 . Therefore this step is accepted, the momentum is
reset to its original value, and the learning rate is increased.
t
0.8 .
0.25
2x 1 + x 2
x 1 + 2x 2
As with steepest descent, the first search direction for the conjugate gradient algorithm is the negative of the gradient:
12-40
Solved Problems
12
p 0 = g 0 = F x
x = x0
= 1.35 .
0.3
0.8 + 1.35 .
0
0.25
0.3
The first step is interval location. Assume that the initial step size is
= 0.075 . Then the interval location would proceed as follows:
F a 1 = F 0.8 = 0.5025 ,
0.25
12-41
12 Variations on Backpropagation
Since F c F d , we have
a 2 = c 1 = 0.3219 , b 2 = b 1 = 0.6 , c 2 = d 1 = 0.4281
d 2 = b 2 1 b 2 a 2 = 0.6 0.382 0.6 0.3219 = 0.4938 ,
F a = F c = 0.1270 , F c = F d = 0.1085 , F d = F d 2 = 0.1232 .
This time F c F d , therefore
a 3 = a 2 = 0.3219 , b 3 = d 2 = 0.4938 , d 3 = c 2 = 0.4281 ,
c 3 = a 3 + 1 b 3 a 3 = 0.3219 + 0.382 0.4938 0.3219 = 0.3876 ,
F b = F d = 0.1232 , F d = F c = 0.1085 , F c = F c 3 = 0.1094 .
This routine continues until b k + 1 a k + 1 tol . The black dots in Figure
P12.4 indicate the location of the new interior points, one for each iteration
of the procedure. The final point is indicated by a blue dot. Compare this
result with the first iteration shown in Figure 9.10.
1
0.5
-0.5
-1
-1
-0.5
0.5
f n = n , f n = n .
Therefore their derivatives are
1
2
f n = 2n , f n = 1 .
12-42
Solved Problems
12
W = 1 ,b = 0 ,W = 2 ,b = 1 .
Find the Jacobian matrix for the first step of the Levenberg-Marquardt method.
Input
Layer 1
w11,1
n11
Layer 2
f1
a11
w21,1
n21
b11
f2
a21
b21
a1 = f 1 (w1 p + b1)
a2 = f 2 (w2 a1 + b2)
a1 = p1 = 1
1
1 0
n1 = W a1 + b = 1 1 + 0 = 1 , a1 = f n1 = 1 = 1
2
2 1
n1 = W a1 + b = 2 1 + 1 = 3 , a1 = f n1 = 3 = 3
2
e1 = t1 a1 = 1 3 = 2
0
a2 = p2 = 2
1
1 0
n2 = W a2 + b = 1 2 + 0 = 2 , a2 = f n2 = 2 = 4
2
2 1
n2 = W a2 + b = 2 4 + 1 = 9 , a2 = f n2 = 9 = 9
12-43
12 Variations on Backpropagation
e2 = t2 a2 = 2 9 = 7
The next step is to initialize and backpropagate the Marquardt sensitivities using Eq. (12.46) and Eq. (12.47).
2
S 1 = F n 1 = 1
2
1
1 1
2 T 2
= 2 1 2 1 = 4
S 1 = F (n 1) W S 1 = 2n 1
1 1 2 1
2
S 2 = F n 2 = 1
2
1
1 1
2 T 2
= 2 2 2 1 = 8
S 2 = F (n 2) W S 2 = 2n 2
1 2 2 1
1
S = S 11 S 12 = 4 8 , S = S 21 S 22 = 1 1
We can now compute the Jacobian matrix using Eq. (12.43), Eq. (12.44) and
Eq. (12.37).
Jx =
v 1 v 1 v 1 v 1
------- ------- ------- ------x 1 x 2 x 3 x 4
v 2 v 2 v 2 v 2
------- ------- ------- ------x 1 x 2 x 3 x 4
e 1 1 e 1 1 e 1 1 e 1 1
------------ ----------- ------------ ----------1
1
2
2
w 1 1 b 1 w 1 1 b 1
e 1 2 e 1 2 e 1 2 e 1 2
------------ ----------- ------------ ----------1
1
2
2
w 1 1 b 1 w 1 1 b 1
1
e 1 1 n 1 1
n 1 1
v
e 1 1
1
1
0
- ------------ = s 1 1 ------------ = s 1 1 a 1 1
- = ---------- J 1 1 = -------1 = -----------1
1
1
1
x 1
w 1 1
n 1 1 w 1 1
w 1 1
= 4 1 = 4
e 1 1 n 1 1
n 1 1
v
e 1 1
1
1
- ----------- = s 1 1 ----------- = s 1 1 = 4
- = ---------- J 1 2 = -------1 = ----------1
1
1
1
x 2
b 1
n 1 1 b 1
b 1
2
e 1 1 n 1 1
n 1 1
v
2
2
1
- ------------ = s 1 1 ------------ = s 1 1 a 1 1 = 1 1 = 1
J 1 3 = -------1 = ----------2
2
2
x 3
n 1 1 w 1 1
w 1 1
12-44
Solved Problems
J 1 4
e 1 1 n 1 1
n 1 1
v
2
2
- ----------- = s 1 1 ----------- = s 1 1 = 1
= -------1 = ----------2
2
2
x 4
n 1 1 b 1
b 1
1
e 1 2 n 1 2
n 1 2
v
1
1
0
- ------------ = s 1 2 ------------ = s 1 2 a 1 2 = 8 2 = 16
J 2 1 = -------2 = ----------1
1
1
x 1
n 1 2 w 1 1
w 1 1
1
J 2 2
J 2 3
e 1 2 n 1 2
n 1 2
v
e 1 2
1
1
- = ----------- ----------- = s 1 2 ----------- = s 1 2 = 8
= -------2 = ----------1
1
1
1
x 2
b 1
n 1 2 b 1
b 1
2
v
e 1 2 n 1 2
n 1 2
2
2
1
- ------------ = s 1 2 ------------ = s 1 2 a 1 2 = 1 4 = 4
= -------2 = ----------2
2
2
x 3
n 1 2 w 1 1
w 1 1
2
J 2 4
v
e 1 2
e 1 2 n 1 2
n 1 2
2
2
- ----------- = s 1 2 ----------- = s 1 2 = 1
- = ----------= -------2 = ----------2
2
2
2
x 4
n 1 2 b 1
b 1
b 1
12-45
4 4 1 1 .
16 8 4 1
12
12 Variations on Backpropagation
Epilogue
One of the major problems with the basic backpropagation algorithm
(steepest descent backpropagation SDBP) has been the long training
times. It is not feasible to use SDBP on practical problems, because it can
take weeks to train a network, even on a large computer. Since backpropagation was first popularized, there has been considerable work on methods
to accelerate the convergence of the algorithm. In this chapter we have discussed the reasons for the slow convergence of SDBP and have presented
several techniques for improving the performance of the algorithm.
The techniques for speeding up convergence have fallen into two main categories: heuristic methods and standard numerical optimization methods.
We have discussed two heuristic methods: momentum (MOBP) and variable learning rate (VLBP). MOBP is simple to implement, can be used in
batch mode or incremental mode and is significantly faster than SDBP. It
does require the selection of the momentum coefficient, but is limited to
the range [0, 1] and the algorithm is not extremely sensitive to this choice.
The VLBP algorithm is faster than MOBP but must be used in batch mode.
For this reason it requires more storage. VLBP also requires the selection
of a total of five parameters. The algorithm is reasonably robust, but the
choice of the parameters can affect the convergence speed and is problem
dependent.
We also presented two standard numerical optimization techniques: conjugate gradient (CGBP) and Levenberg-Marquardt (LMBP). CGBP is generally faster than VLBP. It is a batch mode algorithm, which requires a linear
search at each iteration, but its storage requirements are not significantly
different than VLBP. There are many variations of the conjugate gradient
algorithm proposed for neural network applications. We have presented
only one.
The LMBP algorithm is the fastest algorithm that we have tested for training multilayer networks of moderate size, even though it requires a matrix
inversion at each iteration. It requires that two parameters be selected, but
the algorithm does not appear to be sensitive to this selection. The main
T
drawback of LMBP is the storage requirement. The J J matrix, which
must be inverted, is n n , where n is the total number of weights and biases in the network. If the network has more than a few thousand parameters, the LMBP algorithm becomes impractical on current machines.
There are many other variations on backpropagation that have not been
discussed in this chapter. Some references to other techniques are given in
Chapter 19.
12-46
Further Reading
12
Further Reading
[Barn92]
[Batt92]
[Char92]
C. Charalambous, Conjugate gradient algorithm for efficient training of artificial neural networks, IEE Proceedings, vol. 139, no. 3, pp. 301310, 1992.
This paper explains how the conjugate gradient algorithm
can be used to train multilayer networks. Comparisons are
made to other training algorithms.
[Fahl88]
[HaMe94]
M. T. Hagan and M. Menhaj, Training feedforward networks with the Marquardt algorithm, IEEE Transactions
on Neural Networks, vol. 5, no. 6, 1994.
This paper describes the use of the Levenberg-Marquardt
algorithm for training multilayer networks and compares
the performance of the algorithm with variable learning
rate backpropagation and conjugate gradient. The Levenberg-Marquardt algorithm is faster, but requires more
storage.
12-47
12 Variations on Backpropagation
[Jaco88]
[NgWi90]
[RiIr90]
A. K. Rigler, J. M. Irvine and T. P. Vogl, Rescaling of variables in back propagation learning, Neural Networks, vol.
4, no. 2, pp. 225230, 1991.
This paper notes that the derivative of a sigmoid function
is very small on the tails. This means that the elements of
the gradient associated with the first few layers will generally be smaller that those associated with the last layer.
The terms in the gradient are then scaled to equalize them.
[Scal85]
12-48
Further Reading
[Shan90]
[Toll90]
[VoMa88]
12-49
12
12 Variations on Backpropagation
Exercises
E12.1 We want to train the network shown in Figure E12.1 on the training set
p 1 = 2 t 1 = 0.8 , p 2 = 2 t 2 = 1 ,
Write a MATLAB M-file to create a contour plot for the mean squared error
performance index.
1
a = logsig (w p + b)
Figure E12.1 Network for Exercise E12.1
E12.2 Demonstrate the effect of batching by computing the direction of the initial
step for SDBP with and without batching for the problem described in Exercise E12.1, starting from the initial guess
w 0 = 0 , b 0 = 0.5 .
E12.3 Recall the quadratic function used in Problem P9.1:
1 T
F x = --- x 10 6 x + 4 4 x .
2
6 10
We want to use the steepest descent algorithm with momentum to minimize this function.
i. Suppose that the learning rate is = 0.2 . Find a value for the momentum coefficient for which the algorithm will be stable. Use the
ideas presented in Problem P12.2.
ii. Suppose that the learning rate is = 20 . Find a value for the momentum coefficient for which the algorithm will be stable.
12-50
Exercises
2+2
ans =
4
1 .
2.5
12-51
12
12 Variations on Backpropagation
1 .
2.5
F x = x 1 + 2x 2 .
Perform three iterations of the variable learning rate algorithm, with initial guess
x0 =
0 .
1
12-52
1 .
2.5
Exercises
12
12 Variations on Backpropagation
x = 1 + 1 .
1
1
Perform two iterations of the Golden Section search ( k = 1 2 ) to find the
interval a 3 b 3 . Assume that the initial interval is defined by a 1 = 0 and
b 1 = 1 . Make a rough sketch of the contour plot of F x , draw the search
line in the same figure and indicate your search points (points where you
evaluated F x ) on the line.
E12.13 Consider the following quadratic function.
1 T
F x = --- x 2 0 x .
2
0 1
We want to minimize this function along the line
x = 0 + 1 .
1
1
Perform two iterations of the Golden Section search ( k = 1 2 ) to find the
interval a 3 b 3 . Assume that the initial interval is defined by a 1 = 0 and
b 1 = 1 . Make a rough sketch of the contour plot of F x , draw the search
line in the same figure and indicate your search points (points where you
evaluated F x ) on the line.
E12.14 We want to use the network of Figure E12.2 to approximate the function
12-54
Exercises
Input
Log-Sigmoid Layer
w11,1
p
w12,1
n11
a11
w21,1
b11
n12
a12
b12
12
Linear Layer
w22,1
n2
a2
b2
1
a1 = logsig (W1p + b1)
Repeat this exercise, modifying your program to use the training procedures discussed in this chapter: batch mode SDBP, MOBP, VLBP, CGBP
and LMBP. Compare the convergence results of the various methods.
12-55
Objectives
13
Generalization
13
Objectives
13-1
13-2
Problem Statement
13-2
13-5
13-6
Early Stopping
13-6
Regularization
13-8
Bayesian Analysis
13-10
Bayesian Regularization
13-12
13-19
Summary of Results
13-29
Solved Problems
13-32
Epilogue
13-44
Further Reading
13-45
Exercises
13-47
Objectives
One of the key issues in designing a multilayer network is determining the
number of neurons to use. In effect, that is the objective of this chapter.
In Chapter 11 we showed that if the number of neurons is too large, the network will overfit the training data. This means that the error on the training data will be very small, but the network will fail to perform as well
when presented with new data. A network that generalizes well will perform as well on new data as it does on the training data.
The complexity of a neural network is determined by the number of free parameters that it has (weights and biases), which in turn is determined by
the number of neurons. If a network is too complex for a given data set,
then it is likely to overfit and to have poor generalization.
In this chapter we will see that we can adjust the complexity of a network
to fit the complexity of the data. In addition, this can be done without
changing the number of neurons. We can adjust the effective number of
free parameters without changing the actual number of free parameters.
13-1
13 Generalization
Ockhams Razor
Problem Statement
Lets begin our discussion of generalization by defining the problem. We
start with a training set of example network inputs and corresponding target outputs:
13-2
Problem Statement
{p 1, t 1} { p 2, t 2} {p Q, tQ} .
(13.1)
(13.2)
F x = ED =
tq aq
tq aq ,
(13.3)
q=1
where a q is the network output for input p q . We are using the variable E D
to represent the sum squared error on the training data, because later we
will modify the performance index to include an additional term.
Overfitting
Interpolation
Extrapolation
The problem of overfitting is illustrated in Figure 13.1. The blue curve represents the function g . . The large open circles represent the noisy target
points. The black curve represents the trained network response, and the
smaller circles filled with crosses represent the network response at the
training points. In this figure we can see that the network response exactly
matches the training points. However, it does a very poor job of matching
the underlying function. It overfits.
There are actually two kinds of errors that occur in Figure 13.1. The first
type of error, which is caused by overfitting, occurs for input values between -3 and 0. This is the region where all of the training data points occcur. The network response in this region overfits the training data and
will fail to perform well for input values that are not in the training set. The
network does a poor job of interpolation; it fails to accurately approximate
the function near the training points.
The second type of error occurs for inputs in the region between 0 and 3.
The network fails to perform well in this region, not because it is overfitting, but because there is no training data there. The network is extrapolating beyond the range of the input data.
In this chapter we will discuss methods for preventing errors of interpolation (overfitting). There is no way to prevent errors of extrapolation, unless
the data that is used to train the network covers all regions of the input
space where the network will be used. The network has no way of knowing
what the true function looks like in regions where there is no data.
13-3
13
13 Generalization
25
20
15
10
5
0
5
10
15
20
25
30
3
side of the range 3 p 0 . The network response outside this range will
be unpredictable. This is why it is important to have training data for all
regions of the input space where the network will be used. It is usually not
difficult to determine the required input range when the network has a single input, as in this example. However, when the network has many inputs,
it becomes more difficult to determine when the network is interpolating
and when it is extrapolating.
This problem is illustrated in a simple way in Figure 13.3. On the left side
of this figure we see the function that is to be approximated. The range for
the input variables is 3 p 1 3 and 3 p 2 3 . The neural network was
trained over these ranges of the two variables, but only for p 1 p 2 . Therefore, both p 1 and p 2 cover their individual ranges, but only half of the total
input space is covered. When p 1 p 2 , the network is extrapolating, and we
can see on the right side of Figure 13.3 that the network performs poorly in
this region. (See Problem P13.4 for another example of extrapolation.) If
there are many input variables, it will be quite difficult to determine when
the network is interpolating and when it is extrapolating. We will discuss
some practical ways of dealing with this problem in Chapter 22.
a)
b)
4
2
4
6
3
2
1
p2
0
1
2
3
2
1
p2
p1
0
1
2
3
p1
13
13 Generalization
Test Set
Early Stopping
The first method we will discuss for improving generalization is also the
simplest method. It is called early stopping [WaVe94]. The idea behind this
method is that as training progresses the network uses more and more of
its weights, until all weights are fully used when training reaches a minimum of the error surface. By increasing the number of iterations of training, we are increasing the complexity of the resulting network. If training
is stopped before the minimum is reached, then the network will effectively
be using fewer parameters and will be less likely to overfit. In a later section of this chapter we will demonstrate how the number of parameters
changes as the number of iterations increases.
Cross-Validation
In order to use early stopping effectively, we need to know when to stop the
training. We will describe a method, called cross-validation, that uses a
13-6
Validation Set
validation set to decide when to stop [Sarl95]. The available data (after removing the test set, as described above) is divided into two parts: a training
set and a validation set. The training set is used to compute gradients or
Jacobians and to determine the weight update at each iteration. The validation set is an indicator of what is happening to the network function in
between the training points, and its error is monitored during the training
process. When the error on the validation set goes up for several iterations,
the training is stopped, and the weights that produced the minimum error
on the validation set are used as the final trained network weights.
This process is illustrated in Figure 13.4. The graph at the bottom of this
figure shows the progress of the training and validation performance indices, F (the sum squared errors), during training. Although the training error continues to go down throughout the training process, a minimum of
the validation error occurs at the point labeled a, which corresponds to
training iteration 14. The graph at the upper left shows the network response at this early stopping point. The resulting network provides a good
fit to the true function. The graph at the upper right demonstrates the network response if we continue to train to point b, where the validation error has increased and the network is overfitting.
1.5
1.5
0.5
0.5
2
0
0.5
0.5
1.5
1
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
1.5
1
0.8
0.6
0.4
0.2
10
Validation
10
10
Training
0
10
10
10
10
10
Iteration
13-7
0.2
0.4
0.6
0.8
13
13 Generalization
The basic concept for early stopping is simple, but there are several practical issues to be addressed. First, the validation set must be chosen so that
it is representative of all situations for which the network will be used. This
is also true for the test and training sets, as we mentioned earlier. Each set
must be roughly equivalent in its coverage of the input space, although the
size of each set may be different.
When we divide the data, approximately 70% is typically used for training,
with 15% for validation and 15% for testing. These are only approximate
numbers. A complete discussion of how to select the amount of data for the
validation set is given in [AmMu97].
Another practical point to be made about early stopping is that we should
use a relatively slow training method. During training, the network will
use more and more of the available network parameters (as we will explain
in the last section of this chapter). If the training method is too fast, it will
likely jump past the point at which the validation error is minimized.
To experiment with the effect of early stopping, use the MATLAB Neural
Network Design Demonstration Early Stopping (nnd13es).
Regularization
The second method we will discuss for improving generalization is called
regularization. For this method, we modify the sum squared error performance index of Eq. (13.3) to include a term that penalizes network complexity. This concept was introduced by Tikhonov [Tikh63]. He added a
penalty, or regularization, term that involved the derivatives of the approximating function (neural network in our case), which forced the resulting
function to be smooth. Under certain conditions, this regularization term
can be written as the sum of squares of the network weights, as in
Q
F x = E D + E W =
tq aq
q=1
n
T
tq aq + xi ,
2
(13.4)
i=1
where the ratio controls the effective complexity of the network solution. The larger this ratio is, the smoother the network response. (Note that
we could have used a single parameter here, but developments in later sections will require two parameters.)
Why do we want to penalize the sum squared weights, and how is this similar to reducing the number of neurons? Consider again the example multilayer network shown in Figure 11.4. Recall how increasing a weight
increased the slope of the network function. You can see this effect again in
2
Figure 13.5, where we have changed the weight w 1 1 from 0 to 2. When the
weights are large, the function created by the network can have large
slopes, and is therefore more likely to overfit the training data. If we restrict the weights to be small, then the network function will create a
13-8
smooth interpolation through the training data - just as if the network had
a small number of neurons.
13
w 1 1 = 2
2
w 1 1 = 0
0
1
2
p
Figure 13.5 Effect of Weight on Network Response
To experiment with the effect of weight changes on the network function, use
the MATLAB Neural Network Design Demonstration Network Function
(nnd11nf).
The key to the success of the regularization method in producing a network
that generalizes well is the correct choice of the regularization ratio .
Figure 13.6 illustrates the effect of changing this ratio. Here we have
trained a 1-20-1 network on 21 noisy samples of a sine wave.
In the figure, the blue line represents the true function, and the large open
circles represent the noisy data. The black curve represents the trained
network response, and the smaller circles filled with crosses represent the
network response at the training points. From the figure, we can see that
the ratio = 0.01 produces the best fit to the true function. For ratios
larger than this, the network response is too smooth, and for ratios smaller
than this, the network overfits.
There are several techniques for setting the regularization parameter. One
approach is to use a validation set, such as we described in the section on
early stopping; the regularization parameter is set to minimize the squared
error on the validation set [GoLa98]. In the next two sections we will describe a different technique for automatically setting the regularization parameter. It is called Bayesian regularization.
13-9
13 Generalization
1.5
1.5
= 0
0.5
0.5
0.5
0.5
1.5
1
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
1.5
1.5
1
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
0.2
0.4
0.6
0.8
1.5
= 0.25
0.5
0.5
0.5
0.5
1.5
1
= 0.01
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
1.5
1
= 1
0.8
0.6
0.4
0.2
Bayesian Analysis
Thomas Bayes was a Presbyterian minister who lived in England during
the 1700s. He was also an amateur mathematician. His most important
work was published after his death. In it, he presented what is now known
as Bayes Theorem. The theorem states that if you have two random
events, A and B , then the conditional probability of the occurrence of A ,
given the occurrence of B can be computed as
P B A P A
P A B = ------------------------------- .
P B
(13.5)
Eq. (13.5) is called Bayes rule. Each of the terms in this expression has a
name by which it is commonly referred. P A is called the prior probability.
It tells us what we know about A before we know the outcome of B . P A B
is called the posterior probability. This tells us what we know about A after
we learn about B . P B A is the conditional probability of B given A . Normally this term is given by our knowledge of the system that describes the
relationship between B and A . P B is the marginal probability of the
event B , and it acts as a normalization factor in Bayes rule.
13-10
2
+2
To illustrate how Bayes rule can be used, consider the following medical
situation. Assume that 1% of the population have a certain disease. There
is a test that can be performed to detect the presence of this disease. The
test is 80% accurate in detecting the disease in people who have it. However, 10% of the time, someone without the disease will register a positive
test. If you take the test and register positive, your question would be:
What is the probability that I actually have the disease? Most of us (including most physicians, as has been shown in many studies), would guess that
the probability is very high, considering that the test is 80% accurate in detecting the disease in a sick person. However, this turns out not to be the
case, and Bayes rule can help us overcome this lack of intuition, when it
comes to probability.
Let A represent the event that you have the disease. Let B represent the
event that you have a positive test result. We can then use Bayes rule to
find P A B , which is the probability that you have the disease, given that
you have a positive test. We know that the prior probability P A would be
0.01, because 1% of the population have the disease. P B A is 0.8, because
the test is 80% accurate in detecting the disease in people who have it. (Notice that this conditional probability is based on our knowledge of the test
procedure and its accuracy.) In order to use Bayes rule, we need one more
term, which is P B . This is the probability of getting a positive test,
whether or not you have the disease. This can be obtained by adding the
probability of having a positive test when you have the disease to the probability of having a positive test when you dont have the disease:
P B = P A B + P A B = P B A P A + P B A P A ,
(13.6)
(13.7)
(13.8)
(13.9)
This tells us that even if you get a positive test, you only have a 7.5% chance
of having the disease. For most of us, this result is not intuitive.
The key to Bayes rule is the prior probability P A . In this case, the prior
odds of having the disease were only 1 in 100. If this number had been
much higher, then our posterior probability P A B would have also in13-11
13
13 Generalization
Bayesian Regularization
Although there have been many approaches to the automatic selection of
the regularization parameter, we will concentrate on one developed by
David MacKay [MacK92]. This approach puts the training of neural networks into a Bayesian statistical framework. This framework is useful for
many aspects of training, in addition to the selection of the regularization
parameter, so it is an important concept to become familiar with. There are
two levels to this Bayesian analysis. We will begin with Level I.
Level I Bayesian Framework
The Bayesian framework begins with the assumption that the network
weights are random variables. We then choose the weights that maximize
the conditional probability of the weights given the data. Bayes rule is
used to find this probability function:
P D x M P x M
P x D M = ----------------------------------------------------------- ,
P D M
(13.10)
where x is the vector containing all of the weights and biases in the network, D represents the training data set, and are parameters associated with the density functions P D x M and P x M , and M is the
selected model - the architecture of the network we have chosen (i.e., how
many layers and how may neurons in each layer).
It is worth taking some time to investigate each of the terms in Eq. (13.10).
First, P D x M is the probability density for the data, given a certain
set of weights x , the parameter (which we will explain shortly), and the
choice of model M . If we assume that the noise terms in Eq. (13.2) are independent and have a Gaussian distribution, then
1
P D x M = --------------- exp E D ,
ZD
13-12
(13.11)
Z D = 2
N2
(13.12)
Prior Density
(13.13)
Z W = 2 w
n2
(13.14)
The final term on the right side of Eq. (13.10) is P D M . This is called
the evidence, and it is a normalizing term that is not a function of x . If our
objective is to find the weights x that maximize the posterior density
P x D M , then we do not need to be concerned with P D M .
(However, it will be important later for estimating and .)
With the Gaussian assumptions that we made earlier, we can rewrite the
posterior density, using Eq. (13.10), in the following form:
13-13
13
13 Generalization
1
1
---------------- --------------- exp E D + E W
ZW ZD
P x D M = ----------------------------------------------------------------------------------Normalization Factor
(13.15)
1
= --------------------- exp F x
Z F
where Z F is a function of and (but not a function of x ), and F x
is our regularized performance index, which we defined in Eq. (13.4). To
find the most probable value for the weights, we should maximize the posterior density P x D M . This is equivalent to minimizing the regularized performance index F x = E D + E W .
Most Probable
Therefore, our regularized performance index can be derived using Bayesian statistics, with the assumption of Gaussian noise in the training set
and a Gaussian prior density for the network weights. We will identify the
weights that maximize the posterior density as x MP , or most probable. This
is to be contrasted with the weights that maximize the likelihood function:
x ML .
Note how this statistical framework provides a physical meaning for the
parameters and . The parameter is inversely proportional to the
variance in the measurement noise q . Therefore, if the noise variance is
large, will be small, and the regularization ratio will be large. This
will force the resulting weights to be small and the network function to be
smooth (as seen in Figure 13.6). The larger the measurement noise, the
more we will smooth the network function, in order to average out the affects of the noise.
The parameter is inversely proportional to the variance in the prior distribution for the network weights. If this variance is large, it means that
we have very little certainty about the values of the network weights, and,
therefore, they might be very large. The parameter will then be small,
and the regularization ratio will also be small. This will allow the network weights to be large, and the network function will be allowed to have
more variation (as seen in Figure 13.6). The larger the variance in the prior
density for the network weights, the more variation the network function
will be allowed to have.
Level II Bayesian Framework
So far we have an interesting statistical derivation of the regularized performance index and some new insight into the meanings of the parameters
and , but what we really want to find is a way to estimate these parameters from the data. In order to do this, we need to take the Bayesian analysis to another level. If we want to estimate and using Bayesian
analysis, we need the probability density P D M . Using Bayes rule
this can written
13-14
P D M P M
P D M = ------------------------------------------------------------ .
PD M
(13.16)
This has the same format as Eq. (13.10), with the likelihood function and
the prior density in the numerator of the right hand side. If we assume a
uniform (constant) prior density P M for the regularization parameters and , then maximizing the posterior is achieved by maximizing the
likelihood function P D M . However, note that this likelihood function is the normalization factor (evidence) from Eq. (13.10). Since we have
assumed that all probabilities have a Gaussian form, we know the form for
the posterior density of Eq. (13.10). It is shown in Eq. (13.15). Now we can
solve Eq. (13.10) for the normalization factor (evidence).
P D x M P x M
P D M = -----------------------------------------------------------P x D M
1
1
--------------- exp E D ---------------- exp E W
ZD
ZW
= ----------------------------------------------------------------------------------------------------1
--------------------- exp F x
Z F
(13.17)
Z F
exp E D E W
Z F
- --------------------------------------------= -----------------------------= -----------------------------Z D Z W
exp F x
Z D Z W
Note that we know the constants Z D and Z W from Eq. (13.12) and
Eq. (13.14). The only part we do not know is Z F . However, we can estimate it by using a Taylor series expansion.
Since the objective function has the shape of a quadratic in a small area
surrounding a minimum point, we can expand F x in a second order Taylor series (see Eq. (8.9)) around its minimum point, x MP , where the gradient is zero:
T MP
1
F x F x MP + --- x x MP H x x MP ,
2
(13.18)
MP
13-15
13
13 Generalization
T MP
1
P x D M ------ exp F x MP exp --- x x MP H x x MP . (13.20)
Z
2
F
1
n
MP
2 H
(13.21)
Therefore, equating Eq. (13.21) with Eq. (13.20), we can solve for Z F :
Z F 2
n2
det H
MP 1
12
exp F x MP .
(13.22)
Placing this result into Eq. (13.17), we can solve for the optimal values for
and at the minimum point. We do this by taking the derivative with
respect to each of the log of Eq. (13.17) and set them equal to zero. This
yields (see Solved Problem P13.3):
MP
MP
N
MP
= ------------------------ and
= ------------------------,
MP
MP
2E W x
2E D x
(13.23)
MP 1
1. Take one step of the Levenberg-Marquardt algorithm toward minimizing the objective function F x = E D + E W .
1
13-17
13
13 Generalization
1.5
0.5
0.5
1.5
1
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
10
10
Testing
Training
2
ED
10
ED
10
10
2
10
10
10
10
10
0
10
10
10
10
10
10
Iteration
Iteration
1
10
10
10
10
10
10
10
10
10
Iteration
10
10
0
10
10
10
Iteration
might well have been able to use a smaller network to fit this data. There
are two disadvantages of a large network: 1) it may overfit the data, and 2)
it requires more computation to calculate the network output. We have
overcome the first disadvantage by training with GNBR; although the network has 61 parameters, it is equivalent to a network with only 6 parameters. The second disadvantage is only important if the calculation time for
the network response is critical to the application. This is not usually the
case, since the time to calculate a network response to a particular input is
measured in milliseconds. In those cases where the calculation time is significant, you can train a smaller network on the data.
On the other hand, when the effective number of parameters is close to the
total number of parameters, this can mean that the network is not large
enough to fit the data. In this case, you should increase the size of the network and retrain on the data set.
To experiment with Bayesian Regularization, use the MATLAB Neural
Network Design Demonstration Bayesian Regularization (nnd17breg).
(13.24)
13-19
(13.25)
13
13 Generalization
(13.26)
We want to know how close we come to the minimum of the squared error
at each iteration. For quadratic performance indices, we know that the
minimum will occur at the following point (see Eq. (8.62)):
x
ML
= A d ,
(13.27)
where the superscript ML indicates that this result maximizes the likelihood function, in addition to minimizing the squared error, as we saw in
Eq. (13.11).
We can now rewrite Eq. (13.26) as
1
x k + 1 = x k A x k + A d = x k A x k x
ML
(13.28)
ML
= Mx k + I M x
ML
(13.29)
ML
(13.30)
where the initial guess x 0 usually consists of random values near zero.
Continuing to the second iteration:
x 2 = Mx 1 + I M x
ML
= M x 0 + M I M x
2
= M x 0 + Mx
2
= M x0 + x
ML
ML
ML
+ I M x
2 ML
M x
2 ML
M x
+x
ML
ML
Mx
ML
= M x 0 + I M x
(13.31)
ML
x k = M x 0 + I M x
ML
(13.32)
This key result shows how far we progress from the initial guess to the
maximum likelihood weights in k iterations. We will use this result later to
compare with regularization.
13-20
Regularization Analysis
Recall from Eq. (13.4) that the regularized performance index adds a penalty term to the sum squared error, as in
F x = E D + E W .
(13.33)
For the following analysis, it will more convenient to consider the following
equivalent (because the minimum occurs at the same place) performance
index
Fx
F x = ----------- = E D + ---E = E D + E W ,
W
(13.34)
EW = x x0 x x0 ,
(13.35)
(13.36)
(13.37)
From Eq. (13.25) and Eq. (13.28), the gradient of the sum squared error is
1
E D = Ax + d = A x + A d = A x x
ML
(13.38)
ML
+ 2 x x 0 = 0 .
(13.39)
The solution of Eq. (13.39) is the most probable value for the weights, x MP .
We can make that substitution and perform some algebra to obtain
Ax
MP
ML
= 2 x
MP
= 2 x
MP
x 0 = 2 x
x
ML
2 x
13-21
MP
MP
ML
ML
ML
x0
+x
ML
x0
(13.40)
13
13 Generalization
A + 2I x
Solving for x
x
MP
MP
ML
ML
MP
ML
= 2 x 0 x
ML
(13.41)
, we find
1
= 2 A + 2I x 0 x
ML
= M x0 x
ML
(13.42)
where M = 2 A + 2I .
We want to know the relationship between the regularized solution x MP
and the minimum of the squared error x ML , so we can solve Eq. (13.42) for
x MP :
x
MP
= M x 0 + I M x
ML
(13.43)
This is the key result that describes the relationship between the regularized solution and the minimum of the squared error. By comparing Eq.
(13.43) with Eq. (13.32), we can investigate the relationship between early
stopping and regularization. We will do that in the next section.
Connection Between Early Stopping and Regularization
To compare early stopping and regularization, we need to compare Eq.
(13.43) and Eq. (13.32). They are summarized in Figure 13.9. We would like
to find out when these two solutions are equal. In other words, when do early stopping and regularization produce the same weights?
Early Stopping
k
x k = M x 0 + I M x
Regularization
x
ML
MP
= M x 0 + I M x
M = 2 A + 2I
M = I A
ML
The key matrix for early stopping is M = I A . The key matrix for
1
regularization is M = 2 A + 2I . If these two matrices are equal, then
the weights for early stopping will be the same as the weights for regularization. In Eq. (9.22) we showed that the eigenvectors of M are the same
as the eigenvectors of A and that the eigenvalues of M are 1 i ,
k
where the eigenvalues of A are i . The eigenvalues of M are then
k
eig M = 1 i .
(13.44)
Now lets consider the matrix M . First, using the same procedures that
led to Eq. (9.22), we can show that the eigenvectors of A + 2I are the
same as the eigenvectors of A , and the eigenvalues of A + 2I are
13-22
(13.45)
Therefore, in order for M to equal M , they just need to have equal eigenvalues:
2
k
---------------------- = 1 i .
i + 2
(13.46)
(13.47)
1
i
1 + -----i-
(13.48)
or
1 i
1
-.
k = ------ --------------------------------2 1 + i 2
(13.49)
(13.50)
Therefore, early stopping is approximately equivalent to regularization. Increasing the number of iterations k is approximately the same as decreasing the regularization parameter . This makes intuitive sense, because
increasing the number of iterations, or decreasing the regularization parameter, can lead to overfitting.
Example, Interpretation of Effective Number of Parameters
2
+2
We will illustrate this result with a simple example. Suppose that we have
a single layer, linear network with no bias. The input/target pairs are given
by
13-23
13
13 Generalization
1 t = 1 , p = 1 t = 1 ,
p1 =
2
1
2
1
1
where the probability of the first pair is 0.75, and the probability of the second pair is 0.25. Following Eq. (10.13) and Eq. (10.15), we can find the quadratic mean square error performance index as
2
c = E t = 1 0.75 + 1 0.25 = 1 ,
h = E tz = 0.75 1 1 + 0.25 1 1 = 1 ,
1
1
0.5
d = 2h = 2 1 = 2 ,
0.5
1
T
A = 2R = 2 E zz = 2 0.75 1 1 1 + 0.25 1 1 1 = 2 1 ,
1
1
1 2
1 T
T
E D = c + x d + --- x Ax .
2
The minimum of the mean squared error occurs at
x
ML
= A d = R h =
1 0.5
0.5 1
1 = 1 .
0.5
0
2 1
1 2
1 = 1
13-24
= 4 + 3 = 1 3 ,
2 = 3 .
A I v = 0 .
For 1 = 1 ,
11 v = 0
1
11
13
v1 = 1 ,
1
and for 2 = 3 ,
1 1 v = 0
2
1 1
v2 = 1 .
1
0.5
x2
0.5
1
0.5
0.5
1.5
x1
Figure 13.10 Contour Plot for E D
Now consider the regularized performance index of Eq. (13.34). Its Hessian
matrix will be
2
.
F x = 2E D + 2E W = 2E D + 2I = 2 1 + 2 0 = 2 + 2 1
1 2
0 2
1 2 + 2
13-25
13 Generalization
0.5
x2
= 1
= 0
0.5
1
0.5
0.5
1.5
x1
Figure 13.11 Contour Plot for F
In Figure 13.12 the blue curve represents the movement of x MP as is varied.
1
x MP
0.5
x2
= 0
0.5
1
0.5
0.5
1.5
x1
Figure 13.12 x MP as is Varied
Now lets compare this regularization result with early stopping. Figure
13.13 shows the steepest descent trajectory for minimizing E D , starting
from very small values for the weights. If we stop early, the result will fall
along the blue curve. Notice that this curve is very close to the regularization curve in Figure 13.12. If the number of iterations is very small, this is
equivalent to a very large value for . As the number of iterations increases, it is equivalent to reducing .
13-26
13
0.5
x2
0.5
1
0.5
0.5
1.5
x1
Figure 13.13 Steepest Descent Trajectory
To experiment with the relationship between Early Stopping and Regularization, use the MATLAB Neural Network Design Demonstration Early
Stopping/Regularization (nnd17esr).
It is useful to consider the relationship between the eigenvalues and eigen2
vectors of the Hessian matrix E D x and the results of regularization
and early stopping. In this example, 2 is larger than 1 , so E D has higher
curvature in the v 2 direction. This means that we will get a quicker reduction in the squared error if we move in that direction first. This is shown in
Figure 13.13, as the initial steepest descent movement is almost in the direction of v 2 . Note also that in regularization, as shown in Figure 13.12, as
decreases from a large value, the weights move first in the v 2 direction.
For a given change in the weights, this direction provides the largest reduction in the squared error.
Since the eigenvalue 1 is smaller than 2 , we only move in the v 1 direction after achieving significant reduction in E D in the v 2 direction. This
would be even more pronounced if the difference between 1 and 2 were
greater. In the limiting case, where 1 = 0 , we would not have to move in
the v 1 direction at all. We would only need to move in the v 2 direction to
get the complete reduction in the squared error. (This would be the case of
the stationary valley, as in Figure 8.9.) Note that in this case we would only
be effectively using one parameter, even though the network has two
weights. (Of course, this one effective parameter is some combination of the
two weights.) Therefore, the effective number of parameters is related to
2
the number of eigenvalues of E D x that are significantly different than
zero. We will analyze this in detail in the next section.
13-27
13 Generalization
MP
tr H
MP 1
(13.51)
2
H x = F x = 2E D + 2E W = 2E D + 2I .
(13.52)
Using arguments similar to those leading to Eq. (13.44), we can show that
the eigenvalues of H x are i + 2 . We can then use two properties of
1
1
eigenvalues to compute tr H . First, the eigenvalues of H are the reciprocals of the eigenvalues of H , and, second, the trace of a matrix is equal
to the sum of its eigenvalues. Using these two properties, we can write
n
1
tr H =
.
-------------------- i + 2
(13.53)
i=1
= n 2
MP
tr H
MP 1
= n
i=1
2
--------------------- =
i + 2
,
-------------------- i + 2
(13.54)
i=1
or
n
i=1
i
--------------------=
i + 2
i ,
(13.55)
i=1
where
i
.
i = -------------------- i + 2
(13.56)
Summary of Results
Summary of Results
13
Problem Statement
A network trained to generalize will perform as well in new situations as it
does on the data on which it was trained.
Q
ED =
tq aq
tq aq
q=1
Early Stopping
The available data (after removing the test set) is divided into two parts: a
training set and a validation set. The training set is used to compute gradients or Jacobians and to determine the weight update at each iteration.
When the error on the validation set goes up for several iterations, the
training is stopped, and the weights that produced the minimum error on
the validation set are used as the final trained network weights.
Regularization
n
F x = E D + E W =
tq aq
tq aq + xi
q=1
Bayesian Regularization
Level I Bayesian Framework
P D x M P x M
P x D M = ----------------------------------------------------------P D M
13-29
i=1
13 Generalization
1
2
P D x M = --------------- exp E D , = 1 2
ZD
2 N2
Z D = 2
N2
1
2
P x M = ---------------- exp E W , = 1 2 w
ZW
2 n2
Z W = 2 w
n2
1
P x D M = --------------------- exp F x
Z F
Level II Bayesian Framework
P D M P M
P D M = -----------------------------------------------------------PD M
MP
N
MP
= ------------------------ and
= -----------------------MP
MP
2E W x
2E D x
= n 2
MP
tr H
MP 1
2. Compute the effective number of parameters = N 2tr H , making use of the Gauss-Newton approximation to the Hessian available in
the Levenberg-Marquardt training algorithm:
T
H = 2F x 2J J + 2I n , where J is the Jacobian matrix of the
training set errors (see Eq. (12.37)).
13-30
Summary of Results
Regularization
x k = M x 0 + I M x
ML
MP
= M x 0 + I M x
M = 2 A + 2I
M = I A
k
eig M = 1 i
2
eig M = --------------------- i + 2
1
k -----2
Effective Number of Parameters
n
-------------------- i + 2
i=1
0n
13-31
ML
13
13 Generalization
Solved Problems
P13.1 In this problem and in the following one we want to investigate the
relationship between maximum likelihood methods and Bayesian
methods. Suppose that we have a random variable that is uniformly distributed between 0 and x. We take a series of Q independent
samples of the random variable. Find the maximum likelihood estimate of x.
Before we begin this problem, lets review the Level I Bayesian formulation
of Eq. (13.10). We will not need the Level II formulation for this simple
problem, so we do not need the regularization parameters. Also, we only
have a single parameter to estimate, so x is a scalar. Eq. (13.10) can then
be simplified to
P D x P x
P x D = ------------------------------ .
PD
We are interested in the maximum likelihood estimate for this problem, so
we need to find the value of x that maximizes the likelihood term P D x .
The data is the Q independent samples from the uniformly distributed random variable. A graph of the uniform density function is given in Figure
P13.1.
ft x
1
--x
t
x
Figure P13.1 Uniform Density Function
The definition can be written
1
--- 0 t x
.
f t x = x
0 elsewhere
13-32
Solved Problems
0 x max t
i=1
i
0 elsewhere
max t i
ML
= max t i .
13-33
13
13 Generalization
i
1
f i = -------------- exp --------
2
2
2
2
2
ti x
i=1
1
1
= -------------------------exp -------------------------- = ----------- exp E D
Q2 Q
2
Z
2
2
where
Q
1
= --------2- , E D =
2
ti x =
2
ei , Z
Q2
i=1
i=1
i=1
i=1
i=1
dE D
d
2
t x = 2 t i x = 2 t i Qx = 0 .
=
dx
dx i
13-34
Solved Problems
ML
1
= ---- t i
Q
13
i=1
ii. To find the most probable estimate, we need to use Bayes rule (Eq.
(13.10)) to find the posterior density:
P D x P x
P x D = ------------------------------ .
PD
The likelihood function P D x was found above to be
1
P D x = ----------- exp E D
Z
The prior density is
x2
1
1
P x = f x = ---------------- exp ----------2- = ---------------- exp E W ,
Z
2 x
W
2 x
where
1
12
2
= ----------2- , Z W = , E W = x .
2 x
The posterior density can then be computed as
P x D = f x t 1 t 2 t Q
f t 1 t 2 t Q x f x
= ------------------------------------------------f t 1 t 2 t Q
1
1
--------------- ---------------- exp E D + E W
ZD ZW
= ----------------------------------------------------------------------------------Normalization Factor
To find the most probable value for x, we maximize the posterior density.
This is equivalent to minimizing
Q
E D + E W = t i x + x .
2
i=1
To find the minimum, we take the derivative with respect to x and set it
equal to zero:
13-35
13 Generalization
d
d
2
2
E D + E W =
t x + x = 2 t i x + 2x
dx
d x i
i=1
i=1
= 2 t i Qx + 2x
i=1
Q
= 2 t i + Q x = 0
i=1
MP
t i
i=1
= ------------------- + Q
2
MP
13-36
Solved Problems
0.6
Px D
13
0.4
PD x
0.2
Px
x
3
MP
1
MP
To solve for
and , we will take the derivatives of the log of
P D M , given in Eq. (13.17), with respect to and , and set the derivatives to zero. Taking the log of Eq. (13.17), and substituting Eq. (13.12),
Eq. (13.14) and Eq. (13.22), we obtain
log P D M = log Z F log Z D log Z W
n
1
N
n
MP
= --- log 2 --- logdet H F x MP ---- log --- --- log ---
2
2
2
2
1
N
n
n
N
MP
= F x MP --- log det H + ---- log + --- log + --- log 2 ---- log
2
2
2
2
2
We will consider first the second term in this expression. Since H is the
Hessian of F in Eq. (13.4), we can write it as
h
H = 2F = 2 E D + 2 E W = B + 2I , where B = 2E D . If we let
b
h
b
be an eigenvalue of H and be an eigenvalue of B , then = + 2
for all corresponding eigenvalues. Now we take the derivative of the second
term in the above equation with respect to . Since the determinant of a
matrix can be expressed as the product of its eigenvalues, we can reduce it
1
as shown below, where tr H is the trace of the inverse of the Hessian H .
13-37
13 Generalization
1
1
h
--- log det H = ----------------
2
2det H
k=1
n
1
b
= ---------------- i + 2
2det H
i=1
j + 2 i + 2
1
= ---------------2det H
i = 1 ji
j + 2
b
ji
=1
= i--------------------------------------------n
i + 2
b
i=1
n
- = tr H
-----------------b
+ 2
i=1
Next, we will take the derivative of the same term with respect to . First,
define the parameter , as shown below, and expand it for use in our next
step. The parameter is referred to as the effective number of parameters.
1
n 2tr H
N
1
- =
= n 2 -----------------b
+
2
i
i=1
i=1
2
1 ------------------ =
b
+ 2
i
i
- =
-----------------b
+
2
i
i=1
1
MP
Now take the derivative of --- log det H with respect to .
2
13-38
i
---h
i
i=1
Solved Problems
1
1
h
--- log det H = ---------------- k
2
2det H
k=1
13
1
b
= ---------------- i + 2
2det H
i=1
1
= ---------------2det H
j + 2 i + 2
b
i = 1 ji
i
b
j + 2 -----
1 = 1 ji
= --- i-------------------------------------------------------n
2
b
i + 2
i=1
n
i
1
where the fourth step is derived from the fact that i is an eigenvalue of
b
B , and therefore the derivative of i with respect to is just the eigenb
value of B which is i .
Now we are finally ready to take the derivatives of all terms in
log P D M and set them equal to zero. The derivative with respect to
will be
MP
MP
1
n
log P D M = F w
--- logdet H +
--- log
2
2
MP
MP 1
n
E W w tr H + -----------MP
= EW w
MP
tr H
MP 1
n
+ ------------=0
MP
2
MP
EW w
MP
MP 1
n
= ------------ tr H
MP
2
EW w
MP
= n 2
13-39
MP
MP
tr H
= -------------------------MP
2E W w
MP 1
13 Generalization
1
N
log P D M = F w --- logdet H + ---- log
2
2
MP
E D w -----------+ -----------MP
MP
2
2
= ED w
MP
N
-----------+ -----------=0
MP
MP
2
2
Rearranging terms,
ED w
MP
= ----------- -----------MP
MP
2
2
MP
N
= -------------------------MP
2E D w
P13.4 Demonstrate that extrapolation can occur in a region that is surrounded by training data.
Consider the function displayed in Figure 13.3. In that example, extrapolation occurred in the upper left region of the input space, because all of the
training data was in the lower right. Lets provide training data around the
outside of the input space, but without data in the region
1.5 p 1 1.5
1.5 p 2 1.5 .
3
3
13-40
Solved Problems
The result of the training is shown in Figure P13.5. The neural network approximation significantly overestimates the true function in the region
without training data, even though surrounded by regions with training
data. In addition, this result is random. With a different set of initial random weights, the network might underestimate the true function in this region. Extrapolation occurs because there is a significantly large region
without training data. When the input space is of high dimension, it can be
very difficult to tell when a network is extrapolating. It cannot be done by
simply checking the individual ranges of each input variable.
a)
b)
3
2
1
0
p2
1
2
3
1
0
p2
p1
1
2
3
p1
.
-------------------- i + 2
i=1
= --- = 1 .
i=1
i
--------------------=
i + 2
13-41
i
------------------ =
i = 1 i + 2 --
-.
---------------i + 2
i=1
13
13 Generalization
---------------i + 2
1
3
1 3
14
= ------------ + ------------ = --- + --- = ------ .
1+2 3+2
3 5
15
i=1
Therefore, we are using approximately one of the two available parameters. The network has two parameters: w 1 1 and w 1 2 . The parameter we
are using is not one of these two, but rather a combination. As we can see
from Figure 13.11, we move in the direction of the second eigenvector:
v2 = 1 ,
1
which means that we are changing w 1 1 and w 1 2 by the same amount. Although there are two parameters, we are effectively using only one. Since
v 2 is the eigenvector with the largest eigenvalue, we move in that direction
to obtain the greatest reduction in the squared error.
P13.6 Demonstrate overfitting with polynomials. Consider fitting a polynomial
2
gk p = x0 + x1 p + x2 p + + xk p
to a set of data {p 1, t 1} {p 2, t 2} {p Q, tQ} so as to minimize the following squared error performance function.
Q
Fx =
tq gk pq
q=1
First, we want to express the problem in matrix form. Define the following
vectors.
k
t1
t2
G = 1 p2
k
p2
tQ
1 pQ pQ
x0
x =
x1
t =
1 p1 p1
xk
F x = t Gx t Gx = t t 2x G t + x G Gx
13-42
Solved Problems
To locate the minimum, we take the gradient and set it equal to zero.
T
F x = 2G t + 2G Gx = 0
Solving for the weights, we obtain the least squares solution (maximum
likelihood for the Gaussian noise case).
T
G G x
ML
= G t
ML
= G G G t
To demonstrate the operation of the polynomial fitting, we will use the simple linear function t = p . To create the data set, we will sample the function at five different points and will add noise as follows
t i = p i + i , p = 1 0.5 0 0.5 1 ,
where i has a uniform density with range 0.25 0.25 . The code below
shows how to generate the data and fit a 4th order polynomial. The results
of fitting 2nd and 4th order polynomials are shown in Figure P13.6. The 4th
order polynomial has five parameters, which allow it to exactly fit the five
noisy data points, but it doesnt produce an accurate approximation of the
true function.
2+2
ans =
4
p =
t =
Q =
ord
G =
for
-1:.5:1;
p + 0.5*(rand(size(p))-0.5);
length(p);
= 4;
ones(Q,1);
i=1:ord,
G = [G (p').^i];
end
x = (G'*G)\G'*t'; % Could also use x = G\t;
1.5
Function
Data
2nd Order
4th Order
0.5
0.5
1
1
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
13
13 Generalization
Epilogue
The focus of this chapter has been the development of algorithms for
training multilayer neural networks so that they generalize well. A
network that generalizes well will perform as well in new situations as it
performs on the data for which it was trained.
The basic approach to producing networks that generalize well is to find
the simplest network that can represent the data. A simple network is one
that has a small number of weights and biases.
The two methods that we presented in this chapter, early stopping and regularization, produce simple networks by constraining the weights, rather
than by reducing the number of weights. We showed in this chapter that
constraining the weights is equivalent to reducing the number of weights.
Chapter 23 presents a case study that uses Bayesian regularization to prevent overfitting in a practical function approximation problem. Chapter 25
presents a case study that uses early stopping to prevent overfitting in a
practical pattern recognition problem.
13-44
Further Reading
Further Reading
[AmMu97]
[FoHa97]
[GoLa98]
C. Goutte and J. Larsen, Adaptive Regularization of Neural Networks Using Conjugate Gradient, Proceedings of
the IEEE International Conference on Acoustics, Speech
and Signal Processing, vol. 2, pp. 1201-1204, 1998.
When using regularization, the important step is setting
the regularization parameter. This paper describes a procedure for setting the regularization parameter to minimize
the validation set error.
[MacK92]
[Sarle95]
W. S. Sarle, Stopped training and other remedies for overfitting, In Proceedings of the 27th Symposium on Interface,
1995.
This is one of the early papers on the use of early stopping
with a validation set to prevent overfitting. The paper describes simulation results comparing early stopping with
other methods for improving generalization.
13-45
13
13 Generalization
[SjLj94]
[Tikh63]
[WaVe94]
C. Wang, S. S. Venkatesh, and J. S. Judd, Optimal Stopping and Effective Machine Complexity in Learning, Advances in Neural Information Processing Systems, J. D.
Cowan, G. Tesauro, and J. Alspector, Eds., vol. 6, pp. 303310, 1994.
This paper describes how the effective number of network
parameters changes during the training process and how
the generalization capability of the network can be improved by stopping the training early.
13-46
Exercises
Exercises
E13.1 Consider fitting a polynomial (kth order)
2
gk p = x0 + x1 p + x2 p + + xk p
13
to a set of data {p 1, t 1} {p 2, t 2} {p Q, tQ} . It has been proposed that minimizing a performance index that penalizes the derivatives of the polynomial will provide improved generalization. Investigate the relationship
between this technique and regularization using squared weights.
i. Derive the least squares solution for the weights x i , which minimizes the following squared error performance index. (See Solved Problem P13.6.)
Q
Fx =
tq gk pq
q=1
Fx =
tq gk pq
+ xi
q=1
i=0
iii. Derive a solution for the weights that minimizes a sum of the
squared error plus a sum of squared derivatives.
Q
Fx =
tq gk p q
d
g p
dp k q
i=1
q=1
iv. Derive a solution for the weights that minimizes a sum of the
squared error plus a sum of squared second derivatives.
Q
F x =
tq g k pq
q=1
2+2
ans =
4
+
i=1
d
dp
g p
2 k q
E13.2 Write a MATLAB program to implement the solutions you found in E13.1
i. through iv. Using the following data points, adjust the values to obtain
the best results. Use k = 8 for all cases. Plot the data points, the noise-free
function ( t = p ) and the polynomial approximation in each case. Compare
the four approximations. Which do you think produces the best results?
Which cases produce similar results?
13-47
13 Generalization
t i = p i + i , p = 1 0.5 0 0.5 1 ,
where i has a uniform density with range 0.1 0.1 (use the rand command in MATLAB).
E13.3 Consider fitting a polynomial (1st order), g 1 p = x 0 + x 1 p , to the following
data set:
p1 = 1 t1 = 4 ,
p2 = 2 t2 = 6 .
i. Find the least squares solutions for the weights x 0 and x 1 that minimize the following sum squared error performance index:
2
Fx =
tq g 1 pq
q=1
ii. Find the regularized least squares solution for the weights x 0 and
x 1 when the following squared weight penalty is used:
2
F x =
tq g 1 p q
q=1
1
2
xi .
2
i=0
E13.4 Investigate the extrapolation characteristics of neural networks and polynomials. Consider the problem described in E11.25, where a sine wave is
fit over the range 2 p 2 . Select 11 training points evenly spaced over
this interval.
2+2
ans =
4
i. After fitting the 1-2-1 neural network over this range, plot the actual sine function and the neural network approximation over the
range 4 p 4 .
ii. Fit a fifth-order polynomial (which has the same number of free parameters as the 1-2-1 network) to the sine wave over the range
2 p 2 (using your results from E13.1 i.). Plot the actual function
and the polynomial approximation over the range 4 p 4 .
iii. Discuss the extrapolation characteristics of the neural network and
the polynomial.
E13.5 Suppose that we have a random variable t that is distributed according to
the following density function. We take a series of Q independent samples
ML
of the random variable. Find the maximum likelihood estimate of x ( x ).
13-48
Exercises
t
t
f t x = ----2 exp --
x
x
t0
E13.6 For the random variable t given in E13.5, suppose that x is a random variable with the following prior density function. Find the most probable estiMP
mate of x ( x ).
f x = exp x
x0
E13.7 Repeat E13.6 for the following prior density function. Under what condiMP
ML
tions will x
= x ?
x x
1
f x = ---------------- exp --------------------
2
2 x
2 x
2
E13.8 In the signal plus noise example given in Solved Problem P13.2, find x
for the following prior density functions.
MP
i. f x = exp x
x0
1
ii. f x = --- exp x
2
E13.9 Suppose that we have a random variable t that is distributed according to
the following density function. We take a series of Q = 2 independent samples of the random variable.
exp t x
ft x =
tx
tx
13-49
13
13 Generalization
MP
).
E13.10 We have a coin that is not fair. (The probability of heads is not the same as
the probability of tails.) We want to estimate the probability of heads ( x ).
i. If we flip the coin 10 times, the probability of getting exactly t
heads, given that the probability of heads is x , is given below. Find
ML
the maximum likelihood estimate of x ( x ). (Hint: Take the natural log of p t x before finding the maximum.) Is it reasonable? Explain.
10!
10 t
10 t
10
, where = ---------------------pt x = x 1 x
t
t
t! 10 t
ii. Assume that the probability of heads, x , is a random variable with
the following prior density function. Find the most probable estiMP
mate of x ( x ). (Hint: Take the natural log of p t x p x before
ML
MP
finding the maximum.) Explain why x
is different than x .
2
p x = 12x 1 x , 0 x 1 .
E13.11 Suppose that the prior density in the level I Bayesian analysis (see page 1312) has nonzero mean, x . Find the new performance index.
E13.12 Suppose that we have the following inputs and targets:
2 t = 1 p = 2 t = 3
p1 =
2
1
2
1
1
We want to train a single-layer linear network without a bias on this training set. Assume that each input vector occurs with equal probability. We
will train the network using the regularized performance index of Eq.
(13.34).
i. Find x
MP
MP
MP
ii. Find x
and as . Explain the difference between x
and
ML
x . (Your answer should be specific to this problemnot a general
MP
ML
discussion of the difference between x
and x .)
E13.13 Suppose we have the following input pattern and target:
2 t = 1.
p1 =
1
1
13-50
Exercises
This pattern is used to train a single layer, linear network with no bias.
i. The network is to be trained with a regularized performance index,
with the regularization parameter set to = = 1 2 . Find an
expression for the regularized performance index.
ii. Find x
MP
1 t = 2 , p = 1 t = 2 , p = 2 t = 4 ,
p1 =
2
3
1
2
3
1
2
1
where each pair occurs with equal probability. We want to minimize the
regularized performance index of Eq. (13.34).
i. Find the effective number of parameters , for = 1 .
ii. Starting with zero initial weights, approximately how many iterations of the steepest descent algorithm would need to be made on the
mean square performance index E D to produce results that would
be equivalent to minimizing the regularized performance index
with = 1 ? Assume a learning rate of = 0.01 .
2+2
ans =
4
E13.15 Repeat E11.25, but modify your program to use early stopping and to use
30 neurons. Select 10 training points and 5 validation points. Add noise to
the validation and testing points that is uniformly distributed between
0.1 and 0.1 (using the MATLAB function rand). Measure the mean square
error of the trained network on a testing set consisting of 20 equally-spaced
points of the noise-free function. Try 10 different random sets of training
and validation data. Compare the results with early-stopping with the results without early stopping.
13-51
13
13 Generalization
2+2
ans =
4
E13.16 Repeat E13.15, but use regularization instead of early stopping. This will
require modifying your program to compute the gradient of the regularized
performance index. Add the standard gradient of the squared error, which
is computed by the standard backpropagation algorithm, to the gradient of
times the squared weights. Try three different values of . Compare
these results with the early stopping results.
E13.17 Consider again the problem described in E10.4
i. Find the regularized performance index for = 0 1 . Sketch the
contour plot in each case. Indicate the location of the optimal
weights in each case.
ii. Find the effective number of parameters for = 0 1 .
iii. Starting with zero initial weights, approximately how many iterations of the steepest descent algorithm would need to be made on the
mean square performance index to produce results that would be
equivalent to minimizing the regularized performance index with
= 1 ? Assume a learning rate of = 0.01 .
2+2
ans =
4
iv. Write a MATLAB M-file to implement the steepest descent algorithm to minimize the mean square error performance index that
you found in part i. (This is a quadratic function.) Start the algorithm with zero initial conditions, and use a learning rate of
= 0.01 . Sketch the trajectory on a contour plot of the mean square
error (the contour plot was found in E10.4). Verify that at the iteration you computed in part iii., the weights are close to the same values you found to minimize the regularized performance index with
= 1 in part i.
13-52
Objectives
14
Dynamic Networks
Objectives
14-1
14-2
14-3
14-5
14-8
Dynamic Backpropagation
14-12
Preliminary Definitions
14-12
14-12
Backpropagation-Through-Time
14-22
14-34
Solved Problems
14-36
Epilogue
14-45
Further Reading
14-46
Exercises
14-47
Objectives
Neural networks can be classified into static and dynamic categories. The
multilayer network that we have discussed in the last three chapters is a
static network. This means that the output can be calculated directly from
the input through feedforward connections. In dynamic networks, the output depends not only on the current input to the network, but also on the
current or previous inputs, outputs or states of the network. For example,
the adaptive filter networks we discussed in Chapter 10 are dynamic networks, since the output is computed from a tapped delay line of previous
inputs. The Hopfield network we discussed in Chapter 3 is also a dynamic
network. It has recurrent (feedback) connections, which means that the
current output is a function of outputs at previous times.
We will begin this chapter with a brief introduction to the operation of dynamic networks, and then we will describe how these types of networks can
be trained. The training will be based on optimization algorithms that use
gradients (as in steepest descent and conjugate gradient algorithms) or Jacobians (as in Gauss-Newton and Levenberg-Marquardt algorithms) These
algorithms were described in Chapters 10, 11 and 12 for static networks.
The difference between the training of static and dynamic networks is in
the manner in which the gradient or Jacobian is computed. In this chapter,
we will present methods for computing gradients for dynamic networks.
14-1
14
14 Dynamic Networks
Recurrent
Dynamic networks are networks that contain delays (or integrators, for
continuous-time networks) and that operate on a sequence of inputs. (In
other words, the ordering of the inputs is important to the operation of the
network.) These dynamic networks can have purely feedforward connections, like the adaptive filters of Chapter 10, or they can also have some
feedback (recurrent) connections, like the Hopfield network of Chapter 3.
Dynamic networks have memory. Their response at any given time will depend not only on the current input, but on the history of the input sequence.
Because dynamic networks have memory, they can be trained to learn sequential or time-varying patterns. Instead of approximating functions, like
the static multilayer perceptron network of Chapter 11, a dynmic network
can approximate a dynamic system. This has applications in such diverse
areas as control of dynamic systems, prediction in financial markets, channel equalization in communication systems, phase detection in power systems, sorting, fault detection, speech recognition, learning of grammars in
natural languages, and even the prediction of protein structure in genetics.
Dynamic networks can be trained using the standard optimization methods that we have discussed in Chapters 9 through 12. However, the gradients and Jacobians that are required for these methods cannot be
computed using the standard backpropagation algorithm. In this chapter
we will present the dynamic backpropagation algorithms that are required
for computing the gradients for dynamic networks.
There are two general approaches (with many variations) to gradient and
Jacobian calculations in dynamic networks: backpropagation-throughtime (BPTT) [Werb90] and real-time recurrent learning (RTRL) [WiZi89].
In the BPTT algorithm, the network response is computed for all time
points, and then the gradient is computed by starting at the last time point
and working backward in time. This algorithm is efficient for the gradient
calculation, but it is difficult to implement on-line, because the algorithm
works backward in time from the last time step.
In the RTRL algorithm, the gradient can be computed at the same time as
the network response, since it is computed by starting at the first time
point, and then working forward through time. RTRL requires more calculations than BPTT for calculating the gradient, but RTRL allows a convenient framework for on-line implementation. For Jacobian calculations,
the RTRL algorithm is generally more efficient than the BPTT algorithm.
In order to more easily present general BPTT and RTRL algorithms, it will
be helpful to introduce modified notation for networks that can have recurrent connections. In the next section we will introduce this notation, and
then the remainder of the chapter will present general BPTT and RTRL algorithms for dynamic networks.
14-2
LDDN
Inputs
Layer 1
T
D
L
IW
S xR
b1
LW
2
S xS
n2(t)
S x1
1
S
2,1
S x1
S x1
S2x1
S xS
T
D
L
n3(t)
2
3
S x1
1
S
LW
3,2
S2x1
LW1,3
a3(t)
a (t)
S1x1
T
D
L
T
D
L
1,1
a (t)
n1(t)
p (t)
1
Layer 3
LW1,1
R x1
Layer 2
3
S x1
S3x1
LW2,3
The general equations for the computation of the net input n t for layer
m of an LDDN are
n t =
LW
m l
d a t d
l L m d DL m l
f
IW
m l
(14.1)
l
d p t d + b
l Im d DI m l
m l
Input Weight
Layer Weight
14
14 Dynamic Networks
a t = f n t .
(14.2)
Compare this with the static multilayer network of Eq. (11.6). LDDN networks can have several layers connecting to layer m. Some of the connections can be recurrent through tapped delay lines. An LDDN can also have
multiple input vectors, and the input vectors can be connected to any layer
in the network; for static multilayer networks, we assumed that the single
input vector connected only to Layer 1.
Simulation Order
Backpropagation Order
With static multilayer networks, the layers were connected to each other in
numerical order. In other words, Layer 1 was connected to Layer 2, which
was connected to Layer 3, etc. Within the LDDN framework, any layer can
connect to any other layer, even to itself. However, in order to use Eq.
(14.1), we need to compute the layer outputs in a specific order. The order
in which the layer outputs must be computed to obtain the correct network
output is called the simulation order. (This order need not be unique; there
may be several valid simulation orders.) In order to backpropagate the derivatives for the gradient calculations, we must proceed in the opposite order, which is called the backpropagation order. In Figure 14.1, the
standard numerical order, 1-2-3, is the simulation order, and the backpropagation order is 3-2-1.
As with the multilayer network, the fundamental unit of the LDDN is the
layer. Each layer in the LDDN is made up of five components:
1. a set of weight matrices that come into that layer (which may connect
from other layers or from external inputs),
2. any tapped delay lines (represented by DL m l or DI m l ) that appear at
the input of a set of weight matrices (Any set of weight matrices can be
preceded by a TDL. For example, Layer 1 of Figure 14.1 contains the
1 3
weights LW d and the corresponding TDL.),
3. a bias vector,
4. a summing junction, and
5. a transfer function.
The output of the LDDN is a function not only of the weights, biases, and
current network inputs, but also of some layer outputs at previous points
in time. For this reason, it is not a simple matter to calculate the gradient
of the network output with respect to the weights and biases. The weights
and biases have two different effects on the network output. The first is the
direct effect, which can be calculated using the standard backpropagation
algorithm from Chapter 11. The second is an indirect effect, since some of
14-4
the inputs to the network are previous outputs, which are also functions of
the weights and biases. The main development of the next two sections is
a general gradient calculation for arbitrary LDDNs.
Before we introduce dynamic training, lets get a feeling for the types of responses we can expect to see from dynamic networks. Consider first the
feedforward dynamic network shown in Figure 14.2.
Inputs
p(t)
Linear Neuron
iw1,1(0)
D
D
iw1,1(1)
n(t)
a(t)
iw1,1(2)
a(t) = iw1,1(0)p(t)+iw1,1(1)p(t-1)+iw1,1(2)p(t-2)
Figure 14.2 Example Feedforward Dynamic Network
This is an ADALINE filter, which we discussed in Chapter 10 (see Figure
10.5). Here we are representing it in the LDDN framework. The network
has a TDL on the input, with DI 1 1 = 0 1 2 . To demonstrate the operation of this network, we will apply a square wave as input, and we will set
all of the weight values equal to 1/3:
1
1
1
iw 1 1 0 = --- , iw 1 1 1 = --- , iw 1 1 2 = --- .
3
3
3
(14.3)
at = n t =
IW d p t d
d=0
(14.4)
= n 1 t = iw 1 1 0 p t + iw 1 1 1 p t 1 + iw 1 1 2 p t 2
where we have left off the superscripts on the weight and the input, since
there is only one input and only one layer.
14-5
14
14 Dynamic Networks
FIR
The response of the network is shown in Figure 14.3. The open circles represent the square-wave input signal p t . The dots represent the network
response a t . For this dynamic network, the response at any time point
depends on the previous three input values. If the input is constant, the
output will become constant after three time steps. This type of linear network is called a Finite Impulse Response (FIR) filter.
1.5
D
1
0.5
0.5
1.5
10
15
20
25
Now consider another simple linear dynamic network, but one that has a
recurrent connection. The network in Figure 14.4 is a recurrent dynamic
network. The equation of operation of the network is
1
a t = n t = LW
1 1
1 a t 1 + IW
1 1
= lw 1 1 1 a t 1 + iw 1 1 p t
0 p t
(14.5)
where, in the last line, we have left off the superscripts, since there is only
one neuron and one layer in the network. To demonstrate the operation of
this network, we will set the weight values to
1
1
lw 1 1 1 = --- and iw 1 1 = --- .
2
2
14-6
(14.6)
Linear Neuron
Inputs
iw1,1
p(t)
n(t)
a(t)
lw1,1(1)
14
a(t) = iw1,1 p(t) + lw1,1(1) a(t-1)
0.5
0.5
1.5
10
15
20
25
14-7
14 Dynamic Networks
can be trained to approximate dynamic systems, such as robot arms, aircraft, biological processes and economic systems, where the current system
output depends on a history of previous inputs and outputs. Because dynamic systems are more complex than static functions, we expect that the
training process for dynamic networks will be more challenging than static
network training.
In the following section, we will discuss the computation of gradients for
the training of dynamic networks. For static networks, these gradients
were computed using the standard backpropagation algorithm. For dynamic networks, the backpropagation algorithm must be modified.
Before we get into the details of training dynamic networks, lets first investigate a simple example. Consider again the recurrent network of Figure 14.4. Suppose that we want to train the network using steepest
descent. The first step is to compute the gradient of the performance function. For this example we will use sum squared error:
Q
Fx =
t =
tt a t
(14.7)
t=1
t=1
t=1
F x
--------------- =
iw 1 1
a t
e t
------------------------ = 2 e t ------------------------ ,
lw 1 1 1
lw 1 1 1
t=1
(14.8)
t=1
a t
e t
--------------- = 2 e t --------------iw 1 1
iw 1 1
(14.9)
t=1
The key terms in these equations are the derivatives of the network output
with respect to the weights:
a t
a t
------------------------ and --------------- .
lw 1 1 1
iw 1 1
(14.10)
If we had a static network, then these terms would be very easy to compute.
They would correspond to a t 1 and p t , respectively. However, for recurrent networks, the weights have two effects on the network output. The
first is the direct effect, which is also seen in the corresponding static network. The second is an indirect effect, caused by the fact that one of the network inputs is a previous network output. Lets compute the derivatives of
the network output, in order to demonstrate these two effects.
14-8
(14.11)
We can compute the terms in Eq. (14.10) by taking the derivatives of Eq.
(14.11):
a t
a t 1
------------------------ = a t 1 + lw 1 1 1 ------------------------ ,
lw 1 1 1
lw 1 1 1
(14.12)
a t
a t 1
--------------- = p t + lw 1 1 1 ---------------------- .
iw 1 1
iw 1 1
(14.13)
14
The first term in each of these equations represents the direct effect that
each weight has on the network output. The second term represents the indirect effect. Note that unlike the gradient computation for static networks,
the derivative at each time point depends on the derivative at previous
time points (or at future time points, as we will see later).
The following figures illustrate the dynamic derivatives. In Figure 14.6 a)
we see the total derivatives a t iw 1 1 and also the static portions of the
derivatives. Note that if we consider only the static portion, we will underestimate the effect of a change in the weight. In Figure 14.6 b) we see the
original response of the network (which was also shown in Figure 14.5) and
a new response, in which iw 1 1 is increased from 0.5 to 0.6. By comparing
the two parts of Figure 14.6, we can see how the derivative indicates the
effect on the network response of a change in the weight iw 1 1 .
a)
b)
2
Total Derivative
Static Derivative
1.5
1.5
1
0.5
Original Response
Incremental Response
0.5
0.5
0.5
1
1
1.5
10
15
20
25
1.5
10
15
20
25
14-9
14 Dynamic Networks
b)
1.5
1.5
1
1
Original Response
Incremental Response
0.5
0.5
0.5
0.5
1
1
1.5
Total Derivative
Static Derivative
0
10
15
20
25
1.5
10
15
20
25
p(t)
a(t)
Multilayer Network
a(t) = NN(p(t),a(t-1),x)
14-10
F
------ =
x
t=1
a t
-----------T
x
F
------------ ,
a t
(14.14)
F
------------ .
a t
(14.15)
or
Q
F
------ =
x
t=1
at
-------------T
x
a t
at
at
a t 1
- -------------------------------= -------------- + ----------------------T
T
T
T
x
x
a t 1
x
(14.16)
and
e
F
F
F at + 1
------------ = ------------ + ----------------------- ---------------------- .
T
t + 1
a t
a t
a t
RTRL
Eq. (14.14) and Eq. (14.16) make up the real-time recurrent learning
(RTRL) algorithm. Note that the key term is
a t
-----------,
T
x
BPTT
(14.17)
(14.18)
which must be propagated forward through time. Eq. (14.15) and Eq.
(14.17) make up the backpropagation-through-time (BPTT) algorithm.
Here the key term is
F
-----------a t
(14.19)
14
14 Dynamic Networks
Dynamic Backpropagation
In this section, we will develop general RTRL and BPTT algorithms for dynamic networks represented in the LDDN framework. This development
will involve generalizing Eq. (14.14) through Eq. (14.17).
Preliminary Definitions
Input Layer
Output Layer
t = 1u U
a t
-------------T
x
F
- .
-------------u
a t
(14.20)
Dynamic Backpropagation
Eq. (14.16)
The next step of the development of the RTRL algorithm is the generalization of Eq. (14.16). Again, we use the chain rule:
u
e u
e u
e x
u'
n t
a t
a t d
a t
a t
-----------------T --------------------------T- ------------------------ . (14.21)
-------------- = ----------------+
T
T
T
x
u'
x
x
x
n
a
u' U x X d DL x u'
In Eq. (14.16) we only had one delay in the system. Now we need to account
for each output and also for the number of times each output is delayed before it is input to another layer. That is the reason for the first two summations in Eq. (14.21). These equations must be updated forward in time, as
t is varied from 1 to Q. The terms
u
a t
-------------T
x
(14.22)
e x
n t
a t
-----------------T --------------------------T- .
x
u'
n t
a t d
(14.23)
nk t =
x l
lw k i d' ai t d'
l
l L x d' DL x l i = 1
f
(14.24)
x l
+ bk
l Ix d' DI x l i = 1
nk t
x u'
-----------------------= lw k j d .
u'
a j t d
(14.25)
e u
ak t
----------------,
m
n i t
(14.26)
14
14 Dynamic Networks
u m
u m
u m
u m
u m
u m
s 1 1 t s 1 2 t s 1 Sm t
S
u m
e u
a t
t = ------------------T- =
m
n t
s 2 1 t s 2 2 t s 1 Sm t
u m
u m
(14.27)
u m
s Su 1 t s Su 2 t s S u Sm t
e x
n t
a t
-----------------T --------------------------Tx
u'
n t
a t d
=
i j
u x
x u'
si k t + d lwk j d ,
(14.28)
k=1
or in matrix form
e u
e x
n t
a t
u x
x u'
-----------------T --------------------------T- = S t LW d .
x
u'
n t
a t d
(14.29)
u'
e u
a t
a t d
a t
u x
x u'
-------------- = ----------------+
S t LW d -----------------------
T
T
T
x
x
x
u' U x X d DL x u'
(14.30)
Many of the terms in the summation on the right hand side of Eq. (14.30)
will be zero and will not have to be computed. To take advantage of these
efficiencies, we introduce some indicator sets. They are sets that tell us for
which layers the weights and the sensitivities are nonzero.
The first type of indicator set contains all of the output layers that connect
to a specified layer x (which will always be an input layer) with at least
some nonzero delay:
U
E LW x = u U LW
x u
d 0 d 0 ,
(14.31)
E S u = x X S
u x
0 .
(14.32)
u x
(When S
is nonzero, there is a static connection from layer x to ouput
layer u .) The third type of indicator set contains the layers that have a nonzero sensitivity with a specified layer u :
E S u = x S
14-14
u x
0 .
(14.33)
Dynamic Backpropagation
e u
a t
a t
-------------- = ---------------T
T
x
x
u x
x ES u
u' E LW x
LW
x u'
d DL x u'
u'
a t d
d -----------------------T
x
. (14.34)
Eq. (14.34) makes up the generalization of Eq. (14.16) for the LDDN netu m
work. It remains to compute the sensitivity matrices S t and the explice u
it derivatives a t w , which are described in the next two subsections.
Sensitivities
In order to compute the elements of the sensitivity matrix, we use a form
of standard static backpropagation. The sensitivities at the outputs of the
network can be computed as
u u
s k i t
u u
f n i t for i = k
e u
ak t
= ---------------- =
u
n i t
for i k
, uU,
(14.35)
u u
u
u
t = F n t ,
(14.36)
where F n t is defined as
u u
f n 1 t
u
n2 t
(14.37)
u
u
F n t =
0
u
u u
f n Su t
u m
(see also Eq. (11.34)). The matrices S t can be computed by backpropagating through the network, from each network output, using
S
u m
t =
u l
l ES u
14-15
S t LW
b
Lm
l m
m
m
0 F n t , u U ,
(14.38)
14
14 Dynamic Networks
a t
----------------.
T
x
(14.39)
Using the chain rule of calculus, we can derive the following expansion of
Eq. (14.39) for input weights:
e u
e u
e m
ak t
ni t
ak t
u m
l
- ---------------------- = s k i t p j t d .
---------------------- = ---------------m
m l
m l
iw i j d
n i t iw i j d
(14.40)
a t
u m
l
---------------------- = si t pj t d .
m l
iw i j d
(14.41)
T
a t
l
u m
------------------------------------------T = p t d S t ,
m l
vec IW d
(14.42)
and in a similar way we can derive the derivatives for layer weights and
biases:
e u
T
a t
l
u m
-------------------------------------------T- = a t d S t ,
m l
vec LW d
(14.43)
e u
a t
u m
----------------T- = S t ,
m
b
(14.44)
where the vec operator transforms a matrix into a vector by stacking the
columns of the matrix one underneath the other, and A B is the Kronecker product of A and B [MaNe99].
The total RTRL algorithm for the LDDN network is summarized in the following pseudo code.
14-16
Dynamic Backpropagation
Initialize:
Real-Time Recurrent Learning Gradient
u
a t
-------------- = 0 t 0 , for all u U ,
T
x
For t = 1 to Q,
X
U = , E S u = and E S u = for all u U .
For m decremented through the BP order
b
For all u U , if E S u L m
S
u m
u l
t =
S t LW
l m
14
m
m
0 F n t
l ES u Lm
T
a t
l
u m
------------------------------------------T = p t d S t
m l
vec IW d
e u
T
a t
l
u m
-------------------------------------------T- = a t d S t
m l
vec LW d
e u
a t
u m
----------------T- = S t
m
b
EndFor weights and biases
u
e u
a t
a t
-------------- = ----------------+
T
T
x
x
u x
x ES u
EndFor u
EndFor t
Compute Gradients
F
------ =
x
t = 1u U
a t
-------------T
x
F
-------------u
a t
14-17
u' E LW x
d DL x u'
LW
x u'
u'
a t d
d -----------------------T
x
14 Dynamic Networks
To demonstrate the RTRL algorithm, consider again the feedforward dynamic network of Figure 14.2. The equation of operation of this network is
a t = n t = iw 1 1 0 p t + iw 1 1 1 p t 1 + iw 1 1 2 p t 2 .
The architecture of the network is defined by
U = 1 , X = 1 , I 1 = 1 , DI 1 1 = 0 1 2 , L 1 = , E LW 1 = .
We will choose the following standard performance function with three
time points:
Q
F =
3
2
t t a t =
t=1
t = e 1 + e 2 + e 3 ,
t=1
U = , E S 1 = , E S 1 = .
In addition, the initial conditions for the delays, p 0 p 1 , must be provided.
The network response is then computed for the first time step:
a 1 = n 1 = iw 1 1 0 p 1 + iw 1 1 1 p 0 + iw 1 1 2 p 1
Because the RTRL algorithm proceeds forward through time, we can immediately compute the derivatives for the first time step. We will see in the
next section that the BPTT algorithm, which proceeds backward through
time, will require that we proceed through all of the time points before we
can compute the derivatives.
From the preceding pseudo-code, the first step in the derivative calculation
will be
S
1 1
1
1
1 = F n 1 = 1 ,
since the transfer function is linear. We also update the following sets:
X
ES 1 = 1 , ES 1 = 1 .
14-18
Dynamic Backpropagation
The next step is the computation of the explicit derivatives from Eq.
(14.42):
e 1
e 1
T
a1
a 1
1
1 1
------------------------------------------T = ----------------------- = p 1 S t = p 1 ,
1 1
iw
1 1
vec IW 0
T
a1
a 1
1
1 1
------------------------------------------T = ----------------------- = p 0 S t = p 0 ,
1 1
iw
1
1
vec IW 1
e 1
T
a1
a 1
1
1 1
------------------------------------------T = ----------------------- = p 1 S t = p 1 .
1 1
iw
1 1
vec IW 2
The next step would be to compute the total derivative, using Eq. (14.34).
U
However, since E LW 1 = , the total derivatives are equal to the explicit
derivatives.
All of the above steps would be repeated for each time point, and then the
final step is to compute the derivatives of the performance index with respect to the weights, using Eq. (14.20):
F
------ =
x
t = 1u U
a t
-------------T
x
F
- =
-------------u
a t
t=1
a t
-------------T
x
F
- .
-------------1
a t
14
14 Dynamic Networks
U = 1 , X = 1 , I 1 = 1 , DI 1 1 = 0 ,
f
DL 1 1 = 1 , L 1 = 1 , E LW 1 = 1 .
We will choose the same performance function as the previous example:
Q
F =
3
2
t t a t =
t=1
t = e 1 + e 2 + e 3 ,
t=1
U = , E S 1 = , E S 1 = .
In addition, the initial condition for the delay, a 0 , and the initial derivatives
a 0
a 0
--------------- and ----------------------iw 1 1
lw 1 1 1
must be provided. (The initial derivatives are usually set to zero.)
The network response is then computed for the first time step:
a 1 = lw 1 1 1 a 0 + iw 1 1 p 1
The derivative calculation begins with
S
1 1
1
1
1 = F n 1 = 1 ,
since the transfer function is linear. We also update the following sets:
X
ES 1 = 1 , ES 1 = 1 .
The next step is the computation of the explicit derivatives:
e 1
T
a1
a 1
1
1 1
------------------------------------------T = ---------------- = p 1 S 1 = p 1 ,
1 1
iw
1 1
vec IW 0
e 1
T
a1
a 1
1
1 1
-------------------------------------------T- = ----------------------- = a 0 S 1 = a 0 .
1 1
lw
1
1
vec LW 1
14-20
Dynamic Backpropagation
The next step is to compute the total derivative, using Eq. (14.34):
1
e 1
a t
a t
a t 1
1 1
1 1
-.
-------------- = ---------------- + S t LW 1 ----------------------T
T
T
x
x
x
(14.45)
Replicating this formula for each of our weights for this network, for t = 1 ,
we have
a 0
a 1
--------------- = p 1 + lw 1 1 1 --------------- = p 1 ,
iw 1 1
iw 1 1
a 0
a 1
----------------------- = a 0 + lw 1 1 1 ----------------------- = a 0 .
lw 1 1 1
lw 1 1 1
Note that unlike the corresponding equation in the previous example, these
equations are recursive. The derivative at the current time depends on the
derivative at the previous time. (Note that the two initial derivatives on the
right side of this equation would normally be set to zero, but at the next
time step they would be nonzero.) As we mentioned earlier, the weights in
a recurrent network have two different effects on the network output. The
first is the direct effect, which is represented by the explicit derivative in
Eq. (14.45). The second is an indirect effect, since one of the inputs to the
network is a previous output, which is also a function of the weights. This
effect causes the second term in Eq. (14.45).
All of the above steps would be repeated for each time point:
e
a2
a2
---------------- = p 2 , ----------------------- = a 1 ,
iw 1 1
lw 1 1 1
a 1
a 2
--------------- = p 2 + lw 1 1 1 --------------- = p 2 + lw 1 1 1 p 1 ,
iw 1 1
iw 1 1
a 1
a 2
----------------------- = a 1 + lw 1 1 1 ----------------------- = a 1 + lw 1 1 1 a 0 ,
lw 1 1 1
lw 1 1 1
e
a3
a3
---------------- = p 3 , ----------------------- = a 2 ,
iw 1 1
lw 1 1 1
a 3
a 2
2
--------------- = p 3 + lw 1 1 1 --------------- = p 3 + lw 1 1 1 p 2 + lw 1 1 1 p 1 ,
iw 1 1
iw 1 1
a 2
a 3
2
----------------------- = a 2 + lw 1 1 1 ----------------------- = a 2 + lw 1 1 1 a 1 + lw 1 1 1 a 0 .
lw 1 1 1
lw 1 1 1
14-21
14
14 Dynamic Networks
The final step is to compute the derivatives of the performance index with
respect to the weights, using Eq. (14.20):
F
------ =
x
t = 1u U
a t
-------------T
x
F
-------------- =
u
a t
t=1
a t
-------------T
x
F
-------------- .
1
a t
a 2
a 3
a 1
F
--------------- = --------------- 2e 1 + --------------- 2e 2 + --------------- 2e 3
iw 1 1
iw 1 1
iw 1 1
iw 1 1
= 2e 1 p 1 2e 2 p 2 + lw 1 1 1 p 1
2
2e 3 p 3 + lw 1 1 1 p 2 + lw 1 1 1 p 1
a 1
a 2
a 3
F
----------------------- = ----------------------- 2e 1 + ----------------------- 2e 2 + ----------------------- 2e 3
lw 1 1 1
lw 1 1 1
lw 1 1 1
lw 1 1 1
= 2e 1 a 0 2e 2 a 1 + lw 1 1 1 a 0
2
2e 3 a 2 + lw 1 1 1 a 1 + lw 1 1 1 a 0
The expansions that we show in the final two lines of the above equations
(and also in some of the previous equations) would not be necessary in practice, since the results would be numerical. We have included them here so
that we can compare this result with the BPTT algorithm, which we
present next.
Backpropagation-Through-Time
In this section we will generalize the Backpropagation-Through-Time
(BPTT) algorithm, given in Eq. (14.15) and Eq. (14.17), for LDDN networks.
Eq. (14.15)
The first step is to generalize Eq. (14.15). For the general LDDN network,
we can calculate the terms of the gradient by using the chain rule, as in
F
---------------------- =
m l
lw i j d
t=1
e u
e m
ak t ni t
F
- ---------------- --------------------- -------------u
m
m l
n i t lw i j d
u U k = 1 a k t
(14.46)
(for the layer weights), where u is an output layer, U is the set of all output
u
layers, and S is the number of neurons in layer u .
From Eq. (14.24) we can write
14-22
Dynamic Backpropagation
e m
ni t
l
---------------------- = aj t d .
m l
lw i j d
(14.47)
e u
u Uk = 1
ak t
F
-------------- ----------------.
u
m
a k t n i t
(14.48)
14
The terms of the gradient for the layer weights can then be written
Q
F
---------------------- =
m l
lw i j d
d i t aj t d ,
m
(14.49)
t=1
ak t
u m
-,
s k i t ---------------m
n i t
(14.50)
di t =
u m
- s k i t .
-------------u
a t
u Uk = 1
(14.51)
d t =
u m
uU
T
F
t -------------u
a t
(14.52)
where
F
F
F
F
- -------------- ----------------------------- = -------------u
u
u
u
a 1 t a 2 t
a S u t
a t
(14.53)
t a t d ,
(14.54)
t=1
and by similar steps we can find the derivatives for the biases and input
weights:
14-23
14 Dynamic Networks
F
------------------------- =
m l
IW d
t p t d ,
(14.55)
t=1
F
--------m- =
b
t .
(14.56)
t=1
Eq. (14.54) through Eq. (14.56) make up the generalization of Eq. (14.15)
for the LDDN network.
Eq. (14.17)
The next step in the development of the BPTT algorithm is the generalization of Eq. (14.17). Again, we use the chain rule:
e
F
F
-------------- = -------------u
u
a t
a t
+
u' U x X d DL x u
e u'
e x
a t + d n t + d
--------------------------T- -------------------------T
x
u
n t + d
a t
F
-----------------------u'
a t + d
(14.57)
(14.58)
e x
a t + d n t + d
u' x
x u
--------------------------T- -------------------------- = S t + d LW d .
T
x
u
n t + d
a t
This allows us to write Eq. (14.57) as
14-24
(14.59)
Dynamic Backpropagation
F
F
-------------- = -------------u
u
a t
a t
+
u' x
t + d LW
x u
u' U x X d DL x u
T
F
d -----------------------u'
a t + d
(14.60)
Many of the terms in the summation on the right hand side of Eq. (14.60)
will be zero and will not have to be computed. In order to provide a more
efficient implementation of Eq. (14.60), we define the following indicator
sets:
X
E LW u = x X LW
x u
d 0 d 0 ,
E S x = u U S
u x
0 .
(14.61)
(14.62)
The first set contains all of the input layers that have a connection from
output layer u with at least some nonzero delay. The second set contains
output layers that have a nonzero sensitivity with input layer x . When the
u x
sensitivity S
is nonzero, there is a static connection from input layer x
to output layer u .
We can now rearrange the order of the summation in Eq. (14.60) and sum
only over the existing terms:
e
F
F
-------------- = -------------u
u
a t
a t
+
X
x E LW u d DL x u
LW
x u
u' E S x
u' x
T
F
t + d -----------------------u'
a t + d
(14.63)
Summary
The total BPTT algorithm is summarized in the following pseudo code.
14-25
14
14 Dynamic Networks
Initialize:
Backpropagation-Through-Time Gradient
F
-------------- = 0 t Q , for all u U ,
u
a t
For t = Q to 1,
U
U = , E S u = , and E S u = for all u U .
For m decremented through the BP order
b
For all u U , if E S u L m
S
u m
u l
t =
S t LW
l m
m
m
0 F n t
l ES u L m
F
F
-------------- = --------------+
u
u
a t
a t
LW
X
x E LW u d DL x u
u m
u ES m
T
F
t -------------u
a t
F
------------------------- =
m l
IW d
F
--------m- =
b
t a t d
t=1
Q
t p t d
t=1
t=1
14-26
EndFor m
EndFor t
Compute Gradients
F
--------------------------- =
m l
LW d
u' E S x
EndFor u
For all layers m
d t =
x u
u' x
T
F
t + d -----------------------u'
a t + d
Dynamic Backpropagation
To demonstrate the BPTT algorithm, we will use the same example networks that we used for the RTRL algorithm. First, we use the feedforward
dynamic network of Figure 14.2. We defined the network architecture on
page 14-18.
Before the gradient can be computed using BPTT, the network response
must be computed for all time steps:
a 1 = n 1 = iw 1 1 0 p 1 + iw 1 1 1 p 0 + iw 1 1 2 p 1 ,
a 2 = n 2 = iw 1 1 0 p 2 + iw 1 1 1 p 1 + iw 1 1 2 p 0 ,
a 3 = n 3 = iw 1 1 0 p 3 + iw 1 1 2 p 0 + iw 1 1 2 p 1 .
The BPTT algorithm begins with some initialization:
U
U = , E S 1 = , E S 1 = .
The first step in the derivative calculation will be the sensitivity calculation. For BPTT, we start at the last time point ( t = 3 ):
S
1 1
1
1
3 = F n 3 = 1 ,
since the transfer function is linear. We also update the following sets:
U
ES 1 = 1 , ES 1 = 1 .
The next step is the calculation of the following derivative using Eq.
(14.63):
e
F
F
--------------- = --------------- = 2e 3 .
1
1
a 3
a 3
The final step for t = 3 is Eq. (14.52):
1
d 3 = S
1 1
T
F
- = 2e 3 .
3 --------------1
a 3
1 1
T
F
- = 2e 2 ,
2 --------------1
a 2
1 1
T
F
- = 2e 1 .
1 --------------1
a 1
d 2 = S
d 1 = S
14-27
14
14 Dynamic Networks
iw
1 1 0
IW 0
F
F
------------------------- = ----------------------- =
1 1
iw
1 1 1
IW 1
F
F
------------------------- = ----------------------- =
1 1
iw
1 1 2
IW 2
3
1
t p t =
t=1
3
1
d t p t 1 =
t=1
2e t p t 1 ,
t=1
2e t p t ,
t=1
3
1
d t p t 2 =
t=1
2e t p t 2 .
t=1
Note that this is the same result we obtained for the RTRL algorithm example on page 14-19. RTRL and BPTT should always produce the same
gradient. The only difference is in the implementation.
2
+2
Lets now use our previous recurrent neural network example of Figure
14.4. We defined the architecture of this network on page 14-19.
Unlike the RTRL algorithm, where initial conditions for the derivatives
must be provided, the BPTT algorithm requires final conditions for the derivatives:
a 4
a 4
--------------- and ----------------------- ,
iw 1 1
lw 1 1 1
which are normally set to zero.
The network response is then computed for all time steps:
a 1 = lw 1 1 1 a 0 + iw 1 1 p 1
a 2 = lw 1 1 1 a 1 + iw 1 1 p 2
a 3 = lw 1 1 1 a 2 + iw 1 1 p 3
The derivative calculation begins with
S
1 1
1
1
3 = F n 3 = 1 ,
since the transfer function is linear. We also update the following sets:
X
ES 1 = 1 , ES 1 = 1 .
Next we compute the following derivative using Eq. (14.63):
14-28
Dynamic Backpropagation
T 1 1
T
F
F
F
1 1
-------------- = -------------- + LW 1 S t + 1 ----------------------1
1
1
a t
a t
a t + 1
For t = 3 , we find
0
e
e
T
F
F
F
F
1 1
----------------------------=
--------------+
lw
=
--------------- = 2e 3
1
S
1
1
1
1
1
a 3
a 3
a 4
a 3
and
1
d 3 = S
1 1
T
F
- = 2e 3
3 --------------1
a 3
Continuing to t = 2 ,
S
1 1
1
1
2 = F n 2 = 1 ,
T
F
F
F
1 1
--------------- = --------------- + lw 1 1 1 S 3 --------------1
1
1
a 2
a 2
a 3
= 2e 2 + lw 1 1 1 2e 3
and
1
d 2 = S
1 1
T
F
- = 2e 2 + lw 1 1 1 2e 3
2 --------------1
a 2
Finally, for t = 1 ,
S
1 1
1
1
1 = F n 1 = 1 ,
T
F
F
F
1 1
--------------- = --------------- + lw 1 1 1 S 2 --------------1
1
1
a 1
a 1
a 2
2
= 2e 1 + lw 1 1 1 2e 2 + lw 1 1 1 2e 3
and
1
d 1 = S
1 1
T
F
2
- = 2e 1 + lw 1 1 1 2e 2 + lw 1 1 1 2e 3
1 --------------1
a 1
Now we can compute the total gradient, using Eq. (14.54) and Eq. (14.55):
14-29
14
14 Dynamic Networks
F
F
--------------------------- = ----------------------- =
1 1
lw
1 1 1
LW 1
t a t 1
t=1
2
= a 0 2e 1 + lw 1 1 1 2e 2 + lw 1 1 1 2e 3
+ a 1 2e 2 + lw 1 1 1 2e 3 + a 0 2e 3
F
F
------------------------- = --------------- =
1 1
iw 1 1
IW 0
t p t
t=1
2
= p 1 2e 1 + lw 1 1 1 2e 2 + lw 1 1 1 2e 3
+ p 2 2e 2 + lw 1 1 1 2e 3 + p 3 2e 3
This is the same result that we obtained with the RTRL algorithm on page
14-22.
Dynamic Backpropagation
Tan-Sigmoid Neuron
Inputs
iw1,1
p(t)
n(t)
a(t)
lw1,1(1)
D
a(t) = tansig( iw1,1 p(t) + lw1,1(1) a(t-1) )
Figure 14.9 Nonlinear Recurrent Network
Recall from Chapter 11 that static multilayer networks can be used to approximate functions. Dynamic networks can be used to approximate dynamic systems. A function maps from one vector space (the domain) to
another vector space (the range). A dynamic system maps from one set of
time sequences (the input sequences p t ) to another set of time sequences
(the output sequences a t ). For example, the network of Figure 14.9 is a
dynamic system. It maps from input sequences to output sequences.
In order to simplify our analysis, we will give the network a problem for
which we know the optimal solution. The dynamic system we will approximate is the same network, with the following values for the weights:
14-31
14
14 Dynamic Networks
lw 1 1 1 = 0.5 , iw 1 1 = 0.5 ,
(14.64)
The input sequence that we use to train a dynamic network must be representative of all possible input sequences. Because this network is so simple,
it is not difficult to find an appropriate input sequence, but for many practical networks it can be difficult. We will use a standard form of input sequence (called the skyline function), which consists of a series of pulses of
varying height and width. The input and target sequences are shown in
Figure 14.10. The circles represent the input sequence and the dots represent the target sequence. The targets were created by applying the given
input sequence to the network of Figure 14.9, with the weights given by Eq.
(14.64).
1
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1
10
12
14
16
18
20
14-32
Dynamic Backpropagation
1.5
1.4
1
1.2
1
0.5
lw 1 1 1
0.8
0.6
0.4
0.5
0.2
0
2
1
1.5
2
2
1.5
0.5
0.5
1.5
lw 1 1 1
1
2
iw 1 1
iw 1 1
Figure 14.11 Performance Surface and Steepest Descent Trajectory
To experiment with the training of this recurrent network, use the Neural
Network Design Demonstration Recurrent Network Training (nnd14rnt).
14-33
14
14 Dynamic Networks
Summary of Results
Initialize:
Real-Time Recurrent Learning Gradient
u
a t
-------------- = 0 t 0 , for all u U ,
T
x
For t = 1 to Q,
X
U = , E S u = and E S u = for all u U .
For m decremented through the BP order
b
For all u U , if E S u L m
S
u m
u l
t =
S t LW
l m
m
m
0 F n t
l ES u Lm
T
a t
l
u m
-------------------------------------------T- = a t d S t
m l
vec LW d
e u
a t
u m
----------------T- = S t
m
b
EndFor weights and biases
u
e u
a t
a t
-------------- = ----------------+
T
T
x
x
u x
x ES u
EndFor u
EndFor t
Compute Gradients
F
------ =
x
t = 1u U
a t
-------------T
x
F
-------------u
a t
14-34
u' E LW x
d DL x u'
LW
x u'
u'
a t d
d -----------------------T
x
Summary of Results
Initialize:
Backpropagation-Through-Time Gradient
F
-------------- = 0 t Q , for all u U ,
u
a t
For t = Q to 1,
U
U = , E S u = , and E S u = for all u U .
For m decremented through the BP order
b
For all u U , if E S u L m
S
u m
u l
t =
S t LW
l m
14
m
m
0 F n t
l ES u L m
F
F
-------------- = --------------+
u
u
a t
a t
LW
X
x E LW u d DL x u
u m
u ES m
T
F
t -------------u
a t
F
------------------------- =
m l
IW d
F
--------m- =
b
t a t d
t=1
Q
t p t d
t=1
t=1
14-35
EndFor m
EndFor t
Compute Gradients
F
--------------------------- =
m l
LW d
u' E S x
EndFor u
For all layers m
d t =
x u
u' x
T
F
t + d -----------------------u'
a t + d
14 Dynamic Networks
Definitions/Notation
l
IW
m l
LW
b
m l
DL m l is the set of all delays in the tapped delay line between Layer l and
Layer m.
DIm l is the set of all delays in the tapped delay line between Input l and
Layer m.
I m is the set of indices of input vectors that connect to layer m.
f
E LW x = u U LW
X
E S u = x X S
E S u = x S
u x
u x
d 0 d 0
E LW u = x X LW
U
x u
E S x = u U S
u x
x u
d 0 d 0
14-36
Solved Problems
Solved Problems
P14.1 Before stating the problem, lets first introduce some notation that
will allow us to efficiently represent dynamic networks:
14
1
2
1
1
3
6
4
10
14 Dynamic Networks
L 1 = , L 2 = 1 2 , L 3 = 2 , L 4 = 3 4 7 , L 5 = 4 ,
f
L 6 = 2 5 , L 7 = 2 , L 8 = 7 , L 9 = 4 8 , L 10 = 6 9 .
L 1 = 2 , L 2 = 3 6 7 , L 3 = , L 4 = 5 9 , L 5 = ,
b
L 6 = 10 , L 7 = 4 8 , L 8 = , L 9 = 10 , L 10 = .
Associated with these connections are the following layer delays
DL 2 1 = 0 , DL 2 2 = 1 , DL 3 2 = 0 , DL 4 3 = 1 , DL 4 4 = 1 ,
DL 4 7 = 0 , DL 5 4 = 0 , DL 6 2 = 0 , DL 6 5 = 0 1 , DL 7 2 = 0 ,
DL 8 7 = 0 , DL 9 4 = 0 , DL 9 8 = 1 , DL 10 6 = 0 , DL 10 9 = 0 .
The layers that have connections from output layers are
U
E LW 2 = 2 , E LW 4 = 3 4 ,
U
E LW 6 = 5 , E LW 9 = 8 .
The layers that connect to input layers are
X
E LW 2 = 2 , E LW 3 = 4 , E LW 4 = 4 ,
X
E LW 5 = 6 , E LW 8 = 9 .
The simulation order can be chosen to be 1 2 3 7 4 5 6 8 9 10 . The dimensions of the weight matrices are
IW
1 1
0 2 3 , LW
2 1
0 3 2 , LW
2 2
1 3 3 , LW
3 2
0 2 3 ,
LW
4 3
1 1 2 , LW
4 4
1 1 1 , LW
4 7
0 1 2 , LW
5 4
0 2 1 ,
LW
6 2
0 4 3 , LW
6 5
1 4 2 , LW
7 2
0 2 3 , LW
8 7
0 3 2 ,
LW
9 4
0 2 1 , LW
9 8
1 2 3 , LW
14-38
10 6
0 1 4 , LW
10 9
d 1 2 .
Solved Problems
P14.2 Write out the BPTT equations for the network presented in Problem P14.1.
We will assume that the network response has been computed for all time
points, and we will demonstrate the process for one time step, since they all
will be similar. We proceed through the layers according to the backpropagation order, which is the reverse of the simulation order:
10 9 8 6 5 4 7 3 2 1 .
S
10 10
10
10
t = F n t
e
F
F
---------------- = ---------------10
10
a t
a t
10
d t = S
S
10 9
t = S
10 10
d t = S
S
8 8
10 10
T
F
t ---------------10
a t
t LW
10 9
10 9
9
9
0 F n t
T
F
t ---------------10
a t
8
8
t = F n t
T 10 9
T
F
F
F
9 8
-------------- = -------------- + LW 1 S
t + 1 ------------------------8
8
10
a t + 1
a t
a t
8
d t = S
S
10 6
t = S
10 10
d t = S
S
5 5
8 8
T
F
t -------------8
a t
t LW
10 6
10 6
6
6
0 F n t
T
F
t ---------------10
a t
5
5
t = F n t
T 10 6
T
T 10 6
T
F
F
F
F
6 5
6 5
- + LW 0 S
-------------- = -------------- + LW 1 S t + 1 ------------------------ t ---------------10
10
5
5
a t
a t
a t + 1
a t
5
d t = S
14-39
5 5
T
F
t -------------5
a t
14
14 Dynamic Networks
10 4
t = S
10 9
5 4
t = S
5 5
4 4
t LW
t LW
9 4
5 4
4
4
0 F n t
4
4
0 F n t
4
4
t = F n t
T
T
T
T
F
F
F
F
F
4 4
4 4
5 4
10 4
- + S t + 1 ----------------------- + S t + 1 -------------------------------------- = -------------- + LW 1 S t + 1 ----------------------4
5
10
4
4
a t + 1
a t + 1
a t + 1
a t
a t
4
d t = S
4 4
T
T
T
F
F
F
5 4
10 4
- + S t -------------- + S
t ------------- t ---------------4
5
10
a t
a t
a t
10 7
t = S
10 4
8 7
t = S
8 8
t LW
8 7
7
7
0 F n t
5 7
t = S
5 4
t LW
4 7
7
7
0 F n t
4 7
t = S
4 4
t LW
4 7
7
7
0 F n t
d t = S
10 7
t LW
4 7
7
7
0 F n t
T
T
T
T
F
F
F
F
8 7
5 7
4 7
- + S t -------------- + S t -------------- + S t ------------- t ---------------10
8
5
4
a t
a t
a t
a t
3 3
3
3
t = F n t
T
T
T
T
F
F
F
F
F
4 3
4 4
5 4
10 4
- + S t + 1 ----------------------- + S t + 1 -------------------------------------- = -------------- + LW 1 S t + 1 ----------------------4
5
10
3
3
a t
a t
a t + 1
a t + 1
a t + 1
3
d t = S
S
10 2
t = S
10 6
t LW
6 2
3 3
T
F
t -------------3
a t
2
2
2
10 7
7 2
2
0 F n t + S
t LW 0 F n t
8 2
t = S
8 7
t LW
7 2
2
2
0 F n t
5 2
t = S
5 7
t LW
7 2
2
2
0 F n t
4 2
t = S
4 7
t LW
7 2
2
2
0 F n t
3 2
t = S
3 3
t LW
3 2
2
2
0 F n t
14-40
Solved Problems
2 2
2
2
t = F n t
T
T
T
F
F
F
F
2 2
2 2
3 2
- + S t + 1 ------------------------------------ = -------------- + LW 1 S t + 1 ----------------------2
2
2
3
a t + 1
a t + 1
a t
a t
+S
4 2
T
T
F
F
5 2
- + S t + 1 ---------------------- t + 1 ----------------------4
5
a t + 1
a t + 1
+S
8 2
T
T
F
F
10 2
-+S
t + 1 ---------------------- t + 1 ------------------------8
10
a t + 1
a t + 1
d t = S
+ S
10 2
4 2
T
T
T
F
F
F
8 2
5 2
- + S t -------------- + S t ------------- t ---------------10
8
5
a t
a t
a t
T
T
T
F
F
F
3 2
2 2
- + S t -------------- + S t ------------- t -------------4
3
2
a t
a t
a t
10 1
t = S
10 2
8 1
t = S
8 2
t LW
2 1
1
1
0 F n t
5 1
t = S
5 2
t LW
2 1
1
1
0 F n t
4 1
t = S
4 2
t LW
2 1
1
1
0 F n t
3 1
t = S
3 2
t LW
2 1
1
1
0 F n t
2 1
t = S
2 2
t LW
2 1
1
1
0 F n t
d t = S
+ S
10 1
4 1
t LW
2 1
1
1
0 F n t
T
T
T
F
F
F
8 1
5 1
- + S t -------------- + S t ------------- t ---------------10
8
5
a t
a t
a t
T
T
T
F
F
F
3 1
2 1
- + S t -------------- + S t ------------- t -------------4
3
2
a t
a t
a t
After the preceding steps have been repeated for all time points, from the
last time point back to the first, then the gradient can be computed as follows:
F
--------------------------- =
m l
LW d
14-41
d
t=1
t a t d
14
14 Dynamic Networks
F
------------------------- =
m l
IW d
t p t d
t=1
F
--------m- =
b
t=1
P14.3 Write out the RTRL equations for the network presented in Problem P14.1.
As in the previous problem, we will demonstrate the process for one time
step, since each step is similar. We will proceed through the layers accordu m
ing to the backpropagation order. The sensitivity matrices S t are computed in the same way for the RTRL algorithm as for the BPTT algorithm,
so we wont repeat those steps from Problem P14.2.
The explicit derivative calculations for the input weight will be
e u
T
a t
1
u 1
------------------------------------------T = p t S t
1 1
vec IW 0
For the layer weights and the biases, the explicit derivatives are calculated
by
e u
T
a t
l
u m
-------------------------------------------T- = a t d S t
m l
vec LW d
e u
a t
u m
----------------T- = S t
m
b
For the total derivatives, we have
2
e 2
e 3
a t 1
a t
a t
2 2
2 2
-------------- = ---------------- + S t LW 1 ----------------------T
T
T
x
x
x
a t
a t
a t 1
3 2
2 2
-------------- = ---------------- + S t LW 1 ----------------------T
T
T
x
x
x
14-42
Solved Problems
e 4
a t
a t
a t 1
a t 1
4 4
4 4
4 3
- + LW 1 ------------------------------------ = ---------------- + S t LW 1 ----------------------T
T
T
T
x
x
x
x
+S
4 2
t LW
2 2
a t 1
1 ----------------------T
x
e 5
a t
a t
a t 1
a t 1
5 4
4 4
4 3
-------------- = ---------------- + S t LW 1 ----------------------- + LW 1 ----------------------T
T
T
T
x
x
x
x
+S
5 2
t LW
2 2
a t 1
1 ----------------------T
x
e 8
a t 1
a t
a t
8 2
2 2
-------------- = ---------------- + S t LW 1 ----------------------T
T
T
x
x
x
10
e 10
a t
a t
a t 1
10 9
9 8
---------------- = ------------------ + S t LW 1 ----------------------T
T
T
x
x
x
5
+S
10 6
t LW
6 5
a t
a t 1
6 5
- + LW 1 ---------------------- 0 -------------T
T
x
x
+S
10 4
t LW
4 4
a t 1
a t 1
a t 1
4 3
10 2
2 2
- + LW 1 ----------------------- +S
1 ---------------------- t LW 1 ----------------------T
T
T
x
x
x
After the above steps are iterated through all time points, we can compute
the gradient with
F
-------T- =
x
t=1
F
-------------2
a t
e
F
+ -------------5
a t
a t
F
-------------- + -------------T
3
x
a t
5
a t
F
- + ------------- -------------T
8
x
a t
a t
F
-------------- + -------------T
4
x
a t
8
a t
F
- + --------------- -------------T
10
x
a t
a t
-------------T
x
10
a t
---------------T
x
P14.4 From the previous problem, show the detail of the calculations involved in the explicit derivative term
e 2
T
a t
1
2 1
------------------------------------------T = p t S t
1 1
vec IW 0
14-43
14
14 Dynamic Networks
First, lets display the details of the individual vectors and matrices in this
expression:
IW
1 1
1 1
1 1
1 1
1 1
1 1
1 1
iw 1 1 iw 1 2 iw 1 3
0 =
iw 2 1 iw 2 2 iw 2 3
vec IW
1 1
0 = iw 1 1 iw 1 1 iw 1 1 iw 1 1 iw 1 1 iw 1 1
1 1
2 1
1 2
2 2
1 3
2 3
2 1
p1
p t = p2 S
2 1
p3
2 1
s 1 1 s 1 2
e 2
a t
t = -----------------T- = s 2 1 s 2 1
2 1 2 2
1
n t
2 1 2 1
s 3 1 s 3 2
a 1
a 1
1 1
a 1
1 1
a 1
1 1
a 1
1 1
a 1
1 1
1 1
iw 1 1 iw 2 1 iw 1 2 iw 2 2 iw 1 3 iw 2 3
e 2
a t
a 2
a 2
a 2
a 2
a 2
a 2
------------------------------------------T =
1 1
1 1
1 1
1 1
1 1
1 1
1 1
vec IW 0
iw 1 1 iw 2 1 iw 1 2 iw 2 2 iw 1 3 iw 2 3
2
a 3
a 3
a 3
a 3
a 3
a 3
1 1
1 1
1 1
1 1
1 1
1 1
iw 1 1 iw 2 1 iw 1 2 iw 2 2 iw 1 3 iw 2 3
The Kronecker product is defined as
AB =
a 1 1 B a 1 m B
a n 1 B a n m B
therefore
2 1
p t S
2 1
2 1
2 1
2 1
2 1
2 1
p 1 s 1 1 p 1 s 1 2 p 2 s 1 1 p 2 s 1 2 p 3 s 1 1 p 3 s 1 2
t = p s 2 1 p s 2 1 p s 2 1 p s 2 1 p s 2 1 p s 2 1 .
1 2 1 1 2 2 2 2 1 2 2 2 3 2 1 3 2 2
2 1
2 1
2 1
2 1
2 1
2 1
p 1 s 3 1 p 1 s 3 2 p 2 s 3 1 p 2 s 3 2 p 3 s 3 1 p 3 s 3 2
14-44
Solved Problems
P14.5 Find the computational complexity for the BPTT and RTRL algorithms applied to the sample network in Figure P14.3 as a function
1
of the number of neurons in Layer 1 ( S ), the number of delays in
the tapped delay line ( D ) and the length of the training sequence
( Q ).
14
D
R
t a t d ,
t=1
1 2
e 2
a t
a t
2 1
-------------- = ---------------- + S t
T
T
x
x
LW
d=1
1 1
a t d
d ----------------------T
x
1
14-45
14 Dynamic Networks
Epilogue
14-46
Further Reading
Further Reading
[DeHa07]
[MaNe99]
J.R. Magnus and H. Neudecker, Matrix Differential Calculus, John Wiley & Sons, Ltd., Chichester, 1999.
This textbook provides a very clear and complete description of matrix theory and matrix differential calculus.
[PhHa13]
M. Phan and M. Hagan, Error Surface of Recurrent Networks, IEEE Transactions on Neural Networks and
Learning Systems, Vol. 24, No. 11, pp. 1709 - 1721, October,
2013.
This paper describes spurious valleys that appear in the error surfaces of recurrent networks. It also describes some
procedures that can be used to improve training of recurrent networks.
[Werb90]
[WiZi89]
R. J. Williams and D. Zipser, A learning algorithm for continually running fully recurrent neural networks, Neural
Computation, vol. 1, pp. 270280, 1989.
This paper introduced the real-time, recurrent learning algorithm for computing the gradients of dynamic networks.
Using this method, the gradients are computed by starting
at the first time point, and then working forward through
time. The algorithm is suitable for on-line, or real-time, implementation.
14-47
14
14 Dynamic Networks
Exercises
E14.1 Put the network of Figure 14.1 into the schematic form, which we introduced in Problem P14.1.
E14.2 Consider the network in Figure 14.4, with weight values iw 1 1 = 2 and
lw 1 1 1 = 0.5 . If a 0 = 4 , and p 1 = 2 , p 2 = 3 , p 3 = 2 , find a 1 ,
a2 , a3 .
1
2
3
1
3
2
2
14-48
Exercises
E14.7 Write out the equations of operation for the network in Figure E14.3. Assume that all weights have a value of 0.5, and that all biases have a value
of 0.
i. Assume that the initial network output is a 0 = 0.5 , and that the
initial network input is p 1 = 1 . Solve for a 1 .
ii. Describe any problems that you would have in simulating this network. Will you be able to apply the BPTT and RTRL algorithms to
compute the gradients for this network? What test should you apply
to recurrent networks to determine if they can be simulated and
trained?
1
1
1
1
1
3
1
2
14-49
14
14 Dynamic Networks
1
i.
D
ii.
1
3
4
3
1
3
2
1
u x
iv. Write out Eq. (14.63) specifically for the term F a t and Eq.
3
T
(14.34) specifically for the term a t x . (Expand the summation
to show exactly which terms are included.)
14-50
Exercises
E14.11 Repeat E14.10 for the following networks, except, in part iv., change a to
the indicated layer.
i.
14
,a .
1
1
ii.
,a .
1
3
2
1
iii.
3
4
14-51
,a .
14 Dynamic Networks
iv.
,a .
D
1
v.
3
1
,a .
E14.12 One of the advantages of the RTRL algorithm is that the gradient can be
computed at the same time as the network response, since it is computed
by starting at the first time point, and then working forward through time.
Therefore, RTRL allows a convenient framework for on-line implementation. Suppose that you are implementing the RTRL algorithm, and you update the weights of the network at each time step.
i. Discuss the accuracy of the gradient calculation if the weights are
updated at each time step of a steepest descent algorithm.
2+2
ans =
4
ii. Implement the RTRL algorithm in MATLAB for the network in Figure 14.4. Generate training data by using the network with the two
weights set equal to 0.5. Use the same input sequence shown in Figure 14.10, and use the network responses a t as the targets. Using
this data set, train the network using the steepest descent algorithm, with a learning rate of = 0.1 . Set the initial weights to zero. Update the weights at each time step. Save the gradient at the
end of the eighth time step.
14-52
Exercises
iii. Repeat part ii., but do not update the weights. Compute the gradient at the end of the eighth time step. Compare this gradient with
the one you obtained in part ii. Explain any differences
E14.13 Consider again the recurrent network of Figure 14.4. Assume that F x is
the sum squared error for the first two time points.
i. Let a 0 = 0 . Find a 1 and a 2 as a functions of p 1 , p 2 , and
the weights in the network.
ii. Find the sum squared error for the first two time steps as an explicit
function of p 1 , p 2 , t 1 , t 2 , and the network weights.
F
iii. Using part (ii), find ----------------------- .
lw 1 1 1
iv. Compare the results of part (iii) with the results determined by
RTRL on page 14-22 and by BPTT on page 14-30.
E14.14 In the process of deriving the RTRL algorithm in Exercise E14.5, you
should have produced the following expression
e 3
T
a t
1
3 2
-------------------------------------------T- = a t 1 S t
2 1
vec LW 1
If
1 and S 3 2 2 = 2 3 ,
1
4 5
e 3
e 3
a1 2
a 2
-.
Find -------------------------------------------T- and indicate --------------------------------------T
2 1
2 1
vec LW 1
vec lw 1 2 1
1
a 1 =
E14.15 Each layer of a standard LDDN network has a summing junction, which
combines contributions from inputs, other layers, and the bias, as in Eq.
(14.1), which is repeated here:
m
n t =
LW
m l
d a t d +
l L m d DL m l
IW
m l
d p t d + b .
l I m d DI m l
If, instead of summing, the net input was computed as a product of the contributions, how would the RTRL and BPTT algorithms change?
E14.16 As discussed in Exercise E14.15, the contribution to the net input from other layers is computed as product of a layer matrix with a layer output, as in
LW
14-53
m l
d a t d .
14
14 Dynamic Networks
If, instead of multiplying the layer matrix times the layer output, we were
to compute the distance between each row of the weight matrix and the layer output, as in
n i = iw a .
How would the RTRL and BPTT algorithms change?
E14.17 Find and compare the computational complexity for the BPTT and RTRL
algorithms applied to the sample network in Figure E14.6 as a function of
2
the number of neurons in Layer 2 ( S ), the number of delays in the tapped
delay line ( D ) and the length of the training sequence ( Q ).
1
3
2
S
14-54
Objectives
15
Associative Learning
Objectives
15-1
15-2
15-3
15-5
15-7
15-9
Instar Rule
15-11
Kohonen Rule
15-15
15-16
Outstar Rule
15-17
Summary of Results
15-21
Solved Problems
15-23
Epilogue
15-34
Further Reading
15-35
Exercises
15-37
Objectives
The neural networks we have discussed so far (in Chapters 4, 7, 1014)
have all been trained in a supervised manner. Each network required a target signal to define correct network behavior.
In contrast, this chapter introduces a collection of simple rules that allow
unsupervised learning. These rules give networks the ability to learn associations between patterns that occur together frequently. Once learned, associations allow networks to perform useful tasks such as pattern
recognition and recall.
Despite the simplicity of the rules in this chapter, they will form the foundation for powerful networks in Chapters 16, 18, 19.
15-1
15
15 Associative Learning
Stimulus
Response
associative learning as a primary component. Chapter 16 will describe Kohonen networks, and Chapters 18 and 19 will discuss Grossberg networks.
Inputs
p
15
b = -0.5
1
a = hardlim (wp + b)
Figure 15.1 Single-Input Hard Limit Associator
The neurons output a is determined from its input p according to
a = hardlim wp + b = hardlim wp 0.5 .
(15.1)
1 response
a =
0 no response
(15.2)
The presence of an association between the stimulus p = 1, and the response a = 1 is dictated by the value of w . The network will respond to the
stimulus only if w is greater than b (in this case 0.5).
The learning rules discussed in this chapter are normally used in the
framework of a larger network, such as the competitive networks of Chapters 16, 18 and 19. In order to demonstrate the operation of the associative
learning rules, without using complex networks, we will use simple networks that have two types of inputs.
Unconditioned Stimulus
Conditioned Stimulus
One set of inputs will represent the unconditioned stimulus. This is analogous to the food presented to the dog in Pavlovs experiment. Another set
of inputs will represent the conditioned stimulus. This is analogous to the
bell in Pavlovs experiment. Initially the dog salivates only when food is
15-3
15 Associative Learning
Figure 15.2 shows a network for recognizing bananas. The network has
both an unconditioned stimulus (banana shape) and a conditioned stimulus
(banana smell). We dont mean to imply here that smell is more conditionable than sight. In our examples in this chapter the choices of conditioned
and unconditioned stimuli are arbitrary and are used simply to demonstrate the performance of the learning rules. We will use this network to
demonstrate the operation of the Hebb rule in the following section.
w0 = 1
a Banana?
w = 0 b = -0.5
Smell of banana p
1
a = hardlim (w0p0 + w p + b)
Figure 15.2 Banana Associator
The definitions of the unconditioned and conditioned inputs for this network are
Fruit
Shape
Smell
Network
Banana?
1 shape detected
0
p =
0 shape not detected
1 smell detected
.
p =
0 smell not detected
(15.3)
At this time we would like the network to associate the shape of a banana,
but the not the smell, with a response indicating the fruit is a banana. The
0
problem is solved by assigning a value greater than b to w and assigning
a value less than b to w . The following values satisfy these requirements:
0
w = 1, w = 0.
The banana associators input/output function now simplifies to
15-4
(15.4)
a = hardlim p 0.5 .
(15.5)
0
Thus, the network will only respond if a banana is sighted ( p = 1 ), whether a banana is smelled ( p = 1 ) or not ( p = 0 ).
We will use this network in later sections to illustrate the performance of
several associative learning rules.
(15.6)
(See also Eq. (7.5).) The learning rate dictates how many times a stimulus and response must occur together before an association is made. In the
network in Figure 15.2, an association will be made when w b = 0.5 ,
since then p = 1 will produce the response a = 1 , regardless of the value
0
of p .
Local Learning
Note that Eq. (15.6) uses only signals available within the layer containing
the weights being updated. Rules that satisfy this condition are called local
learning rules. This is in contrast to the backpropagation rule, for example,
in which the sensitivity must be propagated back from the final layer. The
rules introduced in this chapter will all be local learning rules.
The unsupervised Hebb rule can also be written in vector form:
W q = W q 1 + a q p T q .
Training Sequence
(15.7)
As with all unsupervised rules, learning is performed in response to a series of inputs presented in time (the training sequence):
p 1 p 2 p Q .
15-5
(15.8)
15
15 Associative Learning
(Note that we are using the notation p q , instead of p q , in order to emphasize the time-sequence nature of the inputs.) At each iteration, the output
a is calculated in response to the input p , and then the weights W are updated with the Hebb rule.
2
+2
Lets apply the unsupervised Hebb rule to the banana associator. The associator will start with the weight values determined in our previous example, so that it will initially respond to the sight, but not the smell, of a
banana.
0
w = 1 w 0 = 0
(15.9)
p 1 = 0 p 1 = 1 p 2 = 1 p 2 = 1 .
(15.10)
The first weight w , representing the weight for the unconditioned stimu0
lus p , will remain constant, while w will be updated at each iteration, using the unsupervised Hebb rule with a learning rate of 1:
w q = w q 1 + a q p q .
(15.11)
a 1 = hardlim w p 1 + w 0 p 1 0.5
= hardlim 1 0 + 0 1 0.5 = 0 (no response) .
(15.12)
The smell alone did not generate a response. Without a response, the Hebb
rule does not alter w .
w 1 = w 0 + a 1 p 1 = 0 + 0 1 = 0
(15.13)
In the second iteration, both the bananas shape and smell are detected and
the network responds accordingly:
0 0
a 2 = hardlim w p 2 + w 1 p 2 0.5
= hardlim 1 1 + 0 1 0.5 = 1 (banana) .
(15.14)
Because the smell stimulus and the response have occurred simultaneously, the Hebb rule increases the weight between them.
w 2 = w 1 + a 2 p 2 = 0 + 1 1 = 1
(15.15)
When the sight detector fails again, in the third iteration, the network responds anyway. It has made a useful association between the smell of a banana and its response.
15-6
0 0
a 3 = hardlim w p 3 + w 2 p 3 0.5
= hardlim 1 0 + 1 1 0.5 = 1 (banana)
w 3 = w 2 + a 3 p 3 = 1 + 1 1 = 2
(15.16)
(15.17)
From now on, the network is capable of responding to bananas that are detected either by sight or smell. Even if both detection systems suffer intermittent faults, the network will be correct most of the time.
To experiment with the unsupervised Hebb rule, use the Neural Network Design Demonstration Unsupervised Hebb Rule (nnd13uh).
We have seen that the unsupervised Hebb rule can learn useful associations. However, the Hebb rule, as defined in Eq. (15.6), has some practical
shortcomings. The first problem becomes evident if we continue to present
inputs and update w in the example above. The weight w will become arbitrarily large. This is at odds with the biological systems that inspired the
Hebb rule. Synapses cannot grow without bound.
The second problem is that there is no mechanism for weights to decrease.
If the inputs or outputs of a Hebb network experience any noise, every
weight will grow (however slowly) until the network responds to any stimulus.
(15.18)
where , the decay rate, is a positive constant less than one. As approaches zero, the learning law becomes the standard rule. As approaches one,
the learning law quickly forgets old inputs and remembers only the most
recent patterns. This keeps the weight matrix from growing without
bound. (The idea of filtering the weight changes was also discussed in
Chapter 12, where we called it momentum.)
max
15-7
15
15 Associative Learning
w ij = 1 w ij + a i p j
w ij = 1 w ij +
(15.19)
w ij = --
2
+2
Lets examine the operation of the Hebb rule with decay on our previous banana associator problem. We will use a decay rate of 0.1. The first iteration, where only the smell stimulus is presented, is the same:
a1 = 0
(no response)
w 1 = 0 .
(15.20)
The next iteration also produces identical results. Here both stimuli are
presented, and the network responds to the shape. Coincidence of the smell
stimulus and response create a new association:
a2 = 1
(banana)
w2 = 1 .
(15.21)
The results of the third iteration are not the same. The network has
learned to respond to the smell, and the weight continues to increase. However, this time the weight increases by only 0.9, instead of 1.0.
w 3 = w 2 + a 3 p 3 0.1w 2 = 1 + 1 1 0.1 1 = 1.9
(15.22)
The decay term limits the weights value, so that no matter how often the
max
association is reinforced, w will never increase beyond w ij .
max
w ij
1
= --- = ------- = 10
0.1
(15.23)
The new rule also ensures that associations learned by the network will not
be artifacts of noise. Any small random increases will soon decay away.
Figure 15.3 displays the response of the Hebb rule, with and without decay,
for the banana recognition example. Without decay, the weight continues
to increase by the same amount each time the neuron is activated. When
decay is added, the weight exponentially approaches its maximum value
max
( w ij = 10 ).
To experiment with the Hebb rule with decay, use the Neural Network Design Demonstrations Hebb with Decay(nnd13hd) and Effect of Decay Rate
(nnd13edr).
15-8
30
10
20
6
w
4
Hebb Rule
10
0
0
10
20
30
0
0
10
20
30
Figure 15.3 Response of the Hebb Rule, With and Without Decay
The Hebb rule with decay does solve the problem of large weights. However, it does so at a price. The environment must be counted on to occasionally
present all stimuli that have associations. Without reinforcement, associations will decay away.
To illustrate this fact, consider Eq. (15.18) if a i = 0 :
w ij q = 1 w ij q 1 .
(15.24)
(15.25)
So far we have considered only associations between scalar inputs and outputs. We will now examine a neuron that has a vector input. (See Figure
15.4.) This neuron, which is sometimes referred to as an instar, is the simplest network that is capable of pattern recognition, as we will demonstrate
shortly.
15-9
15
15 Associative Learning
Inputs
w1,1
p1
w1,2
p2
w1,R
pR
1
a = hardlim (Wp + b)
Figure 15.4 Instar
You will notice the similarities between the instar of Figure 15.4 and the
perceptron of Figure 4.2 (also the ADALINE of Figure 10.2 and the linear
associator of Figure 7.1). We give these networks different names, in part
for historical reasons (since they arose at different times and out of different environments), and because they perform different functions and are
analyzed in different ways. For example, we will not directly consider the
decision boundary of the instar, although this was an important concept for
the perceptron. Instead, we will analyze the ability of the instar to recognize a pattern, as with the neurons in the first layer of the Hamming network. (See page 3-10.)
The input/output expression for the instar is
a = hardlim Wp + b = hardlim 1w T p + b .
(15.26)
The instar will be active whenever the inner product between the weight
vector (row of the weight matrix) and the input is greater than or equal to
b :
1w
Tp
b .
(15.27)
From our discussion of the Hamming network on page 3-10, we know that
for two vectors of constant length, the inner product will be largest when
they point in the same direction. We can also show this using Eq. (5.15):
1w
Tp
1w
p cos b ,
(15.28)
where is the angle between the two vectors. Clearly the inner product is
maximized when the angle is 0. If p and 1w have the same length
( p = 1w ), then the inner product will be largest when p = 1w .
Based on these arguments, the instar of Figure 15.4 will be active when p
is close to 1w . By setting the bias b appropriately, we can select how close
the input vector must be to the weight vector in order to activate the instar.
15-10
Instar Rule
If we set
b = 1w p ,
(15.29)
then the instar will only be active when p points in exactly the same direction as 1w ( = 0 ). Thus, we will have a neuron that recognizes only the
pattern 1w .
If we would like the instar to respond to any pattern near 1w ( small),
then we can increase b to some value larger than 1w p . The larger the
value of b , the more patterns there will be that can activate the instar, thus
making it the less discriminatory.
We should note that this analysis assumes that all input vectors have the
same length (norm). We will revisit the question of normalization in Chapters 16, 18 and 19.
We can now design a vector recognition network if we know which vector
we want to recognize. However, if the network is to learn a vector without
supervision, we need a new rule, since neither version of the Hebb rule produces normalized weights.
Instar Rule
One problem of the Hebb rule with decay was that it required stimuli to be
repeated or associations would be lost. A better rule might allow weight decay only when the instar is active ( a 0 ). Weight values would still be limited, but forgetting would be minimized. Consider again the original Hebb
rule:
w ij q = w ij q 1 + a i q p j q .
(15.30)
To get the benefits of weight decay, while limiting the forgetting problem,
a decay term can be added that is proportional to a i q :
w ij q = w ij q 1 + a i q p j q a i q w ij q 1
(15.31)
We can simplify Eq. (15.31) by setting equal to (so new weight values
are learned at the same rate old values decay) and gathering terms.
w ij q = w ij q 1 + a i q p j q w ij q 1
Instar Rule
(15.32)
This equation, called the instar rule, can also be rewritten in vector form:
iw q
= iw q 1 + a i q p q iw q 1 .
(15.33)
15-11
15
15 Associative Learning
iw q
= iw q 1 + p q iw q 1
= 1 iw q 1 + p q .
(15.34)
p(q)
w(q)
w(q - 1)
Lets apply the instar rule to the network in Figure 15.6. It has two inputs:
one indicating whether a fruit has been visually identified as an orange
(unconditioned stimulus) and another consisting of the three measurements taken of the fruit (conditioned stimulus).
The output of this network is
Fruit
Sight
0 0
a = hardlim w p + Wp + b .
Measure
Network
Orange?
(15.35)
15-12
shape
p = texture .
weight
(15.36)
Instar Rule
Inputs
Sight of orange p0
Measured shape p1
Measured texture p2
Measured weight p3
= 3 . (See Eq.
w0 = 3
w1,1
w1,3
a Orange?
b = -2
15
a = hardlim (w0 p0 + W p + b)
Figure 15.6 Orange Recognizer
We would like the network to have a constant association between the sight
0
of an orange and its response, so w will be set greater than b . But initially, the network should not respond to any combination of fruit measurements, so the measurement weights will start with values of 0.
T
w = 3 , W 0 = 1w 0 = 0 0 0
(15.37)
The measurement weights will be updated with the instar rule, using a
learning rate of = 1 .
1w q
= 1w q 1 + a q p q 1w q 1
(15.38)
1
1
0
0
p
=
0
=
1
1
1
1
1
(15.39)
Because W initially contains all zeros, the instar does not respond to the
measurements of an orange in the first iteration.
15-13
15 Associative Learning
0 0
a 1 = hardlim w p 1 + Wp 1 2
a 1 = hardlim 3 0 + 0 0 0 1 2 = 0
(15.40)
(no response)
Since the neuron did not respond, its weights 1w are not altered by the instar rule.
1w 1
= 1w 0 + a 1 p 1 1w 0
(15.41)
1
0
0
0
= 0 + 0 1 0 = 0
0
0
0
1
However, the neuron does respond when the orange is identified visually,
in addition to being measured, in the second iteration.
0 0
a 2 = hardlim w p 2 + Wp 2 2
= hardlim 3 1 + 0 0 0 1 2 = 1
(15.42)
(orange)
The result is that the neuron learns to associate the oranges measurement
vector with its response. The weight vector 1w becomes a copy of the orange
measurement vector.
1w 2
= 1w 1 + a 2 p 2 1w 1
1
0
0
= 0 + 1 1 0
0
0
1
(15.43)
= 1
The network can now recognize the orange by its measurements. The neuron responds in the third iteration, even though the visual detection system
failed again.
15-14
Instar Rule
0 0
a 3 = hardlim w p 3 + Wp 3 2
a 3 = hardlim 3 0 + 1 1 1 1 2 = 1
(15.44)
(orange)
= 1w 2 + a 3 p 3 1w 2
1
1
1
= 1 + 1 1 1
1
1
1
(15.45)
15
= 1
Kohonen Rule
Kohonen Rule
= iw q 1 + p q iw q 1
for i X q .
(15.46)
Like the instar rule, the Kohonen rule allows the weights of a neuron to
learn an input vector and is therefore suitable for recognition applications.
Unlike the instar rule, learning is not proportional to the neurons output
a i q . Instead, learning occurs when the neurons index i is a member of
the set X q .
If the instar rule is applied to a layer of neurons whose transfer function
only returns values of 0 or 1 (such as hardlim), then the Kohonen rule can
be made equivalent to the instar rule by defining X q as the set of all i
such that a i q = 1 . The advantage of the Kohonen rule is that it can also
be used with other definitions. It is useful for training networks such as the
self-organizing feature map, which will be introduced in Chapter 16.
15-15
15 Associative Learning
We have seen that the instar network (with a vector input and a scalar output) can perform pattern recognition by associating a particular vector
stimulus with a response. The outstar network, shown in Figure 15.7, has
a scalar input and a vector output. It can perform pattern recall by associating a stimulus with a vector response.
The input-output expression for this network is
a = satlins Wp .
(15.47)
The symmetric saturating function satlins was chosen because this network will be used to recall a vector containing values of -1 or 1.
Input
Symmetric Saturating
Linear Layer
w1,1
w2,1
wS,1
n1
a1
n2
a2
nS
aS
a = satlins (Wp)
Figure 15.7 Outstar Network
If we would like the network to associate a stimulus (an input of 1) with a
particular output vector a , we can simply set W (which contains only a
single column vector) equal to a . Then, if p is 1, the output will be a :
a = satlins Wp = satlins a 1 = a .
(15.48)
(This assumes that the elements of a are less than or equal to 1 in magnitude.)
Note that we have created a recall network by setting a column of the
weight matrix to the desired vector. Earlier we designed a recognition network by setting a row of the weight matrix to the desired vector.
We can now design a network that can recall a known vector a , but we
need a learning rule if the network is to learn a vector without supervision.
We will describe such a learning rule in the next section.
15-16
Outstar Rule
Outstar Rule
To derive the instar rule, forgetting was limited by making the weight decay term of the Hebb rule proportional to the output of the network, a i .
Conversely, to obtain the outstar learning rule, we make the weight decay
term proportional to the input of the network, p j :
w ij q = w ij q 1 + a i q p j q p j q w ij q 1 .
(15.49)
If we set the decay rate equal to the learning rate and collect terms,
we get
w ij q = w ij q 1 + a i q w ij q 1 p j q .
(15.50)
The outstar rule has properties complimentary to the instar rule. Learning
occurs whenever p j is nonzero (instead of a i ). When learning occurs, column w j moves toward the output vector.
Outstar Rule
As with the instar rule, the outstar rule can be written in vector form
w j q = w j q 1 + a q w j q 1 p j q ,
(15.51)
To test the outstar rule we will train the network shown in Figure 15.8.
Inputs
w1,10 = 1
w =1
0
2
Measured weight p
0
2,2
0
3
0
=1
w3,3
Symmetric Saturating
Linear Layer
n1
n2
w1,1
Identified Pineapple p
w3,1
n3
a1 Recalled shape
a2 Recalled texture
a3 Recalled weight
15-17
15
15 Associative Learning
a = satlins W p + Wp ,
(15.52)
1 0 0
0
W = 0 1 0 .
0 0 1
(15.53)
where
Fruit
Sight
Measure
Network
Measurements?
1
p =
0
(15.54)
The weight matrix for the unconditioned stimulus, W , is set to the identi0
ty matrix, so that any set of measurements p (with 1 values) will be copied to the output a . The weight matrix for the conditioned stimulus, W , is
set to zero initially, so that a 1 on p will not generate a response. W will
be updated with the outstar rule using a learning rate of 1:
w j q = w j q 1 + a q w j q 1 p q .
(15.55)
pineapple
1
= 1 .
1
(15.56)
0
1
0
0
p 1 = 0 p 1 = 1 p 2 = 1 p 2 = 1
0
1
15-18
(15.57)
Outstar Rule
In the first iteration, the pineapple is seen, but the measurements are unavailable.
0 0
a 1 = satlins W p 1 + Wp 1 ,
0
0
a 1 = satlins 0 + 0
0
0
1 = 0
(15.58)
(no response)
(15.59)
The network sees the pineapple but cannot output proper measurements,
because it has not learned them and the measurement system is not working. The weights remain unchanged after being updated.
0 0
0
w 1 1 = w 1 0 + a 1 w 1 0 p 1 = 0 + 0 0
0 0
0
1 = 0
(15.60)
In the second iteration the pineapple is seen, and the measurements are
taken properly.
1
0
1
a 2 = satlins 1 + 0 1 = 1
0
1
1
(measurements given)
(15.61)
0 1
0
1 = 1 .
(15.62)
Since the sight of the pineapple and the measurements were both available, the network forms an association between them. The weight matrix
is now a copy of the measurements, so they can be recalled later.
15-19
15
15 Associative Learning
In iteration three, measurements are unavailable once again, but the output is
0
1
a 3 = satlins 0 + 1
1
0
1 = 1
(measurements recalled) .
(15.63)
The network is now able to recall the measurements of the pineapple when
it sees it, even though the measurement system fails. From now on, the
weights will no longer change values unless a pineapple is seen with different measurements.
w 1 3 = w 1 2 + a 2 w 1 2 p 2
1 1
1
1
= 1 + 1 1 1 = 1
1
1
1
1
(15.64)
To experiment with the outstar rule with decay, use the Neural Network Design Demonstration Outstar Rule (nnd13os).
In Chapter 19 we will investigate the ART networks, which use both the
instar and the outstar rules.
15-20
Summary of Results
Summary of Results
Association
An association is a link between the inputs and outputs of a network so
that when a stimulus A is presented to the network, it will output a response B.
Instar
Inputs
w1,1
p1
w1,2
p2
w1,R
pR
1
a = hardlim (Wp + b)
a = hardlim 1w T p + b
The instar is activated for 1w T p =
1w
p cos b ,
Instar Rule
iw q
iw q
= iw q 1 + a i q p q iw q 1
= 1 w q 1 + p q
15-21
if a i q = 1
15
15 Associative Learning
p(q)
w(q)
w(q - 1)
Kohonen Rule
iw q
= iw q 1 + p q iw q 1
for i X q
Outstar
Input
Symmetric Saturating
Linear Layer
w1,1
w2,1
wS,1
n1
a1
n2
a2
nS
aS
a = satlins (Wp)
Outstar Rule
w j q = w j q 1 + a q w j q 1 p j q
15-22
Solved Problems
Solved Problems
P15.1 In Eq. (15.19) the maximum weight for the Hebb rule with decay
was calculated, assuming that p j and a i were 1 at every time step.
Calculate the maximum weight resulting if p j and a i alternate together between values of 0 and 1.
We begin with the scalar version of the Hebb rule with decay:
w ij q = 1 w ij q 1 + a i q p j q .
We can rewrite this expression twice using q to index the weight values as
the weight is updated over two time steps.
w ij q + 1 = 1 w ij q + a i q p j q
w ij q + 2 = 1 w ij q + 1 + a i q + 1 p j q + 1
By substituting the first equation into the second, we get a single expression showing how w ij is updated over two time steps.
w ij q + 2 = 1 1 w ij q + a i q p j q + a i q + 1 p j q + 1
At this point we can substitute values for p j and a i . Because we are looking
for a maximum weight, we will set p j q and a i q to 0, and p j q + 1 and
a i q + 1 to 1. This will mean that the weight decreases in the first time
step, and increases in the second, ensuring that w ij q + 2 is the maximum
of the two weights. If we solve for w ij q + 2 , we obtain
2
w ij q + 2 = 1 w ij q + .
Assuming that w ij will eventually reach a steady state value, we can find
max
it by setting both w ij q + 2 and w ij q equal to w ij and solving
max
w ij
max
w ij
2+2
ans =
4
max
= 1 w ij
+,
= ---------------2- .
2
We can use MATLAB to make a plot of this relationship. The plot will show
learning rates and decay rates at intervals of 0.025.
lr = 0:0.025:1;
dr = 0.025:0.025:1;
Here are the commands for creating a mesh plot of the maximum weight,
as a function of the learning and decay rate values.
15-23
15
15 Associative Learning
[LR,DR] = meshgrid(dr,lr);
MW = LR ./ (DR .* (2 - DR));
mesh(DR,LR,MW);
max
The plot shows that w ij approaches infinity as the decay rate becomes
small with respect to the learning rate (see Figure P15.1).
Maximum weight
20
15
10
0
0
0.2
0.4
0.6
0.8
1
Decay Rate
0.2
0.4
0.6
0.8
Learning Rate
max
P15.2 Retrain the orange recognition network on page 13-13 using the instar rule with a learning rate of 0.4. Use the same training sequence. How many time steps are required for the network to
learn to recognize an orange by its measurements?
Here is the training sequence. It is to be repeated until the network can reT
spond to the orange measurements ( p = 1 1 1 ), even when the visual
0
detection system fails ( p = 0 ).
1
1
0
0
p 1 = 0 p 1 = 1 p 2 = 1 p 2 = 1
1
1
2+2
ans =
4
We will use MATLAB to make the calculations. These two lines of code set
the weights to their initial values.
w0 = 3;
W = [0 0 0];
15-24
Solved Problems
The neuron does not yet recognize the orange, so its output is 0. The
weights do not change when updated with the instar rule.
W = W + 0.4*a*(p-W)
W =
0 0 0
But the association is still not strong enough for a response in the third iteration.
p0 = 0;
p = [1; -1; -1];
a = hardlim(w0*p0+W*p-2)
a =
0
W = W + 0.4*a*(p-W)
W =
0.4000 -0.4000 -0.4000
15-25
15
15 Associative Learning
a =
0
W =
0.6400 -0.6400 -0.6400
By the seventh iteration the network is able to recognize the orange by its
measurements alone.
p0 = 0;
p = [1; -1; -1];
a = hardlim(w0*p0+W*p-2)
a =
1
W = W + 0.4*a*(p-W)
W =
0.8704 -0.8704 -0.8704
Due to the lower learning rate, the network had to experience the measurements paired with its response three times (the even numbered iterations)
before it developed a strong association between them.
P15.3 Both the recognition and recall networks used in this chapters examples could only learn a single vector. Draw the diagram and determine the parameters of a network capable of recognizing and
responding to the following two vectors:
5
p1 = 5
5
p2 =
5
5 .
5
The network should only respond when an input vector is identical to one of these vectors.
We know the network must have three inputs, because it must recognize
three-element vectors. We also know that it will have two outputs, one output for each response.
Such a network can be obtained by combining two instars into a single layer, as in Figure P15.2.
15-26
Solved Problems
Inputs
w1,1
p1
n1
a1
n2
a2
b1
p2
1
p3
w2,3
b2
15
1
a = hardlim (Wp + b)
Figure P15.2 Two-Vector Recognition Network
We now set the weights 1w of the first neuron equal to p 1 , so that its net
input will be at a maximum when an input vector points in the same direction as p 1 . Likewise, we will set 2w to p 2 so that the second neuron is most
sensitive to vectors in the direction of p 2 .
Combining the weight vectors gives us the weight matrix
W =
1w
2w
p1
=
T
5 5 5 .
5 5 5
T
p2
(Note that this is the same manner in which we determined the weight matrix for the first layer of the Hamming network. In fact, the first layer of
the Hamming network is a layer of instars. More about that in the next
chapter.)
The lengths of p 1 and p 2 are the same:
p1 = p2 =
5 + 5 + 5 =
75 .
To ensure that only an exact match between an input vector and a stored
vector results in a response, both biases are set as follows (Eq. (15.29)):
b1 = b2 = p1
2+2
ans =
4
= 75 .
We can use MATLAB to test that the network does indeed respond to p 1 .
W = [5 -5 5; -5 5 5];
b = [-75; -75];
15-27
15 Associative Learning
The first neuron responded, indicating that the input vector was p 1 . The
second neuron did not respond, because the input was not p 2 .
We can also check that the network does not respond to a third vector p 3
that is not equal to either of the stored vectors.
p3 = [-5; 5; -5];
a = hardlim(W*p3+b)
a =
0
0
b = 2 .
W = 1w = 1 1 1
a = hardlim 1w p + b
According to the definition of hardlim , a will be 1 if and only if the inner
T
product between 1w and p is greater than or equal to b (Eq. (15.28)):
1w
Tp
1w
p cos b .
We can find the maximum angle between 1w and p that meets this condition by substituting for the norms and solving
3 3 cos 2
1 2
cos --- = 48.19 .
3
15-28
Solved Problems
p1 =
1w
p1 + p2 + p3 =
3,
p = w1 p1 + w2 p2 + w3 p3 b = p1 p2 p3 2 = 0 .
Since we have three variables and only two constraints, we can set the
third variable p 1 to 0 and solve
2
p1 + p2 + p3 =
p1 p2 p3 2
2
p2 + p3 = 3 ,
p2 + p3 = 2 ,
2
p 2 + p 3 = p 2 + p 3 + 2p 2 p 3 = 2 = 4 ,
3 + 2p 2 p 3 = 4
2
p 2 p 3 = 0.5 ,
p 2 p 2 + p 3 = p 2 + p 2 p 3 = p 2 + 0.5 = p 2 2 = 2p 2 .
After a little work we find that there are two possible values for p 2 :
2
p 2 + 2p 2 + 0.5 = 0 ,
p 2 = 1 0.5 .
It turns out that if we pick p 2 to be one of these values, then p 3 will take
on the other value.
p 2 + p 3 = 1 0.5 + p 3 = 2
p3 = 1
0.5
Therefore, the following vector p is just the right distance from w to be recognized.
0
p = 1 + 0.5
1 0.5
We can test it by presenting it to the network.
15-29
15
15 Associative Learning
a = hardlim 1w p + b
a = hardlim 1 1 1 1 + 0.5 2
1 0.5
a = hardlim 0 = 1
The vector p does indeed result in a net input of 0 and is therefore on the
boundary of the instars active region.
P15.5 Consider the instar network shown in Figure P15.3. The training
sequence for this network will consist of the following inputs:
0
1 p 0 2 = 1 p 2 = 1 .
p 1 = 0 p 1 =
1
1
Inputs
p0
p1
p2
w0 = 3
w1,1
w1,2
b = -2
a = hardlim (w0 p0 + W p + b)
Figure P15.3 Instar Network for Problem P15.5
i. Because W initially contains all zeros, the instar does not respond to
the measurements in the first iteration.
15-30
Solved Problems
0 0
a 1 = hardlim w p 1 + Wp 1 2
a 1 = hardlim 3 0 + 0 0 1 2 = 0
1
The neuron did not respond. Therefore its weights 1w are not altered by the
instar rule.
1w 1
= 1w 0 + 0.5a 1 p 1 1w 0
= 0 + 0 1 0 = 0
1
0
0
0
a 2 = hardlim w p 2 + Wp 2 2
a 2 = hardlim 3 1 + 0 0 1 2 = 1
1
The neuron did respond, and its weights 1w are updated by the instar rule.
1w 2
= 1w 1 + 0.5a 2 p 2 1w 1
= 0 + 0.5 1 0 = 0.5
1
0
0
0.5
a 3 = hardlim w p 3 + Wp 3 2
1
Since the neuron did not respond, its weights are not updated.
15-31
15
15 Associative Learning
1w 3
= 1w 2 + 0.5a 3 p 3 1w 2
a 4 = hardlim w p 4 + Wp 4 2
1
Since the instar was activated, its weights are updated.
1w 4
= 1w 3 + 0.5a 4 p 4 1w 3
= 1w q 1 + p q 1w q 1 = 1 1w q 1 + p q .
When the instar is active, the weight vector is moved toward the input vector along a line between the old weight vector and the input vector. Figure
P15.4 displays the movement of the weight vector for this problem. The
weights were updated on iterations 2 and 4. Because = 0.5 , whenever
the instar is active the weight vector moves halfway from its current position toward the input vector.
1w q
15-32
= 0.5 1w q 1 + 0.5 p q
Solved Problems
p
1
w(4)
1
w(2)
w(0)
15
15-33
15 Associative Learning
Epilogue
In this chapter we introduced some simple networks capable of forming
associations. We also developed and studied several learning rules that
allowed networks to create new associations. Each rule operated by
strengthening an association between any stimulus and response that
occurred simultaneously.
The simple associative networks and learning rules developed in this chapter are useful in themselves, but they are also important building blocks for
more powerful networks. In this chapter we introduced two networks, and
associated learning rules, that will be fundamental for the development of
important networks in the next three chapters: the instar and the outstar.
The instar is a network that is trained to recognize a pattern. The outstar
is a network that is trained to recall a pattern. We will use layers of instars
in Chapters 16 and 18 to perform pattern recognition. These networks are
very similar to the Hamming network of Chapter 3, whose first layer was,
in fact, a layer of instars. In Chapter 19 we will introduce a more complex
network, which combines both instars and outstars in order to produce stable learning.
15-34
Further Reading
Further Reading
[Ande72]
J. Anderson, A simple neural network generating an interactive memory, Mathematical Biosciences, vol. 14, pp.
197220, 1972.
Anderson has proposed a linear associator model for associative memory. The model was trained, using a generalization of the Hebb postulate, to learn an association
between input and output vectors. The physiological plausibility of the network was emphasized. Kohonen published
a closely related paper at the same time [Koho72], although
the two researchers were working independently.
[Gros68]
S. Grossberg, Some physiological and biochemical consequences of psychological postulates, Proceedings of the National Academy of Sciences, vol. 60, pp. 758765, 1968.
This article describes early mathematical models (nonlinear differential equations) of associative learning. It synthesizes psychological, mathematical and physiological
ideas.
[Gros82]
[Hebb49]
[Koho72]
T. Kohonen, Correlation matrix memories, IEEE Transactions on Computers, vol. 21, pp. 353359, 1972.
Kohonen proposed a correlation matrix model for associative memory. The model was trained, using the outer product rule (also known as the Hebb rule), to learn an
association between input and output vectors. The mathematical structure of the network was emphasized. Anderson published a closely related paper at the same time
[Ande72], although the two researchers were working independently.
15-35
15
15 Associative Learning
[Koho87]
[Leib90]
15-36
Exercises
Exercises
E15.1 The network shown in Figure E15.1 is to be trained using the Hebb rule
with decay, using a learning rate of 0.3 and a decay rate of 0.1.
Inputs
p0
w0 = 1
w
b = -0.8
15
1
a = hardlim (w0p0 + wp + b)
Figure E15.1 Associative Network
0
i. If w is initially set to 0, and w and b remain constant (with the values shown in Figure E15.1), how many consecutive presentations of
the following training set are required before the neuron will respond to the test set? Make a plot of w versus iteration number.
0
Training set: p = 1 p = 1
Test set: p = 0 p = 1
ii. Assume that w has an initial value of 1. How many consecutive presentations of the following training set are required before the neuron will no longer be able to respond to the test set? Make a plot of
w versus iteration number.
0
Training set: p = 0 p = 0
Test set: p = 0 p = 1
E15.2 For Exercise E15.1 part (i), use Eq. (15.19) to determine the steady state
value of w . Verify that this answer agrees with your plot from Exercise
E15.1 part (i).
E15.3 Repeat Exercise E15.1, but this time use the Hebb rule without decay
( = 0 ).
E15.4 The following rule looks similar to the instar rule, but it behaves quite differently:
old
w ij = a i p j + w ij
15-37
15 Associative Learning
Inputs
p0
p1
p2
w0 = 1
w1,1
w1,2
b = -0.5
1
a = hardlim (w0p0 + Wp + b)
2+2
ans =
4
i. Train the network with the instar rule on the following training sequence. Apply the instar rule to the second inputs weights only
(which should be initialized to zeros), using a learning rate of 0.6.
The other weight and the bias are to remain constant at the values
in the figure. (You may wish to use MATLAB to perform the calculations.)
0
0.174 p 0 2 = 0 p 2 = 0.174
p 1 = 1 p 1 =
0.985
0.985
0
0.174 p 0 4 = 0 p 4 = 0.174
p 3 = 1 p 3 =
0.985
0.985
0
0.174 p 0 6 = 0 p 6 = 0.174
p 5 = 1 p 5 =
0.985
0.985
15-38
Exercises
iv. What magnitude would you expect the weights to have after training, if the network were trained for many more iterations of the
same training sequence?
E15.6 Consider the instar network shown in Figure E15.3. The training sequence
for this network will consist of the following inputs:
0
1
p 1 = 0 p 1 =
1
0
1
p 2 = 1 p 2 =
1
These two sets of inputs are repeatedly presented to the network until the
weight matrix W converges.
i. Perform the first eight iterations of the instar rule, with learning
rate = 0.25 . Assume that the initial W matrix is set to
W = 1 0 .
ii. Display the results of each iteration of the instar rule in graphical
form (as in Figure 15.5).
Inputs
p0
p1
p2
w0 = 3
w1,1
w1,2
b = -2
a = hardlim (w0 p0 + W p + b)
Figure E15.3 Instar Network for Exercise E15.6
E15.7 Draw a diagram of a network capable of recognizing three different fourelement vectors (of 1 values) when given different stimuli (of value 1).
i. How many inputs does your network have? How many outputs?
What transfer function did you use?
ii. Choose values for the networks weights so that it can recognize
each of the following vectors:
15-39
15
15 Associative Learning
1
p1 = 1
1
1
1
p2 = 1
1
1
1
p3 = 1
1
1
iii. Choose an appropriate value for the biases. Explain your choice.
iv. Test the network with one of the vectors above. Was its response
correct?
v. Test the network with the following vector.
1
p1 = 1
1
1
Why did it respond the way it did?
E15.8 This chapter included an example of a recognition network that initially
used a visual system to identify oranges. At first the network needed the
visual system to tell it when an orange was present, but eventually it
learned to recognize oranges from sensor measurements.
i. Let us replace the visual system with a person. Initially, the network would depend on a person to tell it when an orange was
present. Would you consider the network to be learning in a supervised or unsupervised manner?
ii. In what ways would the input from a person resemble the targets
used to train supervised networks in earlier chapters?
iii. In what ways would it differ?
Scan
Push
1 2
3 4
15-40
Exercises
Input
p0
Floor Code
2x1
2
Retinal Scan
p
3x1
3
1
W0
2x2
Floor?
2x1
2x1
2x3
b
2x1
a = hardlims (W0 p0 + W p + b)
Figure E15.4 Elevator Network
Push Scan
1 2
3 4
0 0
a = hardlims W p + Wp + b .
0
The first input p provides the network with a floor code, if a button has
been pushed.
Network
0
p 1 = 1 (1st floor)
1
p2 =
1 (2nd floor)
1
Floor?
0
p 3 = 1 (3rd floor)
1
0
p 4 = 1 (4th floor)
1
The first input is weighted with an identity matrix, and the biases are set
to -0.5, so that if a button is pushed the network will respond with its code.
0
W = I , b = 0.5
0.5
The second input is always available. It consists of three elements that represent the three executives:
15-41
15
15 Associative Learning
1
p 1 = 0 (President) ,
0
0
0
p 2 = 1 (Vice-President) , p 3 = 0 (Chairman) .
0
1
The network learns to recall the executives favorite floors by updating the
second set of weights using the outstar rule (using a learning rate of 0.6).
Initially those weights are set to zero:
W = 0 0 0 .
0 0 0
2+2
ans =
4
p = p 4 p = p 1 , p = p 3 p = p 2 , p = p 1 p = p 3 ,
p = p 3 p = p 2 , p = p 2 p = p 3 , p = p 4 p = p 1 .
ii. What are the final weights?
iii. Now continue simulating the network on these events:
President does not push a button,
Vice-President does not push a button,
Chairman does not push a button.
iv. Which floors did the network take each executive to?
v. If the executives were to push the following buttons many times,
what would you expect the resulting weight matrix to look like?
President pushes 3,
Vice-President pushes 2,
Chairman pushes 4.
15-42
Objectives
16
Competitive Networks
Objectives
16-1
16-2
Hamming Network
16-3
Layer 1
16-3
Layer 2
16-4
Competitive Layer
16-5
Competitive Learning
Problems with Competitive Layers
16-7
16-9
16-10
16-12
16-15
16-16
LVQ Learning
16-18
16-21
Summary of Results
16-22
Solved Problems
16-24
Epilogue
16-37
Further Reading
16-38
Exercises
16-39
Objectives
The Hamming network, introduced in Chapter 3, demonstrated one technique for using a neural network for pattern recognition. It required that
the prototype patterns be known beforehand and incorporated into the network as rows of a weight matrix.
In this chapter we will discuss networks that are very similar in structure
and operation to the Hamming network. Unlike the Hamming network,
however, they use the associative learning rules of Chapter 15 to adaptively learn to classify patterns. Three such networks are introduced in this
chapter: the competitive network, the feature map and the learning vector
quantization (LVQ) network.
16-1
16
16 Competitive Networks
16-2
Hamming Network
works, and yet they are mathematically more tractable than the Grossberg
networks. They provide a good introduction to competitive learning.
We will begin with the simple competitive network. Next we will present
the self-organizing feature map, which incorporates a network topology. Finally, we will discuss learning vector quantization, which incorporates
competition within a supervised learning framework.
Hamming Network
Since the competitive networks discussed in this chapter are closely related
to the Hamming network (shown in Figure 16.1), it is worth reviewing the
key concepts of that network first.
Feedforward Layer
p
Rx1
1
R
W1
SxR
n1
a1
Sx1
Sx1
Sx1
Recurrent Layer
n2(t + 1)
W2
SxS
Sx1
- Exp 1(W
- 1 p + b 1)
a1 = purelin
a2(t + 1)
Sx1
a2(t)
Sx1
S
a2(0) = a1
Layer 1
Recall from Chapter 15 (see page 15-9 and following) that a single instar is
able to recognize only one pattern. In order to allow multiple patterns to be
classified, we need to have multiple instars. This is accomplished in the
Hamming network.
Suppose that we want the network to recognize the following prototype vectors:
p 1 p 2 p Q .
16-3
(16.1)
16
16 Competitive Networks
Then the weight matrix, W 1 , and the bias vector, b 1 , for Layer 1 will be:
2w
p 1T
=
Sw
p 2T
R
, b1 = R ,
p QT
(16.2)
W1 =
1w
where each row of W 1 represents a prototype vector which we want to recognize, and each element of b 1 is set equal to the number of elements in
each input vector ( R ). (The number of neurons, S , is equal to the number
of prototype vectors which are to be recognized, Q .)
Thus, the output of the first layer is
p 1T p + R
p 2T p + R
a = W1p + b1 =
(16.3)
p QT p + R
Note that the outputs of Layer 1 are equal to the inner products of the prototype vectors with the input, plus R . As we discussed in Chapter 3 (page
3-9), these inner products indicate how close each of the prototype patterns
is to the input vector. (This was also discussed in our presentation of the
instar on page 15-10.)
Layer 2
In the instar of Chapter 15, a hardlim transfer function was used to decide
if the input vector was close enough to the prototype vector. In Layer 2 of
the Hamming network we have multiple instars, therefore we want to decide which prototype vector is closest to the input. Instead of the hardlim
transfer function, we will use a competitive layer to choose the closest prototype.
Layer 2 is a competitive layer. The neurons in this layer are initialized with
the outputs of the feedforward layer, which indicate the correlation between the prototype patterns and the input vector. Then the neurons compete with each other to determine a winner. After the competition, only one
neuron will have a nonzero output. The winning neuron indicates which
category of input was presented to the network (each prototype vector represents a category).
1
a 0 = a
16-4
(16.4)
Competitive Layer
Then the second-layer output is updated according to the following recurrence relation:
2
a t + 1 = poslin W 2 a t .
(16.5)
The second-layer weights W 2 are set so that the diagonal elements are 1,
and the off-diagonal elements have a small negative value.
1
2
w ij = 1 if i = j
, where 0 -----------S
1
otherwise
Lateral Inhibition
(16.6)
This matrix produces lateral inhibition, in which the output of each neuron
has an inhibitory effect on all of the other neurons. To illustrate this effect,
substitute weight values of 1 and for the appropriate elements of W 2 ,
and rewrite Eq. (16.5) for a single neuron.
2
2
2
a i t + 1 = poslin a i t a j t
(16.7)
ji
This is called a winner-take-all competition, since only one neuron will have
a nonzero output. In Chapter 18 we will discuss other types of competition.
You may wish to experiment with the Hamming network and the apple/orange classification problem. The Neural Network Design Demonstration
Hamming Classification (nnd3hamc) was previously introduced in Chapter 3.
Competitive Layer
Competition
The second-layer neurons in the Hamming network are said to be in competition because each neuron excites itself and inhibits all the other neurons. To simplify our discussions in the remainder of this chapter, we will
define a transfer function that does the job of a recurrent competitive layer:
a = compet n .
(16.8)
It works by finding the index i of the neuron with the largest net input,
and setting its output to 1 (with ties going to the neuron with the lowest
index). All other outputs are set to 0.
16-5
16
16 Competitive Networks
1 i = i
ai =
, where n i n i i , and i i n i = n i
0 i i
(16.9)
p
Rx1
W
SxR
n
Sx1
a
Sx1
S
a = compet (Wp)
Sw
p =
Tp
2w
Tp
L cos 1
Sw
= L cos 2 .
Tp
(16.10)
2w
1w
n = Wp =
1w
L cos S
(16.11)
To experiment with the competitive network and the apple/orange classification problem, use the Neural Network Design Demonstration Competitive
Classification (nnd14cc).
16-6
Competitive Layer
Competitive Learning
We can now design a competitive network classifier by setting the rows of
W to the desired prototype vectors. However, we would like to have a
learning rule that could be used to train the weights in a competitive network, without knowing the prototype vectors. One such learning rule is the
instar rule from Chapter 15:
iw q
= iw q 1 + a i q p q iw q 1 .
(16.12)
For the competitive network, a is only nonzero for the winning neuron
( i = i ). Therefore, we can get the same results using the Kohonen rule.
iw q
= iw q 1 + p q iw q 1
= 1 iw q 1 + p q
(16.13)
and
iw q
i i
= iw q 1
(16.14)
Thus, the row of the weight matrix that is closest to the input vector (or has
the largest inner product with the input vector) moves toward the input
vector. It moves along a line between the old row of the weight matrix and
the input vector, as shown in Figure 16.3.
p(q)
w(q)
w(q - 1)
Lets use the six vectors in Figure 16.4 to demonstrate how a competitive
layer learns to classify vectors. Here are the six vectors:
p 1 = 0.1961 p 2 = 0.1961 p 3 = 0.9806
0.9806
0.9806
0.1961
p4 =
16-7
(16.15)
16
16 Competitive Networks
1w
p1 p2
2w
p3
3w
p4
p6
2w
3w
(16.16)
The data vectors are shown at left, with the weight vectors displayed as arrows. Lets present the vector p 2 to the network:
0.7071 0.7071
0.1961
a = compet Wp 2 = compet 0.7071 0.7071
0.9806
1.0000 0.0000
1w
p5
1w
0.5547
= compet 0.8321
0.1961
(16.17)
= 1 .
The second neurons weight vector was closest to p 2 , so it won the competition ( i = 2 ) and output a 1. We now apply the Kohonen learning rule to
the winning neuron with a learning rate of = 0.5.
2w
p1 p2
2w
p3
3w
p4
p6
p5
1w
new
= 2w
old
+ p 2 2w
old
(16.18)
Competitive Layer
p3
p4
p6
p5
2w
3w
Once the network has learned to cluster the input vectors, it will classify
new vectors accordingly.The diagram in the left margin uses shading to
show which region each neuron will respond to. The competitive layer assigns each input vector p to one of these classes by producing an output of
1 for the neuron whose weight vector is closest to p .
To experiment with the competitive learning use the Neural Network Design
Demonstration Competitive Learning (nnd14cl).
slow
0
unstable
fast
16-9
16
16 Competitive Networks
vade the territory of another weight vector, and therefore upset the current classification scheme.
The series of four diagrams in Figure 16.6 illustrate this problem. Two input vectors (shown with blue circles in diagram (a)) are presented several
times. The result is that the weight vectors representing the middle and
right clusters shift to the right. Eventually one of the right cluster vectors
is reclassified by the center weight vector. Further presentations move the
middle vector over to the right until it loses some of its vectors, which
then become part of the class associated with the left weight vector.
(a)
(b)
(c)
(d)
Often weights vary as a function of the distance between the neurons they
connect. For example, the weights for Layer 2 of the Hamming network are
assigned as follows:
1 if i = j
.
w ij =
if i j
(16.19)
Eq. (16.20) assigns the same values as Eq. (16.19), but in terms of the distances d ij between neurons:
neuron j
-e
-e
-e
-e
-e
-e
-e
-e
-e
-e
-e
-e
+1
-e
-e
-e
-e
-e
-e
-e
-e
-e
-e
-e
-e
On-center/off-surround
1 if d ij = 0
.
w ij =
if d ij 0
(16.20)
Either Eq. (16.19) or Eq. (16.20) will assign the weight values shown in the
diagram at left. Each neuron i is labeled with the value of the weight w ij ,
which comes from it to the neuron marked j .
The term on-center/off-surround is often used to describe such a connection
pattern between neurons. Each neuron reinforces itself (center), while inhibiting all other neurons (surround).
It turns out that this is a crude approximation of biological competitive layers. In biology, a neuron reinforces not only itself, but also those neurons
close to it. Typically, the transition from reinforcement to inhibition occurs
smoothly as the distance between neurons increases.
Mexican-Hat Function
This transition is illustrated on the left side of Figure 16.7. This is a function that relates the distance between neurons to the weight connecting
them. Those neurons that are close provide excitatory (reinforcing) connections, and the magnitude of the excitation decreases as the distance increases. Beyond a certain distance, the neurons begin to have inhibitory
connections, and the inhibition increases as the distance increases. Because of its shape, the function is referred to as the Mexican-hat function.
On the right side of Figure 16.7 is a two-dimensional illustration of the
Mexican-hat (on-center/off-surround) function. Each neuron i is marked to
show the sign and relative strength of its weight w ij going to neuron j .
wij
dij
neuron j
16
16 Competitive Networks
SOFM
In order to emulate the activity bubbles of biological systems, without having to implement the nonlinear on-center/off-surround feedback connections, Kohonen designed the following simplification. His self-organizing
feature map (SOFM) network first determines the winning neuron i using the same procedure as the competitive layer. Next, the weight vectors
for all neurons within a certain neighborhood of the winning neuron are updated using the Kohonen rule,
iw q
= iw q 1 + p q iw q 1
= 1 iw q 1 + p q
Neighborhood
i N i d ,
(16.21)
where the neighborhood N i d contains the indices for all of the neurons
that lie within a radius d of the winning neuron i :
N i d = j d ij d .
(16.22)
When a vector p is presented, the weights of the winning neuron and its
neighbors will move toward p . The result is that, after many presentations, neighboring neurons will have learned vectors similar to each other.
2
+2
(16.23)
N 13 2 = 3 7 8 9 11 12 13 14 15 17 18 19 23 .
(16.24)
16-12
10
10
11
12
13
14
15
11
12
13
14
15
16
17
18
19
20
16
17
18
19
20
21
22
23
24
25
21
22
23
24
25
N13(1)
N13(2)
Input
Feature Map
p
3x1
W
25 x 3
n
25 x 1
Feature Map
a
25 x 1
25
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
a = compet (Wp)
1
0.8
0.6
0.4
The diagram in the left margin shows the initial weight vectors for the feature map. Each three-element weight vector is represented by a dot on the
sphere. (The weights are normalized, therefore they will fall on the surface
of a sphere.) Dots of neighboring neurons are connected by lines so you can
see how the physical topology of the network is arranged in the input space.
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
-1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
16-13
16
16 Competitive Networks
The diagram to the left shows a square region on the surface of the sphere.
We will randomly pick vectors in this region and present them to the feature map.
1
0.8
0.6
0.4
Each time a vector is presented, the neuron with the closest weight vector
will win the competition. The winning neuron and its neighbors move their
weight vectors closer to the input vector (and therefore to each other). For
this example we are using a neighborhood with a radius of 1.
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
-1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
The weight vectors have two tendencies: first, they spread out over the input space as more vectors are presented; second, they move toward the
weight vectors of neighboring neurons. These two tendencies work together
to rearrange the neurons in the layer so that they evenly classify the input
space.
The series of diagrams in Figure 16.10 shows how the weights of the twenty-five neurons spread out over the active input space and organize themselves to match its topology.
1
0.8
0.8
0.8
0.8
0.6
0.6
0.6
0.6
0.4
0.4
0.4
0.4
0.2
0.2
0.2
0.2
-0.2
-0.2
-0.2
-0.2
-0.4
-0.4
-0.4
-0.4
-0.6
-0.6
-0.6
-0.6
-0.8
-0.8
-0.8
-1
-1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
-1
-1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
-1
-1
-0.8
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
-1
-1
0.8
0.8
0.8
0.8
0.6
0.6
0.6
0.6
0.4
0.4
0.4
0.4
0.2
0.2
0.2
0.2
-0.2
-0.2
-0.2
-0.2
-0.4
-0.4
-0.4
-0.4
-0.6
-0.6
-0.6
-0.6
-0.8
-0.8
-0.8
-1
-1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
-1
-1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
-1
-1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
-0.8
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
-1
-1
16-14
0.8
0.8
0.8
0.8
0.6
0.6
0.6
0.6
0.4
0.4
0.4
0.4
0.2
0.2
0.2
0.2
-0.2
-0.2
-0.2
-0.2
-0.4
-0.4
-0.4
-0.4
-0.6
-0.6
-0.6
-0.6
-0.8
-0.8
-0.8
-1
-1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
-1
-1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
-0.8
-1
-1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
-1
-1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
0.8
0.8
0.6
0.6
0.4
0.4
0.2
0.2
-0.2
-0.2
-0.4
-0.4
-0.6
-0.6
-0.8
-1
-1
16
-0.8
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
-1
-1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
16-15
16 Competitive Networks
(We discussed the use of this technique for competitive layers earlier in the
chapter.)
Another alteration that speeds self-organization is to have the winning
neuron use a larger learning rate than the neighboring neurons.
Finally, both competitive layers and feature maps often use an alternative
expression for net input. Instead of using the inner product, they can directly compute the distance between the input vector and the prototype
vectors. The advantage of using the distance is that input vectors do not
need to be normalized. This alternative net input expression is introduced
in the next section on LVQ networks.
Other enhancements to the SOFM are described in Chapter 26, including
a batch version of the SOFM learning rule. That chapter is a case study of
using the SOFM for clustering.
To experiment with feature maps use the Neural Network Design Demonstrations 1-D Feature Maps (nnd14fm1) and 2-D Feature Maps (nnd14fm2).
Inputs
Linear Layer
Competitive Layer
W1
1
S xR
p
Rx1
n1
||dist||
S1x1
a1
1
S x1
S x1
n2
2
2
S x1
S2xS1
S
1
S
a2 = W2a1
n i = ||iw -p||
1
a = compet(n )
Figure 16.13 LVQ Network
16-16
As with the competitive network, each neuron in the first layer of the LVQ
network learns a prototype vector, which allows it to classify a region of the
input space. However, instead of computing the proximity of the input and
weight vectors by using the inner product, we will simulate the LVQ networks by calculating the distance directly. One advantage of calculating
the distance directly is that vectors need not be normalized. When the vectors are normalized, the response of the network will be the same, whether
the inner product is used or the distance is directly calculated.
The net input of the first layer of the LVQ will be
1
n i = iw p ,
(16.25)
2w
16
n =
1w
w p
(16.26)
a = compet n .
(16.27)
Therefore the neuron whose weight vector is closest to the input vector will
output a 1, and the other neurons will output 0.
Subclass
Thus far, the LVQ network behaves exactly like the competitive network
(at least for normalized vectors). There is a difference in interpretation,
however. In the competitive network, the neuron with the nonzero output
indicates which class the input vector belongs to. For the LVQ network, the
winning neuron indicates a subclass, rather than a class. There may be several different neurons (subclasses) that make up each class.
The second layer of the LVQ network is used to combine subclasses into a
2
2
single class. This is done with the W matrix. The columns of W repre2
sent subclasses, and the rows represent classes. W has a single 1 in each
column, with the other elements set to zero. The row in which the 1 occurs
indicates which class the appropriate subclass belongs to.
2
(16.28)
The process of combining subclasses to form a class allows the LVQ network to create complex class boundaries. A standard competitive layer has
16-17
16 Competitive Networks
the limitation that it can only create decision regions that are convex. The
LVQ network overcomes this limitation.
LVQ Learning
The learning in the LVQ network combines competitive learning with supervision. As with all supervised learning algorithms, it requires a set of
examples of proper network behavior:
p 1 t 1 p 2 t 2 p Q t Q .
Each target vector must contain only zeros, except for a single 1. The row
in which the 1 appears indicates the class to which the input vector belongs. For example, if we have a problem where we would like to classify a
particular three-element vector into the second of four classes, we can express this as
p1 =
0
12
1 .
0 t1 =
0
12
0
(16.29)
Before learning can occur, each neuron in the first layer is assigned to an
2
output neuron. This generates the matrix W . Typically, equal numbers of
hidden neurons are connected to each output neuron, so that each class can
2
be made up of the same number of convex regions. All elements of W are
set to zero, except for the following:
2
(16.30)
q =
w q 1 + p q iw q 1 , if a k = t k = 1
16-18
(16.31)
Second, if p was classified incorrectly, then we know that the wrong hidden
1
neuron won the competition, and therefore we move its weights iw away
from p .
i
w q =
w
i
q 1 p q iw q 1 , if a k = 1 t k = 0
(16.32)
The result will be that each hidden neuron moves toward vectors that fall
into the class for which it forms a subclass and away from vectors that fall
into other classes.
2
+2
class 1: p 1 = 1 p 2 = 1 , class 2: p 3 = 1 p 4 = 1 ,
1
1
1
1
Class 1
p4
p2
p1
(16.33)
p3
Class 2
1 t = 1 , p = 1 t = 1 ,
p1 =
2
1
2
1
0
1
0
(16.34)
1 t = 0 , p = 1 t = 0 .
p3 =
4
3
4
1
1
1
1
(16.35)
We now must choose how many subclasses will make up each of the two
classes. If we let each class be the union of two subclasses, we will end up
with four neurons in the hidden layer. The output layer weight matrix will
be
2
W = 1 1 0 0 .
0 0 1 1
(16.36)
1w
4w
p2
3w
2w
p1
The row vectors in W are initially set to random values. They can be seen
in the diagram at left. The weights belonging to the two hidden neurons
that define class 1 are marked with hollow circles. The weights defining
class 2 are marked with solid circles. The values for these weights are
p3
1w
1
1
1
= 0.543 , 2w = 0.969 , 3w = 0.997 , 4w = 0.456 .
0.840
0.249
0.094
0.954
16-19
(16.37)
16
16 Competitive Networks
1
1
a = compet n = compet
1
1w p 3
1
2w p 3
1
3w p 3
1
4w p 3
T
T
0.543 0.840 1 1
T
T
0.969 0.249 1 1
= compet
T
T
0.997 0.094 1 1
0.456 0.954 T 1 1 T
(16.38)
2.40
2.11
= compet
1.09
2.03
= 0
The third hidden neuron has the closest weight vector to p 3 . In order to de1
2
termine which class this neuron belongs to, we multiply a by W .
0
1
1
0
0
0 = 0
a = W a =
0 0 1 1 1
1
0
2
2 1
(16.39)
1 = 3w 0 + p 3 3w 0
(16.40)
The diagram on the left side of Figure 16.14 shows the weights after 3w
was updated on the first iteration. The diagram on the right side of Figure
16.14 shows the weights after the algorithm has converged.
16-20
The diagram on the right side of Figure 16.14 also indicates how the regions of the input space will be classified. The regions that will be classified
as class 1 are shown in gray, and the regions that will be classified as class
2 are shown in blue.
p4
1w
2w
p1
w1
4w
p3
1w
p4
p2
3w
p2
p1
p3
2
w1
w1
LVQ2
When the network correctly classifies an input vector, the weights of only
one neuron are moved toward the input vector. However, if the input vector
is incorrectly classified, the weights of two neurons are updated, one weight
vector is moved away from the input vector, and the other one is moved toward the input vector. The resulting algorithm is called LVQ2.
To experiment with LVQ networks use the Neural Network Design Demonstrations LVQ1 Networks (nnd14lv1) and LVQ2 Networks (nnd14lv2).
16-21
16
16 Competitive Networks
Summary of Results
Competitive Layer
Input Competitive Layer
Rx1
SxR
Sx1
Sx1
S
a = compet (Wp)
wq =
w q 1 + p q iw q 1 = 1 iw q 1 + p q
i
wq =
i i ,
wq 1
p(q)
w(q)
w(q - 1)
16-22
Summary of Results
Feature Map
3x1
25 x 3
Feature Map
25 x 1
a
25 x 1
25
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
a = compet (Wp)
= iw q 1 + p q iw q 1
16
i N i d
= 1 iw q 1 + p q
N i d = j d ij d
LVQ Network
Inputs
Linear Layer
Competitive Layer
1
1
S xR
||dist||
Rx1
S1x1
a1
1
S x1
S x1
S2x1
S2xS1
S1
R
1
S2
a2 = W2a1
n i = ||iw -p||
1
a = compet(n )
2
q =
q =
w q 1 + p q iw q 1 , if a k = t k = 1
w q 1 p q iw q 1 , if a k = 1 t k = 0
16-23
16 Competitive Networks
Solved Problems
P16.1 Figure P16.1 shows several clusters of normalized vectors.
class 1
class 2
class 4
class 3
p
Rx1
W
SxR
n
Sx1
a
Sx1
S
a = compet (Wp)
= 1 2 , 2w = 1 2 , 3w = 1 2
1 2
1 2
1 2
16-24
Solved Problems
The center of the fourth cluster appears to be about twice as far from the
vertical axis as it is from the horizontal axis. The resulting normalized
weight vector is
4w
= 2 5 .
1 5
The weight matrix W for the competitive layer is simply the matrix of the
transposed prototype vectors:
W =
1w
2w
3w
4w
1 2 1 2
=
1 2 1 2 .
1 2 1 2
2 5 1 5
We get Figure P16.3 by drawing these weight vectors with arrows and bisecting the circle between each adjacent weight vector to get the class regions.
class 1
class 4
class 2
class 3
0 , w = 2 5 , w = 1 5 .
2
3
1
1 5
2 5
16-25
16
16 Competitive Networks
Calculate the resulting weights found after training the competitive layer with the Kohonen rule and a learning rate of 0.5, on
the following series of inputs:
p1 , p2 , p3 , p1 , p2 , p3 .
3w
p2
p3
2w
p1
1w
Figure P16.4 Input Vectors and Initial Weights for Problem P16.2
First we combine the weight vectors into the weight matrix W .
0
1
W = 2 5 1 5
1 5 2 5
Then we present the first vector p 1 .
0
0
1
0
1
a = compet Wp 1 = compet 2 5 1 5
= compet 0.894 = 1
0
0
1 5 2 5
0.447
The second neuron responded, since 2w was closest to p 1 . Therefore, we
will update 2w with the Kohonen rule.
3w
p2
2w
p1
p3
2w
new
= 2w
old
+ p 1 2w
old
= 2 5 + 0.5 1 2 5 = 0.947
0
0.224
1 5
1 5
16-26
Solved Problems
1
0
1
0
a = compet Wp 2 = compet 0.947 0.224
= compet 0.224
1
1 5 2 5
0.894
= 0
new
= 3w
old
+ p 2 3w
old
= 1 5 + 0.5 0 1 5 = 0.224
1
0.947
2 5
2 5
We now present p 3 .
0
1
2
a = compet Wp 3 = compet 0.947 0.224
2
0.224 0.947
0.707
0
= compet 0.512 = 0
1
0.512
The third neuron wins again.
3w
new
= 3w
old
+ p 2 3w
old
After presenting p 1 through p 3 again, neuron 2 will again win once and
neuron 3 twice. The final weights are
p2
3w
p3
0
1
W = 0.974 0.118 .
0.414 0.8103
2w
p1
16-27
16
16 Competitive Networks
these vectors using the Kohonen rule with learning rate = 0.5 .
Find graphically the position of the weights after all of the input
vectors (in the order shown) have been presented once.
p4
w(0)
w(0)
p3
p1
p2
Figure P16.5 Input Vectors and Initial Weights for Problem P16.3
This problem can be solved graphically, without any computations. The results are displayed in Figure P16.6.
p4
w(0)
w(0)
w(4)
w(3)
w(1)
p3
p1
w(2)
p2
Figure P16.6 Solution for Problem P16.3
The input vector p 1 is presented first. The weight vector 1w is closest to
p 1 , therefore neuron 1 wins the competition and 1w is moved halfway to
16-28
Solved Problems
p 1 , since = 0.5 . Next, p 2 is presented, and again neuron 1 wins the competition and 1w is moved halfway to p 2 . During these first two iterations,
2w is not changed.
On the third iteration, p 3 is presented. This time 2w wins the competition
and is moved halfway to p 3 . On the fourth iteration, p 4 is presented, and
neuron 2 again wins. The weight vector 2w is moved halfway to p 4 .
If we continue to train the network, neuron 1 will classify the input vectors
p 1 and p 2 , and neuron 2 will classify the input vectors p 3 and p 4 . If the
input vectors were presented in a different order, would the final classification be different?
P16.4 So far in this chapter we have only talked about feature maps
whose neurons are arranged in two dimensions. The feature map
shown in Figure P16.7 contains nine neurons arranged in one dimension.
Inputs
Feature Map
Feature Map
16
1
2
3
p
3x1
n
W
9x1
a
9x1
9x3
4
5
6
7
8
9
a = compet(Wp)
Figure P16.7 Nine-Neuron Feature Map
Given the following initial weights, draw a diagram of the weight
vectors, with lines connecting weight vectors of neighboring neurons.
0.41 0.45 0.41 0 0 0 0.41 0.45 0.41
W = 0.41 0 0.41 0.45 0 0.45 0.41
0 0.41
0.82 0.89 0.82 0.89 1 0.89 0.82 0.89 0.82
Train the feature map for one iteration, on the vector below, using
a learning rate of 0.1 and a neighborhood of radius 1. Redraw the
diagram for the new weight matrix.
16-29
16 Competitive Networks
0.67
p = 0.07
0.74
The feature map diagram for the initial weights is given in Figure P16.8.
1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
-1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
a = compet Wp
0.41 0.45 0.41 0 0 0 0.41 0.45 0.41
0.67
0.07
0.74
= compet 0.91 0.96 0.85 0.70 0.74 0.63 0.36 0.36 0.3
= 0 1 0 0 0 0 0 0 0
The second neuron won the competition. Looking at the network diagram,
we see that the second neurons neighbors, at a radius of 1, include neurons
1 and 3. We must update each of these neurons weights with the Kohonen
rule.
16-30
Solved Problems
0.67
0.41
0.41
0.82
0.82
0.74
0.43
= 0.37
0.81
0.67
0.45
0.45
0 + 0.1 0.07 0
2w 1 = 2w 0 + p 2w 0 =
0.89
0.89
0.74
0.47
= 0.01
0.88
0.67
0.41
0.41
0.82
0.82
0.74
0.43
= 0.36
0.81
Figure P16.9 shows the feature map after the weights were updated.
1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
-1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8
16-31
0
1 0 0 0 0
1
2
1 ,W = 0 1 0 0 0
0 0 1 1 1
1
1
16
16 Competitive Networks
Inputs
Linear Layer
Competitive Layer
W1
5x2
p
2x1
n1
-||dist||
5x1
a1
5x1
3x1
3x1
3x5
5
1
n i = -||iw -p||
1
3
a2 = W2a1
a = compet(n )
Figure P16.10 LVQ Network for Problem P16.5
We create the diagram shown in Figure P16.11 by marking each vector iw
1
in W according to the index k of the corresponding nonzero element in the
2
ith column of W , which indicates the class.
16-32
Solved Problems
Inputs
Linear Layer
Competitive Layer
W1
9x2
p
2x1
n1
-||dist||
9x1
a1
9x1
3x1
n2
3x1
3x9
9
1
n i = -||iw -p||
1
3
a2 = W2a1
a = compet(n )
Figure P16.14 LVQ Network for Problem P16.6
16-33
16
16 Competitive Networks
We can now design the weight matrix W of the first layer by setting each
row equal to a transposed prototype vector for one cluster. Picking prototype vectors at the center of each cluster gives us the following values:
T
W = 1 0 1 1 0 1 1 0 1 .
1 1 1 0 0 0 1 1 1
1
Now each neuron in the first layer will respond to a different cluster.
2
1
1
a = compet n = compet
5
0
2
0
1
0
2
0
1 = 0 .
0
1
0
2
0
1
The network says that the vector we presented is in the sixth subclass.
Lets see what the second layer says.
16-34
Solved Problems
0
0
0
1 0 0 0 0 1 0 1 0 0
1
2
2 1
a = W a = 0 1 0 0 1 0 1 0 0 0 = 0
0 0 1 1 0 0 0 0 1 1
0
0
0
0
The second layer indicates that the vector is in class 1, as indeed it is. The
diagram of class regions and decision boundaries is shown in Figure
P16.15.
16
Figure P16.15 Class Regions and Decision Boundaries
P16.7 Competitive layers and feature maps require that input vectors be
normalized. But what if the available data is not normalized?
One way to handle such data is simply to normalize it before giving
it to the network. This has the disadvantage that the vector magnitude information, which may be important, is lost.
Another solution is to replace the inner product expression usually used to calculate net input,
a = compet Wp ,
with a direct calculation of distance,
n i = iw p and a = compet n ,
as is done with the LVQ network. This works and saves the magnitude information.
However, a third solution is to append a constant of 1 to each input
vector before normalizing it. Now the change in the added element
will preserve the vector magnitude information.
16-35
16 Competitive Networks
1
1
1
0
p'' 2 = 1
1
0
1
1
0
p'' 3 = 0
1
1 3
= 1 3
1 3
0
= 1 2
1 2
0
0
1
0
= 0
1
16-36
Epilogue
Epilogue
In this chapter we have demonstrated how the associative instar learning
rule of Chapter 15 can be combined with competitive networks, similar to
the Hamming network of Chapter 3, to produce powerful self-organizing
networks. By combining competition with the instar rule, each of the prototype vectors that are learned by the network become representative of a
particular class of input vector. Thus the competitive networks learn to divide their input space into distinct classes. Each class is represented by one
of the prototype vectors (rows of the weight matrix).
Three types of networks, all developed by Tuevo Kohonen, were discussed
in this chapter. The first is the standard competitive layer. Its simple operation makes it a practical network for many problems.
The self-organizing feature map is very similar to the competitive layer,
but more closely models biological on-center/off-surround networks. The result is a network that not only learns to classify input vectors, but also
learns the topology of the input space.
The third network, the LVQ network, uses both unsupervised and supervised learning to recognize clusters. It uses a second layer to combine multiple convex regions into classes that can have any shape. LVQ networks
can even be trained to recognize classes made up of multiple unconnected
regions.
Chapters 18 and 19 will build on the networks presented in this chapter.
For example, Chapter 18 will carry out a more detailed examination of lateral inhibition, on-center/off-surround networks and the biology that inspired them. In Chapter 19 we discuss a modification to the standard
competitive network (called adaptive resonance theory), which solves the
weight stability problem that we discussed in this chapter.
Chapter 22 presents practical tips for training competitive networks, and
Chapter 26 is a case study of using self organizing feature maps on a realworld clustering problem.
16-37
16
16 Competitive Networks
Further Reading
[FrSk91]
[Koho87]
[Hech90]
[RuMc86]
16-38
Exercises
Exercises
E16.1 Suppose that the weight matrix for layer 2 of the Hamming network is given by
3
1 --4
2
W = 3
--- 1
4
3 3
--- --4 4
3
--4
3
--- .
4
1
p4 p1
p2
3w
p3
2w
1w
16
16 Competitive Networks
1 , p = 1 , p = 1 .
2
3
1
1
1
i. Use the Kohonen learning law with = 0.5 , and train for one pass
through the input patterns. (Present each input once, in the order
given.) Display the results graphically. Assume the initial weight
matrix is
W =
2 0 .
0 2
ii. After one pass through the input patterns, how are the patterns
clustered? (In other words, which patterns are grouped together in
the same class?) Would this change if the input patterns were presented in a different order? Explain.
iii. Repeat part (i) using = 0.25 . How does this change affect the
training?
E16.4 Earlier in this chapter the term conscience was used to refer to a technique for avoiding the dead neuron problem plaguing competitive layers
and LVQ networks.
Neurons that are too far from input vectors to ever win the competition can
be given a chance by using adaptive biases that get more negative each
time a neuron wins the competition. The result is that neurons that win
very often start to feel guilty until other neurons have a chance to win.
Figure E16.2 shows a competitive network with biases. A typical learning
rule for the bias b i of neuron i is
new
bi
16-40
old
0.9b i , if i i
.
=
b old
0.2 , if i = i
i
Exercises
Input
Competitive Layer
p
2x1
3x2
1
2
3x1
b
3x1
3x1
a = compet (Wp + b)
Figure E16.2 Competitive Layer with Biases
i. Examine the vectors in Figure E16.3. Is there any order in which
the vectors can be presented that will cause 1w to win the competition and move closer to one of the vectors? (Note: assume that adaptive biases are not being used.)
3w
p2
p3
2w
p1
1w
0 , w = 2 5 , w = 1 5 , b 0 = b 0 = b 0 = 0
1
2
3
2
3
1
1 5
2 5
Sequence of input vectors: p 1 , p 2 , p 3 , p 1 , p 2 , p 3 ,
16-41
16
16 Competitive Networks
Inputs
Competitive Layer
W
2x2
-||dist||
2x1
n1
2x1
a1
2x1
2
1
n i = -||iw-p||
1
a = compet(n )
Figure E16.4 Competitive Layer with Alternate Net Input Expression
Use this technique to train a two-neuron competitive layer on the (nonnormalized) vectors below, using a learning rate, , of 0.5.
p1 = 1 , p2 = 1 , p3 = 2
1
2
2
Present the vectors in the following order:
p1 , p2 , p3 , p2 , p3 , p1 .
Here are the initial weights of the network:
1w
= 0 , 2w = 1 .
1
0
E16.6 Repeat E16.5 for the following inputs and initial weights. Show the movements of the weights graphically for each step. If the network is trained for
a large number of iterations, how will the three vectors be clustered in the
final configuration?
16-42
Exercises
p1 = 2 , p2 = 0 , p3 = 2
0
1
2
1w
= 1 , 2w = 1 .
0
0
E16.7 We have a competitive learning problem, where the input vectors are
p1 = 0 , p2 = 0 , p3 = 1 , p4 = 2 ,
1
2
1
2
and the initial weight matrix is
W =
1 1 .
1 1
16
16 Competitive Networks
Inputs
Feature Map
Feature Map
4x2
p
2x1
-||dist||
n
4x1
a
4x1
3
4
4
ni = -||iw-p||
a = compet(n)
16-44
Exercises
i. Plot the initial weight vectors as dots, and connect the neighboring
weight vectors as lines (as in Figure 16.10, except that this is a 1-D
feature map).
ii. The following input vector is applied to the network. Perform one iteration of the feature map learning rule. (You can do this graphically.) Use a neighborhood size of 1 and a learning rate of = 0.5 .
p1 = 2 0
iii. Plot the new weight vectors as dots, and connect the neighboring
weight vectors as lines.
E16.12 Consider the following feature map, where distance is used instead of inner
product to compute the net input.
Inputs
Feature Map
Feature Map
W
a
4x2
p
2x1
-||dist||
n
4x1
4x1
4
ni = -||iw - p||
a = compet(n)
ii. Apply the input p = 1 1 , and perform one iteration of the feature map learning rule, with learning rate of = 0.5 , and neighborhood radius of 1.
iii. Plot the weights after the first iteration, and show their topological
connections.
16-45
16
16 Competitive Networks
0
1 0 0 0 0
0
2
,
W
=
0 1 1 0 0 .
0
0 0 0 1 1
1
1
i. How many classes does this LVQ network have? How many subclasses?
ii. Draw a diagram showing the first-layer weight vectors and the decision boundaries that separate the input space into subclasses.
iii. Label each subclass region to indicate which class it belongs to.
E16.14 We would like an LVQ network that classifies the following vectors according to the classes indicated:
1
1
class 1: 1 1 , class 2:
1 1
1
1
1
1 1
1
1
1
, class 3:
1 1
1 1 .
1
1
i. How many neurons are required in each layer of the LVQ network?
ii. Define the weights for the first layer.
iii. Define the weights for the second layer.
iv. Test your network for at least one vector from each class.
E16.15 We would like an LVQ network that classifies the following vectors according to the classes indicated:
class 1: p 1 = 1 p 2 = 0 , class 2:
1
2
1 p = 1
p3 =
4
1
2
Exercises
iv. Initialize the first-layer weights of the network to all zeros and calculate the changes made to the weights by the Kohonen rule (with
a learning rate of 0.5) for the following series of vectors:
p4 , p2 , p3 , p1 , p2 .
v. Draw a diagram showing the input vectors, the final weight vectors
and the decision boundaries between the two classes.
E16.16 An LVQ network has the following weights and training data.
1 0
1
2
W = 0 1 ,W = 1 1 0 ,
0 0 1
0 0
2 t = 1 , p = 2 t = 0 , p = 2 t = 1 ,
p1 =
2
3
1
2
3
0
1
0
2
0
2
2 t = 0
p4 =
4
1
0
i. Plot the training data input vectors and weight vectors (as in Figure
16.14).
ii. Perform four iterations of the LVQ learning rule, with learning rate
= 0.5 , as you present the following sequence of input vectors: p 1 ,
p 2 , p 3 , p 4 (one iteration for each input). Do this graphically, on a
separate diagram from part i.
iii. After completing the iterations in part ii, on a new diagram, sketch
the regions of the input space that make up each subclass and each
class. Label each region to indicate which class it belongs to.
E16.17 An LVQ network has the following weights:
T
2
W = 0 1 1 0 0 1 1 , W = 1 0 1 0 1 1 0 .
0 0 0 1 1 1 1
0 1 0 1 0 0 1
1
i. How many classes does this LVQ network have? How many subclasses?
ii. Draw a diagram showing the first-layer weight vectors and the decision boundaries that separate the input space into subclasses.
iii. Label each subclass region to indicate which class it belongs to.
16-47
16
16 Competitive Networks
2
W = 0 0 2 1 1 1 , W = 1 1 1 0 0 0 .
0 2 2 1 1 1
0 0 0 1 1 1
1
i. How many classes does this LVQ network have? How many subclasses?
ii. Draw a diagram showing the first-layer weight vectors and the decision boundaries that separate the input space into subclasses.
iii. Label each subclass region to indicate which class it belongs to.
iv. Perform one iteration of the LVQ algorithm, with the following inT
T
put/target pair: p = 1 2 , t = 1 0 . Use learning rate
= 0.5 .
16-48
Objectives
17
17-1
17-2
17-2
Function Approximation
17-4
Pattern Classification
17-6
17-9
17-9
17-11
17-17
Clustering
17-22
Nonlinear Optimization
17-23
17-25
Summary of Results
17-26
Solved Problems
17-29
Epilogue
17-33
Further Reading
17-34
Exercises
17-36
Objectives
The multilayer networks discussed in Chapters 11 and 12 represent one
type of neural network structure for function approximation and pattern
recognition. As we saw in Chapter 11, multilayer networks with sigmoid
transfer functions in the hidden layers and linear transfer functions in the
output layer are universal function approximators. In this chapter we will
discuss another type of universal approximation network, the radial basis
function network. This network can be used for many of the same applications as multilayer networks.
This chapter will follow the structure of Chapter 11. We will begin by demonstrating, in an intuitive way, the universal approximation capabilities of
the radial basis function network. Then we will describe three different
techniques for training these networks. They can be trained by the same
gradient-based algorithms discussed in Chapters 11 and 12, with derivatives computed using a form of backpropagation. However, they can also be
trained using a two-stage process, in which the first layer weights are computed independently from the weights in the second layer. Finally, these
networks can be built in an incremental way - one neuron at a time.
17-1
17
The radial basis network is a two-layer network. There are two major distinctions between the radial basis function (RBF) network and a two layer
perceptron network. First, in layer 1 of the RBF network, instead of performing an inner product operation between the weights and the input
(matrix multiplication), we calculate the distance between the input vector
and the rows of the weight matrix. (This is similar to the LVQ network
shown in Figure 16.13.) Second, instead of adding the bias, we multiply by
the bias. Therefore, the net input for neuron i in the first layer is calculated
as follows:
1
n i = p iw b i .
17-2
(17.1)
Each row of the weight matrix acts as a center point - a point where the net
input value will be zero. The bias performs a scaling operation on the transfer (basis) function, causing it to stretch or compress.
We should note that most papers and texts on RBF networks use the terms
standard deviation, variance or spread constant, rather than bias. We have
used the bias in order to maintain a consistency with other networks in this
text. This is simply a matter of notation and pedagogy. The operation of the
network is not affected. When a Gaussian transfer function is used, the
bias is related to the standard deviation as follows: b = 1 2 .
The transfer functions used in the first layer of the RBF network are different than the sigmoid functions generally used in the hidden layers of
multilayer perceptrons (MLP). There are several different types of transfer
function that can be used (see [BrLo88]), but for clarity of presentation we
will consider only the Gaussian function, which is the one most commonly
used in the neural network community. It is defined as follows
a = e
(17.2)
17
0.8
0.6
a = e
a
0.4
0.2
n
Figure 17.1 Gaussian Basis Function
Local Function
Global Function
A key property of this function is that it is local. This means that the output
is close to zero if you move very far in either direction from the center point.
This is in contrast to the global sigmoid functions, whose output remains
close to 1 as the net input goes to infinity.
The second layer of the RBF network is a standard linear layer:
2
2 1
a = W a +b
17-3
(17.3)
Inputs
Linear Layer
W1
S1xR
p
1
R x1
||dist||
.*
1
R
S1x1
n1
S1x1
S2x1
S x1
S
1
S2x1
n2
S2xS1
S2
S2x1
a i = radbas(||iw -p||b i)
2 1
a = W a +b
Function Approximation
This RBF network has been shown to be a universal approximator
[PaSa93], just like the MLP network. To illustrate the capability of this
network, consider a network with two neurons in the hidden layer, one output neuron, and with the following default parameters:
1
w 1 1 = 1 , w 2 1 = 1 , b 1 = 2 , b 2 = 2 ,
2
w 1 1 = 1 , w 1 2 = 1 , b = 0 .
The response of the network with the default parameters is shown in Fig2
ure 17.3, which plots the network output a as the input p is varied over
the range 2 2 .
Notice that the response consists of two hills, one for each of the Gaussian
neurons (basis functions) in the first layer. By adjusting the network parameters, we can change the shape and location of each hill, as we will see
in the following discussion. (As you proceed through this example, it may
be helpful to compare the response of this sample RBF network with the
response of the sample MLP network in Figure 11.5.)
17-4
1
2
p
Figure 17.3 Default Network Response
Figure 17.4 illustrates the effects of parameter changes on the network response. The blue curve is the nominal response. The other curves correspond to the network response when one parameter at a time is varied over
the following ranges:
1
0 w 2 1 2 , 1 w 1 1 1 , 0.5 b 2 8 , 1 b 1 .
2
b2
w 2 1
1
2
1
2
(a)
2
(c)
(b)
w 1 1
1
2
(17.4)
1
2
(d)
17-5
17
Center
location of the hills; there will be a hill centered at each first layer weight.
For multidimensional inputs there will be a hill centered at each row of the
weight matrix. For this reason, each row of the first layer weight matrix is
often called the center for the corresponding neuron (basis function).
Notice that the effects of the weight and the bias in first layer of the RBF
network are much different than for the MLP network, which was shown
in Figure 11.6. In the MLP network, the sigmoid functions create steps.
The weights change the slopes of the steps, and the biases change the locations of the steps.
Figure 17.4 (c) illustrates how the weights in the second layer scale the
height of the hills. The bias in the second layer shifts the entire network
response up or down, as can be seen in Figure 17.4 (d). The second layer of
the RBF network is the same type of linear layer used in the MLP network
of Figure 11.6, and it performs a similar function, which is to create a
weighted sum of the outputs of the layer 1 neurons.
This example demonstrates the flexibility of the RBF network for function
approximation. As with the MLP, it seems clear that if we have enough
neurons in the first layer of the RBF network, we can approximate virtually any function of interest, and [PaSa93] provides a mathematical proof
that this is the case. However, although both MLP and RBF networks are
universal approximators, they perform their approximations in different
ways. For the RBF network, each transfer function is only active over a
small region of the input space - the response is local. If the input moves
far from a given center, the output of the corresponding neuron will be close
to zero. This has consequences for the design of RBF networks. We must
have centers adequately distributed throughout the range of the network
inputs, and we must select biases in such a way that all of the basis functions overlap in a significant way. (Recall that the biases change the width
of each basis function.) We will discuss these design considerations in more
detail in later sections.
To experiment with the response of this RBF network, use the MATLAB
Neural Network Design Demonstration RBF Network Function (nnd17nf).
Pattern Classification
2
+2
Category 1: p 2 = 1 p 3 = 1 , Category 2:
1
1
17-6
1 p = 1 .
p1 =
4
1
1
p2
p1
p4
p3
The problem is illustrated graphically in the figure to the left. Because the
two categories are not linearly separable, a single-layer network cannot
perform the classification.
RBF networks can classify these patterns. In fact, there are many different
RBF solutions. We will consider one solution that demonstrates in a simple
way how to use RBF networks for pattern classification. The idea will be to
have the network produce outputs greater than zero when the input is near
patterns p 2 or p 3 , and outputs less than zero for all other inputs. (Note
that the procedures we will use to design this example network are not
suitable for complex problems, but they will help us illustrate the capabilities of the RBF network.)
From the problem statement, we know that the network will need to have
two inputs and one output. For simplicity, we will use only two neurons in
the first layer (two basis functions), since this will be sufficient to solve the
XOR problem. As we discussed earlier, the rows of the first-layer weight
matrix will create centers for the two basis functions. We will choose the
centers to be equal to the patterns p 2 and p 3 . By centering a basis function
at each pattern, we can produce maximum network outputs there. The first
layer weight matrix is then
T
W =
p2
T
p3
= 1 1 .
1 1
(17.5)
The choice of the bias in the first layer depends on the width that we want
for each basis function. For this problem, we would like the network function to have two distinct peaks at p 2 and p 3 . Therefore, we dont want the
basis functions to overlap too much. The centers of the basis functions are
each a distance of 2 from the origin. We want the basis function to drop
significantly from its peak in this distance. If we use a bias of 1, we would
get the following reduction in that distance:
a = e
= e
1 2
= e
= 0.1353 .
(17.6)
Therefore, each basis function will have a peak of 1 at the centers, and will
drop to 0.1353 at the origin. This will work for our problem, so we select the
first layer bias vector to be
1
b = 1 .
1
(17.7)
The original basis function response ranges from 0 to 1 (see Figure 17.1).
We want the output to be negative for inputs much different than p 2 and
p 3 , so we will use a bias of -1 for the second layer, and we will use a value
17-7
17
of 2 for the second layer weights, in order to bring the peaks back up to 1.
The second layer weights and biases then become
2
W = 2 2 , b = 1 .
(17.8)
For the network parameter values given in (17.5), (17.7) and (17.8), the network response is shown in Figure 17.5. This figure also shows where the
2
surface intersects the plane at a = 0 , which is where the decision takes
place. This is also indicated by the contours shown underneath the surface.
2
These are the function contours where a = 0 . They are almost circles that
surround the p 2 and p 3 vectors. This means that the network output will
be greater than 0 only when the input vector is near the p 2 and p 3 vectors.
1
0.5
0
0.5
1
1.5
2
3
2
1
0
p2
1
2
3
p1
17-8
p2
3
3
p1
17
sigmoid functions in the first layer will have significant outputs. They must
sum or cancel in the second layer in order to produce the appropriate response at each point. In the RBF network, each basis function is only active
over a small range of the input. For any given input, only a few basis functions will be active.
There are advantages and disadvantages to each approach. The global approach tends to require fewer neurons in the hidden layer, since each neuron contributes to the response over a large part of the input space. For the
RBF network, however, basis centers must be spread throughout the range
of the input space in order to provide an accurate approximation. This leads
to the problem of the curse of dimensionality, which we will discuss in the
next section. Also, if more neurons, and therefore more parameters, are
used, then there is a greater likelihood that the network will overfit the
training data and fail to generalize well to new situations.
On the other hand, the local approach generally leads to faster training, especially when the two-stage algorithms, which will be discussed in the next
section, are used. Also, the local approach can be very useful for adaptive
training, in which the network continues to be incrementally trained while
it is being used, as in adaptive filters (nonlinear versions of the filters in
Chapter 10) or controllers. If, for a period of time, training data only appears in a certain region of the input space, then a global representation
will tend to improve its accuracy in those regions at the expense of its representation in other regions. Local representations will not have this problem to the same extent. Because each neuron is only active in a small region
of the input space, its weights will not be adjusted if the input falls outside
that region.
mainly in how the first layer weights and biases are selected. Once the first
layer weights and biases have been selected, the second layer weights can
be computed in one step, using a linear least-squares algorithm. We will
discuss linear least squares in the next section.
Curse of Dimensionality
The simplest of the two-stage algorithms arranges the centers (first layer
weights) in a grid pattern throughout the input range and then chooses a
constant bias so that the basis functions have some degree of overlap. This
procedure is not optimal, because the most efficient approximation would
place more basis functions in regions of the input space where the function
to be approximated is most complex. Also, for many practical cases the full
range of the input space is not used, and therefore many basis functions
could be wasted. One of the drawbacks of the RBF network, especially
when the centers are selected on a grid, is that they suffer from the curse
of dimensionality. This means that as the dimension of the input space increases, the number of basis functions required increases geometrically.
For example, suppose that we have one input variable, and we specify a
grid of 10 basis functions evenly spaced across the range of that input variable. Now, increase the number of input variables to 2. To maintain the
same grid coverage for both input variables, we would need 102, or 100 basis functions.
Another method for selecting the centers is to select some random subset
of the input vectors in the training set. This ensures that basis centers will
be placed in areas where they will be useful to the network. However, due
to the randomness of the selection, this procedure is not optimal. A more
efficient approach is to use a method such as the Kohonen competitive layer or the feature map, described in Chapter 16, to cluster the input space.
The cluster centers then become basis function centers. This ensures that
the basis functions are placed in regions with significant activity. We will
discuss this method in a later section.
A final procedure that we will discuss for RBF training is called orthogonal
least squares. It is based on a general method for building linear models
called subset selection. This method starts with a large number of possible
centerstypically all of the input vectors from the training data. At each
stage of the procedure, it selects one center to add to the first layer weight.
The selection is based on how much the new neuron will reduce the sum
squared error. Neurons are added until some criteria is met. The criteria is
typically chosen to maximize the generalization capability of the network.
17
S
1
b i = ---------- ,
d max
(17.9)
(17.10)
n i q = p q iw b i ,
1
(17.11)
a q = radbas n q .
(17.12)
Since the first layer weights and biases will not be adjusted, the training
data set for the second layer then becomes
1
a 1 t 1 a 2 t 2 a Q t Q .
(17.13)
2 1
a = W a +b .
(17.14)
We want to select the weights and biases in this layer to minimize the sum
square error performance index over the training set:
Q
Fx =
2 T
tq aq
tq aq
(17.15)
q=1
Our derivation of the solution to this linear least squares problem will follow the linear network derivation starting with Eq. (10.6). To simplify the
discussion, we will assume a scalar target, and we will lump all of the parameters we are adjusting, including the bias, into one vector:
17-12
1w
x =
(17.16)
zq = aq .
1
(17.17)
a q = 1w a q + b ,
(17.18)
can be written as
T
aq = x zq .
(17.19)
This allows us to conveniently write out an expression for the sum square
error:
Q
F x =
eq
tq aq
q=1
q=1
tq x
zq .
(17.20)
q=1
t2 , U =
z1
T
z2
2u
e1
,e =
zQ
T
Qu
e2 .
(17.21)
tQ
T
1u
eQ
(17.22)
F x = t Ux t Ux .
(17.23)
If we use regularization, as we discussed in Chapter 13, to help in preventing overfitting, we obtain the following form for the performance index:
17-13
17
F x = t Ux t Ux + x i = t Ux t Ux + x x , (17.24)
2
i=1
F x = t Ux t Ux + x x = t t 2t Ux + x U Ux + x x
T
= t t 2t Ux + x U U + I x
(17.25)
Take a close look at Eq. (17.25), and compare it with the general form of the
quadratic function, given in Eq. (8.35) and repeated here:
1 T
T
F x = c + d x + --- x Ax .
2
(17.26)
c = t t , d = 2U t and A = 2 U U + I .
(17.27)
2
The stationary point of F x can be found by setting the gradient equal to
zero:
T
2Z t + 2 U U + I x = 0
17-14
U U + I x = U t .
(17.29)
U U + I x = U t .
T
(17.30)
x = U U + I U t
T
(17.31)
To illustrate the least squares algorithm, lets choose a network and apply
it to a particular problem. We will use an RBF network with three neurons
in the first layer to approximate the following function
(17.32)
To obtain our training set we will evaluate this function at six values of p :
p = 2 1.2 0.4 0.4 1.2 2 .
(17.33)
(17.34)
W =
(17.35)
The next step is to compute the output of the first layer, using the following
equations.
1
n i q = p q iw b i ,
1
a q = radbas n q .
1
17-15
(17.36)
(17.37)
17
1
0.852 0.527 0.237 0.077 0.018
1
0.018 0.077 0.237 0.527 0.852
1
(17.38)
We can use Eq. (17.17) and Eq. (17.21) to create the U and t matrices
1 0.852 0.527 0.237 0.077 0.018
0.368
0.698 0.961 0.961 0.698 0.368 ,
U =
0.018 0.077 0.237 0.527 0.852 1
1
1
1
1
1
1
T
(17.39)
(17.40)
The next step is to solve for the weights and biases in the second layer using Eq. (17.30). We will begin with the regularization parameter set to zero.
1
x = U U + I U t
T
2.07
= 1.76
0.42
2.71
1.76
3.09
1.76
4.05
0.42 2.71
1.76 4.05
2.07 2.71
2.71 6
1.01
1.03
4.05 =
0
4.41
1.03
6
1
(17.41)
W = 1.03 0 1.03 , b = 1 .
(17.42)
Figure 17.7 illustrates the operation of this RBF network. The blue line
represents the RBF approximation, and the circles represent the six data
points. The dotted lines in the upper axis represent the individual basis
functions scaled by the corresponding weights in the second layer (including the constant bias term). The sum of the dotted lines will produce the
blue line. In the small axis at the bottom, you can see the unscaled basis
functions, which are the outputs of the first layer.
17-16
2.5
2
1.5
1
0.5
0
0.5
1
1.5
1
0.8
0.6
0.4
0.2
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
0.2
0.4
0.6
0.8
0.5
0
1
1.5
0.5
0.5
1
2
1.5
0.5
1.5
0.5
0.5
1.5
0.5
1.5
0.5
0
2
17-17
17
To experiment with the linear least squares fitting, use the MATLAB Neural Network Design Demonstration RBF Linear Least Squares (nnd17lls).
The basic idea behind this method comes from statistics, and it is called
subset selection [Mill90]. The general objective of subset selection is to
choose an appropriate subset of independent variables to provide the most
efficient prediction of a target dependent variable. For example, suppose
that we have 10 independent variables, and we want to use them to predict
our target dependent variable. We want to create the simplest predictor
possible, so we want to use the minimum number of independent variables
for the prediction. Which subset of the 10 independent variables should we
use? The optimal approach, called an exhaustive search, tries all combinations of subsets and finds the smallest one that provides satisfactory performance. (We will define later what we mean by satisfactory
performance.)
Unfortunately, this strategy is not practical. If we have Q variables in our
original set, the following expression gives the number of distinct subsets:
Q
Q!
-.
-----------------------q! Q q !
(17.43)
q=1
Forward Selection
Backward Elimination
If Q = 10 , this number is 1023. If Q = 20 , the number is more than 1 million. We need to have a less expensive strategy than the exhaustive search.
There are several suboptimal procedures. They are not guaranteed to find
the optimal subset, but they require significantly less computation. One
procedure is called forward selection. This method begins with an empty
model and then adds variables one at a time. At each stage, we add the independent variable that provides the largest reduction in squared error.
We stop adding variables when the performance is adequate. Another approach, called backward elimination, starts with all independent variables
selected for the model. At each stage we eliminate the variable that would
cause the least increase in the squared error. The process continues until
the performance is inadequate. There are other approaches which combine
17-18
(17.44)
We will use our standard notation for matrix rows and columns to individually identify both the rows and the columns of the matrix U:
U =
1u
2u
=
T
z2 =
u1 u2 un
(17.45)
Qu
z1
zQ
Here each row of the matrix U represents the output of layer 1 of the RBF
network for one input vector from the training set. There will be a column
of the matrix U for each neuron (basis function) in layer 1 plus the bias term
1
( n = S + 1 ). Note that for the OLS algorithm, the potential centers for the
basis functions are often chosen to be all of the input vectors in the training
set. In this case, n will equal Q + 1 , since the constant 1 for the bias term
is included in z , as shown in Eq. (17.17).
Regression Matrix
Eq. (17.44) is in the form of a standard linear regression model. The matrix
U is called the regression matrix, and the columns of U are called the regressor vectors.
The objective of OLS is to determine how many columns of U (numbers of
neurons or basis functions) should be used. The first step is to calculate
how much each potential column would reduce the squared error. The problem is that the columns are generally correlated with each other, and so it
is difficult to determine how much each individual column would reduce
the error. For this reason, we need to first orthogonalize the columns. Orthogonalizing the columns means that we can decompose U as follows:
U = MR ,
where R is an upper triangular matrix, with ones on the diagonal:
17-19
(17.46)
17
1 r 1 2 r 1 3 r 1 n
0 1 r 2 3 r 2 n
0 0
0 r n 1 n
0 0
R =
(17.47)
m1 m1
v 1 1 0 0
T
M M = V =
0 v 2 2 0
m2 m2
(17.48)
0 v n n
mn mn
(17.49)
h = Rx .
(17.50)
where
h = M M M t = V M t ,
T
(17.51)
mi t
mi t
h i = --------= -------------.
T
v i i
mi mi
(17.52)
From h we can compute x using Eq. (17.50). Since R is upper-triangular, Eq. (17.50) can be solved by back-substitution and does not require a
matrix inversion.
There are a number of ways to obtain the orthogonal vectors m i , but we
will use the Gram-Schmidt orthogonalization process of Eq. (5.20), starting
with the original columns of U .
m1 = u1 ,
17-20
(17.53)
k1
ri k mi ,
mk = uk
(17.54)
i=1
where
T
mi uk
r i k = ------------- , i = 1 k 1 .
T
mi mi
(17.55)
Now lets see how orthogonalizing the columns of U enables us to efficiently calculate the squared error contribution of each basis vector. Using Eq.
(17.49), the total sum square value of the targets is given by
T
t t = Mh + e Mh + e = h M Mh + e Mh + h M e + e e .
(17.56)
e Mh = t Mh Mh = t Mh h M Mh .
(17.57)
T
T
T
1
T
T
e Mh = t Mh t MV M Mh = t Mh t Mh = 0 .
(17.58)
Therefore the total sum square value from Eq. (17.56) becomes
n
T
t t = h M Mh + e e = h Vh + e e =
hi mi mi + e
2
e.
(17.59)
i=1
The first term on the right of Eq. (17.59) is the contribution to the sum
squared value explained by the regressors, and the second term is the remaining sum squared value that is not explained by the regressors. Therefore, regressor (basis function) i contributes
2
hi mi mi
(17.60)
to the squared value. This also represents how much the squared error can
be reduced by including the corresponding basis function in the network.
We will use this number, after normalizing by the total squared value, to
determine the next basis function to include at each iteration:
2
hi mi mi
-.
o i = ------------------T
t t
This number always falls between zero and one.
17-21
(17.61)
17
Now lets put all these ideas together into an algorithm for selecting centers.
The OLS Algorithm
To begin the algorithm, we start with all potential basis functions included
in the regression matrix U . (As we explained below Eq. (17.45), if all input
vectors in the training set are to be considered potential basis function centers, then the U matrix will be Q by Q + 1 .) This matrix represents only
potential basis functions, since we start with no basis functions included in
the network.
The first stage of the OLS algorithm consists of the following three steps,
for i = 1 Q :
i
m1 = ui ,
i
h1
i
o1
(17.62)
iT
m1 t
= ---------------------,
i T i
m1 m1
i 2
iT
(17.63)
h1 m1 m1
.
= ------------------------------------T
t t
(17.64)
We then select the basis function that creates the largest reduction in error:
i
o 1 = o 1 1 = max o 1 ,
i
m 1 = m 1 1 = u i1 .
(17.65)
(17.66)
mj ui
= ------------- , j = 1 k 1 ,
T
mj mj
(17.67)
k1
i
mk = ui
rj k mj ,
j=1
17-22
(17.68)
iT
mk t
= ---------------------,
i T i
mk mk
i
hk
i 2
iT
(17.69)
hk mk mk
i
o k = ------------------------------------,
T
t t
ik
ok = ok
= max o k ,
k
r j k = r j k , j = 1 k 1 .
mk = mk k .
(17.70)
(17.71)
(17.72)
(17.73)
The iterations continue until some stopping criterion is met. One choice of
stopping criterion is
k
oj ,
(17.74)
j=1
xn = hn , xk = hk
r j k x j ,
(17.75)
j = k+1
where n is the final number of weights and biases in the second layer (adjustable parameters).
To experiment with orthogonal least squares learning, use the MATLAB
Neural Network Design Demonstration RBF Orthogonal Least Squares
(nnd17ols).
Clustering
There is another approach [MoDa89] for selecting the weights and biases
in the first layer of the RBF network. This method uses the competitive networks described in Chapter 16. Recall that the competitive layer of Kohonen (see Figure 16.2) and the Self Organizing Feature Map (see Figure
17-23
17
16.9) perform a clustering operation on the input vectors of the training set.
After training, the rows of the competitive networks contain prototypes, or
cluster centers. This provides an approach for locating centers and selecting biases for the first layer of the RBF network. If we take the input vectors from the training set and perform a clustering operation on them, the
resulting prototypes (cluster centers) could be used as centers for the RBF
network. In addition, we could compute the variance of each individual
cluster and use that number to calculate an appropriate bias to be used for
the corresponding neuron.
Consider again the following training set:
{p 1, t 1} { p 2, t 2} {p Q, tQ} .
(17.76)
We want to perform a clustering of the input vectors from this training set:
p 1 p 2 p Q .
(17.77)
We will train the first layer weights of the RBF network to perform a clustering of these vectors, using the Kohonen learning rule of Eq. (16.13), and
repeated here:
i
w q =
w
i
q 1 + p q iw q 1 ,
(17.78)
1
nc
2
1
1 2
i
dist i = ----- p j iw
nc
(17.79)
j=1
i
p1
where
is the input vector that closest to iw , and is p 2 the next closest
input vector. From these distances, [MoDa89] recommends setting the first
layer biases as follows:
17-24
1
1
b i = ------------------ .
2dist i
(17.80)
Nonlinear Optimization
It is also possible to train RBF networks in the same manner as MLP networksusing nonlinear optimization techniques, in which all weights and
biases in the network are adjusted at the same time. These methods are not
generally used for the full training of RBF networks, because these networks tend to have many more unsatisfactory local minima in their error
surfaces. However, nonlinear optimization can be used for the fine-tuning
of the network parameters, after initial training by one of the two-stage
methods we presented in earlier sections.
We will not present the nonlinear optimization methods in their entirety
here, since they were treated extensively in Chapters 11 and 12. Instead,
we will simply indicate how the basic backpropagation algorithm for computing the gradient in MLP networks can be modified for RBF networks.
The derivation of the gradient for RBF networks follows the same pattern
as the gradient development for MLP networks, starting with Eq. (11.9),
which you may wish to review at this time. Here we will only discuss the
one step where the two derivations differ. The difference occurs with Eq.
(11.20). The net input for the second layer of the RBF network has the same
form as its counterpart in the MLP network, but the first layer net input
has a different form (as given in Eq. (17.1) and repeated here):
S
1
ni
= p iw
1
bi
1
bi
pj w i j
1
j=1
17-25
(17.81)
17
If we take the derivative of this function with respect to the weights and
biases, we obtain
1
n i
b i w i j p j
12
1
1
- 2 p j w i j 1 = ------------------------------------- = b i --------------------------------------,
1
1
1
S
w i j
p iw
1 2
pj wi j
(17.82)
j=1
1
n i
1
-------1- = p iw .
b i
(17.83)
This produces the modified gradient equations (compare with Eq. (11.23)
and Eq. (11.24)) for Layer 1 of the RBF network
1
F
1 b i w i j p j
---------- = s i ----------------------------,
1
1
w i j
p iw
(17.84)
F
1
1
-------1- = s i p iw .
b i
(17.85)
Therefore, if we look at the summary of the gradient descent backpropagation algorithm for MLP networks, from Eq. (11.44) to Eq. (11.47), we find
that the only difference for RBF networks is that we substitute Eq. (17.84)
and Eq. (17.85) for Eq. (11.46) and Eq. (11.47) when m = 1 . When m = 2
the original equations remain the same.
To experiment with nonlinear optimization learning, use the MATLAB
Neural Network Design Demonstration RBF Nonlinear Optimization
(nnd17no).
Summary of Results
Summary of Results
Radial Basis Network
Radial Basis Layer
Inputs
Linear Layer
W1
S1xR
p
1
R x1
a1
||dist||
.*
1
R
S1x1
n1
S1x1
S2x1
S x1
S
1
S2
S2x1
a i = radbas(||iw -p||b i)
2 1
a = W a +b
x =
1w
t1
t =
,U =
, zq = aq
1
T
1u
z1
T
z2
2u
,e =
zQ
eQ
F x = t Ux t Ux + x x
U U + I x = U t
T
e2
T
Qu
e1
tQ
17-27
17
t2
S2x1
n2
S2xS1
a2
W2
m1 = ui ,
iT
m1 t
i
h 1 = ---------------------,
i T i
m1 m1
i 2
iT
h1 m1 m1
i
.
o 1 = ------------------------------------T
t t
i
o 1 = o 1 1 = max o 1
i
m 1 = m 1 1 = u i1 .
Step k
For i = 1 Q , i i 1 , ..., i i k 1
T
mj uk
i
r j k = ------------- , j = 1 k ,
T
mj mj
k1
i
mk
= ui
r j k mj ,
j=1
i
hk
i
ok
iT
mk t
= ---------------------,
i T i
mk mk
i 2
iT
hk mk mk
,
= ------------------------------------T
t t
i
o k = o k k = max o k ,
i
mk = mk k .
17-28
Summary of Results
Clustering
Training the weights
i
w q =
w
i
q 1 + p q iw q 1
1
---
2
1
1 2
i
dist i = ----- p j iw
nc
j=1
1
1
b i = -----------------2dist i
Nonlinear Optimization
Replace Eq. (11.46) and Eq. (11.47) in standard backpropagation with
1
1
F
1 b i w i j p j
---------s
=
----------------------------,
i
1
1
w i j
p iw
F
1
1
-------1- = s i p iw .
b i
17-29
17
Solved Problems
P17.1 Use the OLS algorithm, to approximate the following function:
g p = cos p for 1 p 1 .
To obtain our training set we will evaluate this function at five values of p :
p = 1 0.5 0 0.5 1 .
This produces the targets
t = 1 0 1 0 1 .
Perform one iteration of the OLS algorithm. Assume that the inputs in the training set are the potential centers and that the biases are all equal to 1.
First, we compute the outputs of the first layer:
1
n i q = p q iw b i ,
1
a q = radbas n q ,
1
a =
We can use Eq. (17.17) and Eq. (17.21) to create the U and t matrices:
1.000
0.779
T
U = 0.368
0.105
0.018
1.000
T
0.779
1.000
0.779
0.368
0.105
1.000
0.368
0.779
1.000
0.779
0.368
1.000
0.105
0.368
0.779
1.000
0.779
1.000
t = 1 0 1 0 1 .
17-30
0.018
0.105
0.368 ,
0.779
1.000
1.000
Solved Problems
m1 = ui ,
m1
1.000
0.779
0.368
0.105
0.779
1.000
0.779
0.368
2
3
4
= 0.368 , m 1 = 0.779 , m 1 = 1.000 , m 1 = 0.779 ,
0.105
0.368
0.779
1.000
0.018
0.105
0.368
0.779
m1
0.018
1.000
0.105
1.000
6
= 0.368 , m 1 = 1.000 ,
0.779
1.000
1.000
1.000
iT
m1 t
i
h 1 = ---------------------,
i T i
m1 m1
1
h1
= 0.371 , h 1
= 0.045 , h 1
6
h1
i
o1
o1
= 0.0804 , o 1
= 0.106 , h 1
= 0.045 , h 1
= 0.371 ,
= 0.200 ,
i 2
iT
h1 m1 m1
,
= ------------------------------------T
t t
3
= 0.0016 , o 1
o1
= 0.0094 , o 1
= 0.0016 , o 1
= 0.0804 ,
= 0.0667 .
We see that the first and fifth centers would produce a 0.0804 reduction in
the error. This means that the error would be reduced by 8.04%, if the first
or fifth center were used in a single-neuron first layer. We would typically
select the first center, since it has the smallest index.
If we stop at this point, we would add the first center to the hidden layer.
2
1
Using Eq. (17.75), we would find that w 1 1 = x 1 = h 1 = h 1 = 0.371 . Also,
6
b 2 = 0 , since the bias center, m 1 , was not selected on the first iteration.
Note that if we continue to add neurons in the hidden layer, the first weight
will change. This can be seen from Eq. (17.75). This equation to find x k is
only used after all of the h k are found. Only x n will exactly equal h n .
17-31
17
W =
1 1 .
2.5 2.5
The choice of the biases in the first layer depends on the width that we
want for each basis function. For this problem, the first basis function
should be wider than the second. Therefore, the first bias will be smaller
than the second bias. The boundary formed by the first basis function
17-32
Solved Problems
= e
1 1
= e
= 0.3679 , a = e
= e
2 0.5
= e
= 0.3679
This will work for our problem, so we select the first layer bias vector to be
1
b = 1 .
2
The original basis function response ranges from 0 to 1 (see Figure 17.1).
We want the output to be negative for inputs outside the decision regions,
so we will use a bias of -1 for the second layer, and we will use a value of 2
for the second layer weights, in order to bring the peaks back up to 1. The
second layer weights and biases then become
2
W = 2 2 , b = 1 .
For these network parameter values, the network response is shown on the
right side of Figure P17.2. This figure also shows where the surface inter2
sects the plane at a = 0 , which is where the decision takes place. This is
also indicated by the contours shown underneath the surface. These are the
2
function contours where a = 0 . These decision regions are shown more
clearly on the left side of Figure P17.2.
3.5
1
3
0.5
2.5
p2
0
0.5
1
1.5
1.5
2
0
1
0.5
p1
0
0.5
1.5
p1
2.5
3.5
1
4
17-33
p2
17
P17.3 For an RBF network with one input and one neuron in the hidden
layer, the initial weights and biases are chosen to be
1
w 0 = 0 , b 0 = 1 , w 0 = 2 , b 0 = 1 .
An input/target pair is given to be
p = 1 t = 1 .
Perform one iteration of steepest descent backpropagation with
= 1.
The first step is to propagate the input through the network.
1
n = p w b = 1 1 0 = 1
1
a = radbas n = e
2
2 1
1 2
= e
= 0.3679
n = w a + b = 2 0.3679 + 1 = 0.2642
2
a = purelin n = n = 0.2642
2
e = t a = 1 0.2642 = 0.7358
Now we backpropagate the sensitivities using Eq. (11.44) and Eq. (11.45).
2 2
2
s = 2F (n ) t a = 2 1 e = 2 1 0.7358 = 1.4716
2
1
1 1
1
2 T 2
1 n
2 2
1
s = F (n ) W s = 2 n e
w s = 2 1 e 2 1.4716 = 2.1655
Finally, the weights and biases are updated using Eq. (11.46) and Eq.
(11.47) for Layer 2, and Eq. (17.84) and Eq. (17.85) for Layer 1:
2
1 T
b 1 = b 0 s = 1 1 1.4716 = 2.4716 ,
1
b 1 = b 0 s p w
17-34
= 1 1 2.1655 1 0 = 3.1655 .
Epilogue
Epilogue
The radial basis function network is an alternative to the multilayer perceptron network for problems of function approximation and pattern recognition. In this chapter we have demonstrated the operation of the RBF
network, and we have described several techniques for training the network. Unlike MLP training, RBF training usually consists of two stages. In
the first stage, the weights and biases in the first layer are found. In the
second stage, which typically involves linear least squares, the second layer
weights and biases are calculated.
17
17-35
Further Reading
[Bish91]
[BrLo88]
D.S. Broomhead and D. Lowe, Multivariable function interpolation and adaptive networks, Complex Systems,
vol.2, pp. 321-355, 1988.
This seminal paper describes the first use of radial basis
functions in the context of neural networks.
[ChCo91]
[ChCo92]
[ChCh96]
S. Chen, E. S. Chng, and K. Alkadhimi, Regularised orthogonal least squares algorithm for constructing radial
basis function networks, International Journal of Control,
Vol. 64, No. 5, pp. 829837, 1996.
Modifies the orthogonal least squares algorithm to handle
regularized performance indices.
[ChCo99]
S. Chen, C.F.N. Cowan, and P.M. Grant, Combined Genetic Algorithm Optimization and Regularized Orthogonal
Least Squares Learning for Radial Basis Function Networks, IEEE Transactions on Neural Networks, Vol.10,
No.5, pp.302-309, 1999.
Combines a genetic algorithm with orthogonal least
squares to compute the regularization parameter and basis
17-36
Further Reading
[Mill90]
[MoDa89]
[OrHa00]
M. J. Orr, J. Hallam, A. Murray, and T. Leonard, Assessing rbf networks using delve, IJNS, 2000.
This paper compares a variety of methods for training radial basis function networks. The methods include forward
selection with regularization and also regression trees.
[PaSa93]
J. Park and I.W. Sandberg, Universal approximation using radial-basis-function networks, Neural Computation,
vol. 5, pp. 305-316, 1993.
This paper proves the universal approximation capability
of radial basis function networks.
[Powe87]
M.J.D. Powell, Radial basis functions for multivariable interpolation: a review, Algorithms for Approximation, pp.
143-167, Oxford, 1987.
This paper provides the definitive survey of the original
work on radial basis functions. The original use of radial
basis functions was in exact multivariable interpolation.
17-37
17
Exercises
E17.1 Design an RBF network to perform the classification illustrated in Figure
E17.1. The network should produce a positive output whenever the input
vector is in the shaded region and a negative output otherwise.
1
2
17-38
Exercises
E17.3 Consider a 1-2-1 RBF network (two neurons in the hidden layer and one
output neuron). The first layer weights and biases are fixed as follows:
1
1
W = 1 , b = 0.5 .
1
0.5
2
Assume that the bias in the second layer is fixed at 0 ( b = 0 ). The training
set has the following input/target pairs:
p 1 = 1 t 1 = 1 , p 2 = 0 t 2 = 0 , p 3 = 1 t 3 = 1 .
i. Use linear least squares to solve for the second layer weights, assuming that the regularization parameter = 0 .
ii. Plot the contour plot for the sum squared error. Recall that it will be
a quadratic function. (See Chapter 8.)
2+2
ans =
4
iii. Write a MATLAB M-file to check your answers to parts i. and ii.
iv. Repeat parts i. to iii., with = 4 . Plot regularized squared error.
E17.4 The Hessian matrix for the performance index of the RBF network, given
in Eq. (17.25), is
T
2 U U + I .
Show that this matrix is at least positive semidefinite for 0 , and show
that it is positive definite if 0 .
E17.5 Consider an RBF network with the weights and biases in the first layer
fixed. Show how the LMS algorithm of Chapter 10 could be modified for
learning the second layer weights and biases.
E17.6 Suppose that a Gaussian transfer function in the first layer of the RBF network is replaced with a linear transfer function.
i. In Solved Problem P11.8, we showed that a multilayer perceptron
with linear transfer functions in each layer is equivalent to a singlelayer perceptron. If we use a linear transfer function in each layer
of an RBF network, is that equivalent to a single-layer network? Explain.
2+2
ans =
4
17-39
17
E17.7 Consider a Radial Basis Network, as in Figure 17.2, but assume that there
is no bias in the second layer. There are two neurons in the first layer (two
basis functions). The first layer weights (centers) and biases are fixed, and
we have three inputs and targets. The outputs of the first layer and the targets are given by
1
a = 2 1 0 , t = 0 1 2 .
1
i. Use linear least squares to find the second layer weights of the network.
ii. Assume now that the basis function centers in the first layer are
only potential centers. If orthogonal least squares is used to select
potential centers, which center will be selected first, what will be its
corresponding weight in the second layer, and how much will it reduce the squared error? Show all calculations clearly and in order.
iii. Is there a relationship between the two weights that you computed
in part i. and the single weight that you computed in part ii? Explain.
E17.8 Repeat E17.7 for the following data:
i.
ii.
1
a = 1 2 1 , t = 1 2 1 .
2
1
a = 2 1 0 , t = 3 1 2 .
1
E17.9 Consider the variation of the radial basis network shown in Figure E17.3.
The inputs and targets in the training set are p 1 = 1 t 1 = 1 ,
p 2 = 1 t 2 = 1 .
2
i. Find the linear least squares solution for the weight matrix W .
2
ii. For the weight matrix W that you found in part i., sketch the network response as the input varies from -2 to 2.
17-40
Exercises
Inputs
Linear Layer
W1
2x1
p
1x1
a1
||dist||
.*
1
1
2x1
n1
a2
1x1
n2
1x2
2x1
1x1
2x1
2
1
a i = ||iw -p||b i
1
2
2 1
a =Wa
2+2
ans =
4
ii. Add uniform random noise in the range 0.1 0.1 to the training
targets. Repeat Exercise E17.10 ii. with no regularization and with
regularization parameter = 0.2 2 20 . Which case produces the
best results. Explain.
17-41
17
2+2
ans =
4
E17.12 Write a MATLAB program to implement the orthogonal least squares algorithm. Repeat Exercise E17.10 using the orthogonal least squares algorithm. Use the 10 random training point inputs as the potential centers,
and use Eq. (17.9) to set the bias. Use only the first four selected centers.
Compare your final sum squared errors with the result from E17.10 part ii.
E17.13 Write a MATLAB program to implement the steepest descent algorithm
1
for the 1 S 1 RBF network. Train the network to approximate the function
2+2
ans =
4
You should be able to use a slightly modified version of the program you
wrote for Exercise E11.25.
i. Select 10 data points at random from the interval 2 p 2 .
ii. Initialize all parameters (weights and biases in both layers) as
small random numbers, and then train the network to convergence.
(Experiment with the learning rate , to determine a stable value.)
Plot the network response for 2 p 2 , and show the training
points on the same plot. Compute the sum squared error over the
training set. Use 2, 4 and 8 centers. Try different sets of initial
weights.
iii. Repeat part ii., but use a different method for initializing the parameters. Start by setting the parameters as follows. First, select
basis function centers evenly spaced on the interval 2 p 2 .
Then, use Eq. (17.9) to set the bias. Finally, use linear least squares
to find the second layer weights and biases. Compute the squared
error for these initial weights and biases. Starting from these initial
conditions, train all parameters with steepest descent.
iv. Compare the final sum squared errors for all cases and explain your
results.
E17.14 Suppose that a radial basis function layer (Layer 1 of the RBF network)
were used in the second or third layer of a multilayer network. How could
you modify the backpropagation equation, Eq. (11.35), to accommodate this
change. (Recall that the weight update equations would be modified from
Eq. (11.23) and Eq. (11.24) to Eq. (17.84) and Eq. (17.85).)
E17.15 Consider again Exercise E16.10, in which you trained a feature map to
cluster the input space
0 p1 1 , 2 p2 3 .
17-42
Exercises
Assume that over this input space, we wish to use an RBF network to approximate the following function:
t = sin 2p 1 cos 2p 2 .
2+2
ans =
4
17-43
17
Objectives
18
Grossberg Network
Objectives
18-1
18-2
18-3
18-4
Vision Normalization
18-8
18-9
18-12
Layer 1
18-13
Layer 2
18-17
18-20
Learning Law
18-22
18-24
Summary of Results
18-26
Solved Problems
18-30
Epilogue
18-42
Further Reading
18-43
Exercises
18-45
18
Objectives
This chapter is a continuation of our discussion of associative and competitive learning algorithms in Chapters 15 and 16. The Grossberg network
described in this chapter is a self-organizing continuous-time competitive
network. This will be the first time we have considered continuous-time recurrent networks, and we will introduce concepts here that will be further
explored in Chapters 20 and 21. This Grossberg network is also the foundation for the adaptive resonance theory (ART) networks that we will
present in Chapter 19.
We will begin with a discussion of the biological motivation for the Grossberg network: the human visual system. Although we will not cover this
material in any depth, the Grossberg networks are so heavily influenced by
biology that it is difficult to discuss his networks without putting them in
their biological context. It is also important to note that biology provided
the original inspirations for the field of artificial neural networks, and we
should continue to look for inspiration there, as scientists continue to develop new understanding of brain function.
18-1
18 Grossberg Network
18-2
Bipolar Cell
Amacrine
Cell
Ganglion Cell
Cone
Optic
Nerve
Lens
Light
Rod
Horizontal
Cell
Retina
18
Figure 18.1 Eyeball and Retina
Retina
Rods
Cones
The retina is actually a part of the brain. It becomes separated from the
brain during fetal development, but remains connected to it through the
optic nerve. The retina consists of three layers of nerve cells. The outer layer consists of the photoreceptors (rods and cones), which convert light into
electrical signals. The rods allow us to see in dim light, whereas the cones
allow us to see fine detail and color. For reasons not completely understood,
light must pass through the other two layers of the retina in order to stimulate the rods and cones. As we will see later, this obstruction must be compensated for in neural processing, in order to reconstruct recognizable
images.
Bipolar Cells
The middle layer of the retina consists of three types of cells: bipolar cells,
horizontal cells and amacrine cells. Bipolar cells receive input from the receptors and feed into the third layer of the retina, containing the ganglion
18-3
18 Grossberg Network
Horizontal Cells
Amacrine Cells
cells. Horizontal cells link the receptors and the bipolar cells, and amacrine
cells link bipolar cells with the ganglion cells.
Ganglion Cells
The final layer of the retina contains the ganglion cells. The axons of the
ganglion cells pass across the surface of the retina and collect in a bundle
to form the optic nerve. It is interesting to note that each eye contains
roughly 125 million receptors, but only 1 million ganglion cells. Clearly
there is significant processing done in the retina to perform data reduction.
Visual Cortex
The axons of the ganglion cells, bundled into the optic nerve, connect to an
area of the brain called the lateral geniculate nucleus, as illustrated in Figure 18.2. From this point the fibers fan out into the primary visual cortex,
located at the back of the brain. The axons of the ganglion cells make synapses with lateral geniculate cells, and the axons of the lateral geniculate
cells make synapses with cells in the visual cortex. The visual cortex is the
region of the brain devoted to visual function and consists of many layers
of cells.
Primary
Visual
Cortex
Lateral
Geniculate
Nucleus
Retina
Illusions
We now have some idea of the general structure of the visual pathway, but
how does it function? What is the purpose of the three layers of the retina?
What operations are performed by the lateral geniculate? Some hints to the
18-4
Fovea
Figure 18.3 is the view of the retina that an ophthalmologist has when
looking into the eye through the cornea. The large pale circle is the optic
disk, where the optic nerve leaves the retina on its way to the lateral geniculate. This is also where arteries enter and veins leave the retina. The optic disk causes a blind spot in our vision, as we will discuss in a moment.
The darker disk to the right of the optic disk is the fovea, which constitutes
the center of our field of vision. This is a region of the retina, about half a
millimeter in diameter, that contains only cones. Although cones are distributed throughout the retina, they are most densely packed in the fovea.
In addition, in this area of the retina the other layers are displaced to the
side, so that the cones lie at the front. The densely packed photoreceptors,
and the lack of obstruction, give us our best fine-detail vision at the fovea,
which allows us to precisely focus the lens.
Optic Disk (Blind Spot)
18
Vein
Fovea
18-5
18 Grossberg Network
at which the circle on the right will disappear from your field of vision. (You
are still looking at the circle on the left.) If you havent tried this before, it
can be a little disconcerting. The interesting thing is that we dont see our
blind spot as a black hole. Somehow our brains fill in the missing region.
Edge
Vein
Blind
Spot
Stabilized
Images Fade
Retina
Figure 18.5 Perception of an Edge on the Retina (after [Gros90])
Emergent Segmentation
Featural Filling-in
Because we do not see edges as displayed on the right side of Figure 18.5,
the neural systems in our visual pathway must be performing some operation that compensates for the distortions and completes the image. Grossberg suggests [GrMi89] that there are two primary types of compensatory
processing involved. The first, which he calls emergent segmentation, completes missing boundaries. The second, which he calls featural filling-in,
fills in the color and brightness inside the resulting boundaries. These two
processes are illustrated in Figure 18.6. In the top figure we see an edge as
it is originally perceived by the rods and cones, with missing sections. In
18-6
the lower figure we see the completed edge, after the emergent segmentation and featural filling-in.
Before Processing
After Processing
Emergent Segmentation
Featural Filling-in
18-7
18
18 Grossberg Network
Vision Normalization
Brightness Constancy
Brightness Contrast
Variable
Illumination
Separate
Constant Illumination
18-8
Time Constant
(18.1)
18
Leaky Integrator
+
-
1/
.
n
dn/dt = - n + p
Figure 18.9 Leaky Integrator
The response of the leaky integrator to an arbitrary input p t is
n(t) = e
18-9
1 t t
n(0) + --- e
p() d .
0
(18.2)
18 Grossberg Network
(18.3)
0.75
0.5
0.25
0
0
t
Figure 18.10 Leaky Integrator Response
There are two important properties of the leaky integrator that we want to
note. First, because Eq. (18.1) is linear, if the input p is scaled, then the
response n t will be scaled by the same amount. For example, if the input
is doubled, then the response will also be doubled, but will maintain the
same shape. This is evident in Eq. (18.3). Second, the speed of response of
the leaky integrator is determined by the time constant . When decreases, the response becomes faster; when increases, the response becomes
slower. (See Problem P18.1.)
To experiment with the leaky integrator, use the Neural Network Design
Demonstration Leaky Integrator (nnd15li).
Shunting Model
Excitatory
Inhibitory
(18.4)
Input
p+
+
1/
.
n
n
+
pb-
b+
0
-b-
n(t)
18-11
18
18 Grossberg Network
0.75
nt
0.75
p = 1
0.5
0.5
0.25
0.25
0
0
0
0
p = 5
Short-Term Memory
Long-Term Memory
18-12
Layer 1
Layer 2
(Retina)
(Visual Cortex)
Input
STM
LTM
(Adaptive Weights)
Contrast
Enhancement
Normalization
Layer 1
Layer 1 of the Grossberg network receives external inputs and normalizes
the intensity of the input pattern. (Recall from Chapter 14 that the Kohonen network performs best when the input patterns are normalized. For
the Grossberg network the normalization is accomplished by the first layer
of the network.) A block diagram of this layer is given in Figure 18.14. Note
that it uses the shunting model, with the excitatory and inhibitory inputs
computed from the input vector p .
Input
Layer 1
+b1
+W1
S1 x S1
S1 x 1
S1
1/
.
n1
n1
a1
-W1
S1 x S1
18
-b1
S1
dn (t)
+ 1
+ 1
- 1 - 1
1
1
1
-------------- = n (t) + b n (t) W p n (t) + b W p .
dt
18-13
(18.5)
18 Grossberg Network
As we mentioned earlier, the parameter determines the speed of response. It is chosen so that the neuron responses will be much faster than
the changes in the adaptive weights, which we will discuss in a later section.
+
(18.6)
1 0 0
0
+ 1
W = 0 1
.
0 0 1
Therefore the excitatory input to neuron i is the ith element of the input
vector.
-
(18.7)
0 1 1
1
- 1
W = 1 0
.
1 1 0
Thus the inhibitory input to neuron i is the sum of all elements of the input
vector, except the ith element.
+
On-Center/Off-Surround
For simplicity, we will set the inhibitory bias b to zero, which sets the
lower limit of the shunting model to zero, and we will set all elements of the
+ 1
excitatory bias b to the same value, i.e.,
+ 1
bi
+ 1
= b , i = 1 2 S ,
(18.8)
so that the upper limit for all neurons will be the same.
To investigate the normalization effect of Layer 1, consider the response of
neuron i :
18-14
dn i (t)
+ 1
1
1
1
- = n i (t) + b n i (t) p i n i (t) p j .
------------dt
(18.9)
ji
+ 1
(18.10)
ji
b pi
1
n i = ---------------------.
1
(18.11)
1+
pj
j=1
pj .
(18.12)
j=1
b P
1
n i = ------------- p i .
1 + P
(18.13)
S
1
nj
j=1
+ 1
+ 1
b P
b P
+ 1
------------ p = ------------- b .
1 + P j
1 + P
(18.14)
j=1
+ 1
The input vector is normalized so that the total activity is less than b ,
while the relative intensities of the individual elements of the input vector
1
are maintained. Therefore, the outputs of Layer 1, n i , code the relative input intensities, p i , rather than the instantaneous fluctuations in the total
input activity, P . This result is produced by the on-center/off-surround connection pattern of the inputs and the nonlinear gain control of the shunting
model.
Note that Layer 1 of the Grossberg network explains the brightness constancy and brightness contrast characteristics of the human visual system,
which we discussed on page 15-8. The network is sensitive to the relative
18-15
18
18 Grossberg Network
2
+2
intensities of an image, rather than absolute intensities. In addition, experimental evidence has shown that the on-center/off-surround connection
pattern is a characteristic feature of the receptive fields of retinal ganglion
cells [Hube88]. (The receptive field is an area of the retina in which the photoreceptors feed into a given cell. The figure in the left margin illustrates
the on-center/off-surround receptive field of a typical retinal ganglion cell.
A + indicates an excitatory region, and a - indicates an inhibitory region. It is a two-dimensional pattern, as opposed to the one-dimensional
connections of Eq. (18.6) and Eq. (18.7).)
To illustrate the performance of Layer 1, consider the case of two neurons,
+ 1
with b = 1 , = 0.1 :
1
dn 1(t)
1
1
1
0.1 -------------- = n 1(t) + 1 n 1(t) p 1 n 1(t)p 2 ,
dt
(18.15)
dn 2(t)
1
1
1
- = n 2(t) + 1 n 2(t) p 2 n 2(t)p 1 .
0.1 ------------dt
(18.16)
The response of this network, for two different input vectors, is shown in
Figure 18.15. For both input vectors, the second element is four times as
large as the first element, although the total intensity of the second input
vector is five times as large as that of the first input vector (50 vs. 10). From
Figure 18.15 we can see that the response of the network maintains the relative intensities of the inputs, while limiting the total response. The total
1
1
response ( n 1(t) + n 2(t) ) will always be less than 1.
1
n2
1
n2
0.75
0.75
p1 = 2
8
0.5
0
0
n1
0.25
0.05
p 2 = 10
40
0.5
n1
0.25
0.1
0.15
0.2
0
0
0.05
0.1
0.15
0.2
t
Figure 18.15 Layer 1 Response
To experiment with Layer 1 of the Grossberg network, use the Neural Network Design Demonstration Grossberg Layer 1 (nnd15gl1).
18-16
Layer 2
Short-Term Memory
Layer 2 of the Grossberg network, which is a layer of continuous-time instars, performs several functions. First, like Layer 1, it normalizes total activity in the layer. Second, it contrast enhances its pattern, so that the
neuron that receives the largest input will dominate the response. (This is
closely related to the winner-take-all competition in the Hamming network
and the Kohonen network.) Finally, it operates as a short-term memory
(STM) by storing the contrast-enhanced pattern.
Figure 18.16 is a diagram of Layer 2. As with Layer 1, the shunting model
forms the basis for Layer 2. The main difference between Layer 2 and Layer 1 is that Layer 2 uses feedback connections. The feedback enables the
network to store a pattern, even after the input has been removed. The
feedback also performs the competition that causes the contrast enhancement of the pattern. We will demonstrate these properties in the following
discussion.
Layer 2
+
W2
On-Center
+b2
S2 x S1
a1
S1
+
-
1/
+W2
+
-
.
n2
n2
+
-b2
Off-Surround
S2 x S2
f2
a2
18
S2
-W2
S2 x S2
dn (t)
+ 2
+ 2 2 2
2
2
2 1
-------------- = n (t) + b n (t) W f (n (t)) + W a
dt
- 2 - 2 2 2
2
n (t) + b W f (n (t))
18-17
(18.17)
18 Grossberg Network
2 1
w
+ 2
- 2
2
= 0.1 , b = 1 , b = 0 , W = 1
= 0.9 0.45 ,
T
2
1
0
0.45 0.9
2w
(18.18)
and
2
10 n
2
f (n) = ------------------2- .
1 + n
(18.19)
dn 1(t)
2 T 1
2 2
2
2
- = n 1(t) + 1 n 1(t) f (n 1(t)) + 1w a
0.1 ------------dt
2
(18.20)
n 1(t)f (n 2(t))
2
dn 2(t)
2 T 1
2 2
2
2
- = n 2(t) + 1 n 2(t) f (n 2(t)) + 2w a
0.1 ------------dt
2
(18.21)
n 2(t)f (n 1(t)) .
Contrast Enhance
Note the relationship between these equations and the Hamming and Kohonen networks. The inputs to Layer 2 are the inner products between the
2
prototype patterns (rows of the weight matrix W ) and the output of Layer
1 (normalized input pattern). The largest inner product will correspond to
the prototype pattern closest to the input pattern. Layer 2 then performs a
competition between the neurons, which tends to contrast enhance the output pattern maintaining large outputs while attenuating small outputs.
This contrast enhancement is generally milder than the winner-take-all
competition of the Hamming and Kohonen networks. In the Hamming and
Kohonen networks, the competition drives all but one of the neuron outputs to zero. The exception is the one with the largest input. In the Grossberg network, the competition maintains large values and attenuates small
values, but does not necessarily drive all small values to zero. The amount
18-18
2 T 1
2w a
n 2(t)
0.75
2 T 1
1w a
0.5
0.25
n 1(t)
0
0
0.1
0.2
0.3
0.4
0.5
t
Figure 18.17 Layer 2 Response
There are two important characteristics of this response. First, even before
the input is removed, some contrast enhancement is performed. The inputs
to Layer 2 are
2 T 1
1w a = 0.9 0.45 0.2 = 0.54 ,
0.8
(18.22)
2 T 1
2w a = 0.45 0.9 0.2 = 0.81 .
0.8
(18.23)
Therefore the second neuron has 1.5 times as much input as the first neuron. However, after 0.25 seconds the output of the second neuron is 6.34
times the output of the first neuron. The contrast between high and low has
been increased dramatically.
The second characteristic of the response is that after the input has been
set to zero, the network further enhances the contrast and stores the pattern. In Figure 18.17 we can see that after the input is removed (at 0.25
seconds) the output of the first neuron decays to zero, while the output of
the second neuron reaches a steady state value of 0.79 . This output is
maintained, even after the input is removed. (Grossberg calls this behavior
reverberation [Gross76].) It is the nonlinear feedback that enables the net-
18-19
18
18 Grossberg Network
Active
Active
Inactive
Figure 18.18 Operation of Oriented Receptive Field
18-20
f 2(n)
Stored Pattern
n2()
Comments
Linear
Perfect storage
of any pattern,
but amplifies
noise.
Slower than
Linear
Amplifies noise,
reduces contrast.
Faster than
Linear
Winner-take-all,
suppresses noise,
quantizes total
activity.
Sigmoid
Supresses
noise, contrast
enhances, not
quantized.
2
Faster-than-linear transfer functions (e.g., f (n) = n ) produce a winnertake-all competition. Only those neurons with the largest initial values are
stored; all others are driven to zero. This minimizes the effect of noise, but
quantizes the response into an all-or-nothing signal (as in the Hamming
and Kohonen networks).
A sigmoid function is faster-than-linear for small signals, approximately
linear for intermediate signals and slower-than-linear for large signals.
When a sigmoid transfer function is used in Layer 2, the pattern is contrast
enhanced; larger values are amplified, and smaller values are attenuated.
All initial neuron outputs that are less than a certain level (called the
quenching threshold by Grossberg [Gros76]) decay to zero. This merges the
noise suppression of the faster-than-linear transfer functions with the perfect storage produced by linear transfer functions.
18-21
18
18 Grossberg Network
To experiment with Layer 2 of the Grossberg network, use the Neural Network Design Demonstration Grossberg Layer 2 (nnd15gl2).
Learning Law
Long-Term Memory
The third component of the Grossberg network is the learning law for the
2
adaptive weights W . Grossberg calls these adaptive weights the long-term
2
memory (LTM). This is because the rows of W will represent patterns that
have been stored and that the network will be able to recognize. As in the
Kohonen and Hamming networks, the stored pattern that is closest to an
input pattern will produce the largest output in Layer 2. In the next subsection we will look more closely at the relationship between the Grossberg
network and the Kohonen network.
2
dw i j(t)
2
2
1
----------------- = w i j(t) + n i (t)n j (t) .
dt
(18.24)
The first term in the bracket on the right-hand side of Eq. (18.24) is a passive decay term, which we have seen in the Layer 1 and Layer 2 equations,
while the second term implements a Hebbian-type learning. Together,
these terms implement the Hebb rule with decay, which was discussed in
Chapter 13.
Recall from Chapter 13 that it is often useful to turn off learning (and for2
getting) when n i (t) is not active. This can be accomplished by the following
learning law:
2
dw i j(t)
2
2
1
----------------- = n i (t) w i j(t) + n j (t) ,
dt
(18.25)
d iw (t)
2
1
2
--------------------- = n i (t) iw (t) + n (t) ,
dt
2
(18.26)
2
where iw (t) is a vector composed of the elements of the ith row of W (see
Eq. (4.4)).
The terms on the right-hand side of Eq. (18.25) are multiplied (gated) by
2
2
n i (t) , which allows learning (and forgetting) to occur only when n i (t) is not
zero. This is the continuous-time implementation of the instar learning
rule, which we introduced in Chapter 13 (Eq. (15.32)). In the following subsection we will demonstrate the equivalence of Eq. (18.25) and Eq. (15.32).
18-22
2
+2
To illustrate the performance of the Grossberg learning law, consider a network with two neurons in each layer. The weight update equations would
be
2
dw 1 1(t)
2
2
1
------------------- = n 1(t) w 1 1(t) + n 1(t) ,
dt
(18.27)
dw 1 2(t)
2
2
1
------------------- = n 1(t) w 1 2(t) + n 2(t) ,
dt
(18.28)
dw 2 1(t)
2
2
1
------------------- = n 2(t) w 2 1(t) + n 1(t) ,
dt
(18.29)
dw 2 2(t)
2
2
1
------------------- = n 2(t) w 2 2(t) + n 2(t) ,
dt
(18.30)
where the learning rate coefficient has been set to 1 . To simplify our example, we will assume that two different input patterns are alternately
presented to the network for periods of 0.2 seconds at a time. We will also
assume that Layer 1 and Layer 2 converge very quickly, in comparison
with the convergence of the weights, so that the neuron outputs are effectively constant over the 0.2 seconds. The Layer 1 and Layer 2 outputs for
the two different input patterns will be
0.9 , n 2 = 1 ,
0.45
0
(18.31)
1
2
for pattern 2: n = 0.45 , n = 0 .
0.9
1
(18.32)
for pattern 1: n =
18
18 Grossberg Network
w 1 1(t)
0.75
w 2 2(t)
2
w 1 2(t)
0.5
0.25
w 2 1(t)
0
0
0.5
1.5
2.5
d iw (t)
2
1
2
--------------------- = n i (t) iw (t) + n (t) .
dt
(18.33)
d iw (t) iw (t + t) iw (t)
--------------------- -------------------------------------------- ,
dt
t
(18.34)
(18.35)
(Compare this equation with the instar rule that was presented in Chapter
13 in Eq. (15.33).) If we rearrange terms, this can be reduced to
iw
(18.36)
a nonzero output; call it neuron i . Then only row i of the weight matrix
will be updated:
w
i
(18.37)
18
18-25
18 Grossberg Network
Summary of Results
Basic Nonlinear Model
Leaky Integrator
dn(t)
------------ = n(t) + p(t)
dt
Leaky Integrator
1/
.
n
dn/dt = - n + p
Shunting Model
dn(t)
+
+
- ------------ = n(t) + b n(t) p n(t) + b p
dt
Input
p+
+
1/
.
n
n
0
+
pb-
18-26
b+
-b-
n(t)
Summary of Results
Layer 2
(Retina)
(Visual Cortex)
Input
STM
LTM
(Adaptive Weights)
Contrast
Enhancement
Normalization
Layer 1
Input
Layer 1
+b1
+W1
S1 x S1
S1 x 1
1/
.
n1
n1
+
-W1
S1
a1
S1 x S1
-b1
S1
dn (t)
+ 1
+ 1
- 1 - 1
1
1
1
-------------- = n (t) + b n (t) W p n (t) + b W p
dt
On-Center
18-27
1 1 0
0 0 1
0 1 1
1
- 1
W = 1 0
1 0 0
0
+ 1
W = 0 1
Off-Surround
18
18 Grossberg Network
p
b P
1
n i = ------------- p i , where p i = ----i and P =
1 + P
P
pj
j=1
Layer 2
Layer 2
+
W2
On-Center
+b2
S2 x S1
a1
S1
1/
+W2
S2 x S2
.
n2
n2
f2
+
-b2
a2
S2
-W2
Off-Surround
S2 x S2
dn (t)
+ 2
+ 2 2 2
2
2
2 1
-------------- = n (t) + b n (t) W f (n (t)) + W a
dt
2
- 2
n (t) + b W f (n (t))
18-28
Summary of Results
f 2(n)
Linear
Comments
Perfect storage
of any pattern,
but amplifies
noise.
Slower than
Linear
Faster than
Linear
Sigmoid
Amplifies noise,
reduces contrast.
Winner-take-all,
suppresses noise,
quantizes total
activity.
Supresses
noise, contrast
enhances, not
quantized.
Learning Law
2
d iw (t)
2
1
2
--------------------- = n i (t) iw (t) + n (t)
dt
(Continuous-Time Instar Learning)
18-29
18
18 Grossberg Network
Solved Problems
P18.1 Demonstrate the effect of the coefficient on the performance of
the leaky integrator, which is shown in Figure P18.1, with the input p = 1 .
Leaky Integrator
+
1/
.
n
dn/dt = - n + p
Figure P18.1 Leaky Integrator
The equation of operation for the leaky integrator is
dn(t)
------------ = n(t) + p(t) .
dt
The solution to this differential equation, for an arbitrary input p t , is
n(t) = e
1 t t
n(0) + --- e
p(t ) d .
0
1 t t
n(0) + --- e
d .
0
We want to show how this response changes as a function of . The response will be
n(t) = e
n(0) + 1 e
= e
n(0) 1 + 1 .
This response begins at n(0) , and then grows exponentially (or decays exponentially, depending on whether or not n(0) is greater than or less than
1 ), approaching the steady state response of n() = 1 . As is decreased,
t
the response becomes faster (since e
decays more quickly), while the
steady state value remains constant. Figure P18.2 illustrates the responses
for = 1 0.5 0.25 0.125 , with n(0) = 0 . Notice that the steady state value
remains 1 for each case. Only the speed of response changes.
18-30
Solved Problems
1.25
= 0.125
0.75
= 1
0.5
0.25
0
0
0.5
1.5
or
n(t + t) = n(t) + t n(t) + p(t) = 1 t n(t) + t p(t) .
ii. If we let t = 0.1 we obtain the difference equation
n(t + 0.1) = 0.9n(t) + 0.1p(t) .
If we let p t = 1 and n(0) = 0 , then we can solve for n t :
18-31
18
18 Grossberg Network
n(0) + 1 e
= 1 e .
0.75
0.5
0.25
0
0
0.25
0.5
0.75
Solved Problems
k1
p(0) + 0.9
k2
p(0.1) + + p( k 1 0.1) .
Therefore the response of the leaky integrator is a weighted average of previous inputs, p(0) p(0.1) p( k 1 0.1) . Note that the recent inputs contribute more to the response than the early inputs.
P18.3 Find the response of the shunting network shown in Figure P18.4
+
Input
p+
+
1/
.
n
n
+
pb-
11t
n(0) + e
0
18-33
11 t
10 d ,
18
18 Grossberg Network
or
n(t) = e
11t
10
11t
0.5 + ------ 1 e .
11
0.5
-0.5
-1
0
0.25
0.5
0.75
101t
101t
100
101t
0.5 + --------- 1 e
.
101
11t
P18.4 Find the response of Layer 1 of the Grossberg network for the case
+ 1
- 1
of two neurons, with b = 1 , b = 0 , = 1 and input vector
T
p = c 2c . Assume that the initial conditions are set to zero. Demonstrate the effect of c on the response.
The Layer 1 differential equations for this case are
1
dn 1(t)
1
1
1
1
-------------- = n 1(t) + 1 n 1(t) c n 1(t) 2c = 1 + 3c n 1(t) + c ,
dt
18-34
Solved Problems
dn 2(t)
1
1
1
1
-------------- = n 2(t) + 1 n 2(t) 2c n 2(t) c = 1 + 3c n 2(t) + 2c .
dt
The solutions to these equations would be
1
n 1(t) = e
1
n 2(t) = e
1 + 3c t 1
n 1(0)
1 + 3c t 1
n 2( 0)
+ e
1 + 3c t
c d ,
+ e
1 + 3c t
2c d .
N (t) =
nk (t) ,
2
k=1
n i (t)
2
-,
n i (t) = ----------2
N (t)
18-35
18
18 Grossberg Network
dn (t)
+ 2
+ 2 2 2
2
2
2 1
-------------- = n (t) + b n (t) W f (n (t)) + W a
dt
- 2 - 2 2 2
2
n (t) + b W f (n (t)) .
2 1
If the input is removed, then W a is zero. For simplicity, we will set the
- 2
inhibitory bias b to zero, and we will set all elements of the excitatory bias
+ 2
+ 2
b to b . The response of neuron i is then given by
2
dn i (t)
+ 2
2 2
2 2
2
2
2
- = n i (t) + b n i (t) f (n i (t)) n i (t) f (n k (t)) .
------------dt
ki
2
dn i (t)
+ 2 2 2
2
2
2 2
-------------- = n i (t) + b f (n i (t)) n i (t) f (n k (t)) .
dt
k = 1
F (t) =
f (n k(t)) ,
2
k=1
dn i (t)
+ 2 2 2
2
2
- = 1 + F (t) n i (t) + b f (n i (t)) .
------------dt
To get the total activity, sum this equation over i to produce
2
dN (t)
+ 2
2
2
2
--------------- = 1 + F (t) N (t) + b F (t) .
dt
This equation describes the variation in the total activity in Layer 2 over
time.
ii. The derivative of the relative activity is
18-36
Solved Problems
n i (t) d 2
1 d 2
d 2
d n i (t)
------------ = ----------- n (t) ----------------- n (t) =
- N (t) .
2 dt i
2
2
dt i
d t N 2(t)
N (t)
N (t) d t
If we then substitute our previous equations for these derivatives, we find
1
d 2
+ 2 2 2
2
2
- 1 + F (t) n i (t) + b f (n i (t))
n i (t) = ----------2
dt
N (t)
2
n i (t)
+ 2
2
2
2
- 1 + F (t) N (t) + b F (t) .
----------2
N (t)
Two terms on the right-hand side will cancel to produce
2
n i (t) + 2 2
1
d 2
+ 2 2 2
- b f (n i (t)) ----------- b F (t) ,
n i (t) = ----------2
2
dt
N (t)
N (t)
or
2
+ 2 2
d 2
b F (t) f (n i (t)) n i (t)
- ----------------- ----------- .
n i (t) = -----------------2
2
2
dt
N (t)
F (t)
N (t)
We can put this in a more useful form if we expand the terms in the brackets:
2
18
f (n i (t)) n i (t)
1
2
2 2
2
2
- f (n i (t))N (t) n i (t)F (t)
----------------- ----------- = ----------------------2
2
2
2
F (t)N (t)
F (t)
N (t)
S
1
2
2
2
2
2 2
2 2
- g (n i (t))n i (t) n k (t) n i (t) g (n k (t))n k (t)
= ----------------------2
2
F (t)N (t)
k=1
k=1
2
n i (t)
= ----------------------2
2
F (t)N (t)
k=1
where
2
f (n i (t))
2 2
.
g (n i (t)) = -----------------2
n i (t)
Combining this expression with our previous equation, we obtain
18-37
18 Grossberg Network
d 2
+ 2 2
n i (t) = b n i (t)
dt
k=1
This form of the differential equation describing the evolution of the relative outputs is very useful in demonstrating the characteristics of Layer 2,
as we will see in the next solved problem.
P18.6 Suppose that the transfer function in Layer 2 of the Grossberg network is linear.
i. Show that the relative outputs of Layer 2 will not change after the input has been removed.
ii. Under what conditions will the total output of Layer 2 decay
to zero after the input has been removed?
i. From Problem P18.5 we know that the relative outputs of Layer 2, after
the input has been removed, evolve according to
S
+ 2 2
d 2
n i (t) = b n i (t)
dt
k=1
2
f ( n) = c n .
Therefore
2
cn
f ( n)
2
g (n) = ----------- = ------- = c .
n
n
If we substitute this expression into our differential equation, we find
S
d 2
+ 2 2
n i (t) = b n i (t)
dt
n k(t) c c
= 0.
k=1
dN (t)
+ 2
2
2
2
--------------- = 1 + F (t) N (t) + b F (t) .
dt
18-38
Solved Problems
F (t) =
f (n k(t))
2
k=1
c n k(t)
2
n k(t)
2
= c
k=1
= c N (t) .
k=1
dN (t)
+ 2
+ 2
2
2
2
2
2
--------------- = 1 + c N (t) N (t) + b c N (t) = 1 b c + c N (t) N (t) .
dt
To find the equilibrium solutions of this equation, we set the derivative to
zero:
+ 2
0 = 1 b c + c N (t) N (t) .
Therefore there are two equilibrium solutions:
+ 2
b c1
2
2
N (t) = 0 or N (t) = ------------------- .
c
We want to know the conditions under which the total output will converge
to each of these possible solutions. Consider two cases:
1.
+ 2
1 b c
For this case, the derivative of the total output,
2
dN (t)
+ 2
2
2
--------------- = 1 b c + c N (t) N (t) ,
dt
2
will always be negative for positive N (t) . (Recall that the outputs of
Layer 2 are never negative.) Therefore, the total output will decay
to zero.
2
lim N (t) = 0
2.
+ 2
1 b c
2
+ 2
b c 1
2
lim N (t) = ------------------------ .
c
t
18-39
18
18 Grossberg Network
+ 2
b c 1
2
lim N (t) = ------------------------ .
c
t
Therefore, if the transfer function of Layer 2 is linear, the total output will
+ 2
+ 2
decay to zero if 1 b c . If 1 b c , then the total output will converge to
+ 2
b c 1 c . In any case, the relative outputs will remain constant.
As an example of these results, consider the following Layer 2 equations:
2
dn 1(t)
2
2
2
2
2
-------------- = n 1(t) + 1.5 n 1(t) n 1(t) n 1(t) n 2(t) ,
dt
2
dn 2(t)
2
2
2
2
2
-------------- = n 2(t) + 1.5 n 2(t) n 2(t) n 2(t) n 1(t) .
dt
+ 2
+ 2
For this case, = 1 , b = 1.5 and c = 1 , therefore 1 b c . The total output will converge to
+ 2
b c 1
1.5 1
2
lim N (t) = ------------------------ = --------------------- = 0.5 .
c
1
t
In Figure P18.6 we can see the response of Layer 2 for two different sets of
initial conditions:
2
2
n (0) = 0.75 and n (0) = 0.15 .
0.5
0.1
As expected, the total output converges to 0.5 for both initial conditions. In
addition, since the relative values of the initial conditions are the same for
the two cases, the outputs converge to the same values in both cases.
18-40
Solved Problems
1.5
N (t)
0.5
n 1(t)
2
n 2(t)
0
0
10
dw i j(t)
2
2
1
----------------- = w i j(t) + n i (t)n j (t) .
dt
If we approximate the derivative by
2
18
W q = 1 W q 1 + a q p q ,
we can see that they have the identical form.
18-41
18 Grossberg Network
Epilogue
The Grossberg network presented in this chapter was inspired by the visual system of higher vertebrates. To motivate the network, we presented a
brief description of the primary visual pathway. We also discussed some visual illusions, which help us to understand the mechanisms underlying the
visual system.
The Grossberg network is a two-layer, continuous-time competitive network, which is very similar in structure and operation to the Kohonen competitive network presented in Chapter 14. The first layer of the Grossberg
network normalizes the input pattern. It demonstrates how the visual system can use on-center/off-surround connection patterns and a shunting
model to implement an automatic gain control, which normalizes total activity.
The second layer of the Grossberg network performs a competition, which
contrast enhances the output pattern and stores it in short-term memory.
It uses nonlinear feedback and the on-center/off-surround connection pattern to produce the competition and the storage. The choice of the transfer
function and the feedback connection pattern determines the degree of
competition (e.g., winner-take-all, mild contrast enhancement, or no
change in the pattern).
The adaptive weights in the Grossberg network use an instar learning rule,
which stores prototype patterns in long-term memory. When a winnertake-all competition is performed in the second layer, this learning rule is
equivalent to the Kohonen learning rule used in Chapter 14.
As with the Kohonen network, one key problem of the Grossberg network
is the stability of learning; as more inputs are applied to the network, the
weight matrix may never converge. This problem was discussed extensively in Chapter 14. In Chapter 16 we will present a class of networks that is
designed to overcome this difficulty: the Adaptive Resonance Theory (ART)
networks. The ART networks are direct descendents of the Grossberg network presented in this chapter.
Another problem with the Grossberg network, which we have not discussed
in this chapter, is the stability of the differential equations that implement
the network. In Layer 2, for example, we have a set of differential equations
with nonlinear feedback. Can we make some general statement about the
stability of such systems? Chapter 17 will present a comprehensive discussion of this problem.
18-42
Further Reading
Further Reading
[GrMi89]
S. Grossberg, E. Mingolla and D. Todorovic, A neural network architecture for preattentive vision, IEEE Transactions on Biomedical Engineering, vol. 36, no. 1, pp. 6584,
1989.
The objective of this paper is to develop a neural network
for general purpose preattentive vision. The network consists of two main subsystems: a boundary contour system
and a feature contour system.
[Gros76]
S. Grossberg, Adaptive pattern classification and universal recoding: I. Parallel development and coding of neural
feature detectors, Biological Cybernetics, vol. 23, pp. 121
134, 1976.
Grossberg describes a continuous-time competitive network, inspired by the developmental physiology of the visual cortex. The structure of this network forms the
foundation for other important networks.
[Gros82]
[Hube88]
[vanT75]
18-43
18
18 Grossberg Network
[vond73]
C. von der Malsburg, Self-organization of orientation sensitive cells in the striate cortex, Kybernetic, vol. 14, pp. 85
100, 1973.
Malsbergs is one of the first papers to present a self-organizing feature map neural network. The network is a model
for the visual cortex of higher vertebrates. This paper influenced the work of Kohonen and Grossberg on feature maps.
18-44
Exercises
Exercises
E18.1 Consider the leaky integrator shown in Figure E18.1.
i. Find the response n t if = 1 , n 0 = 1 and p t = 0.5 .
ii. Find the response n t if = 1 , n 0 = 1 and p t = 2 .
iii. Find the response n t if = 4 , n 0 = 1 and p t = 2 .
2+2
ans =
4
Leaky Integrator
+
-
1/
.
n
dn/dt = - n + p
Figure E18.1 Leaky Integrator
E18.2 Consider the shunting network shown in Figure E18.2.
i. Find and sketch the response of the shunting network if = 2 ,
+
+
b = 3 , b = 1 , p = 0 , p = 5 and n(0) = 1 .
ii. Find and sketch the response of the shunting network if = 2 ,
+
+
b = 3 , b = 1 , p = 0 , p = 50 and n(0) = 1 .
iii. Find and sketch the response of the shunting network if = 2 ,
+
+
b = 3 , b = 1 , p = 50 , p = 0 and n(0) = 1 .
iv. Find and sketch the response of the shunting network if = 5 ,
+
+
b = 2 , b = 6 , p = 5 , p = 0 and n(0) = 0 .
v. Find and sketch the response of the shunting network if = 5 ,
+
+
b = 2 , b = 6 , p = 0 , p = 5 and n(0) = 0 .
vi. Find and sketch the response of the shunting network if = 0.25 ,
+
+
b = 4 , b = 2 , p = 2 , p = 2 and n(0) = 0 .
vii. Find and sketch the response of the shunting network if = 0.25 ,
+
+
b = 4 , b = 2 , p = 2 , p = 4 and n(0) = 0 .
18-45
18
18 Grossberg Network
2+2
ans =
4
Input
p+
+
1/
.
n
n
+
pb-
18-46
Exercises
E18.6 Find the differential equation that describes the variation in the total output of Layer 1,
S
1
N (t) =
ni (t) .
1
i=1
E18.8 Suppose that the transfer function for Layer 2 of the Grossberg network is
+ 2
2
2
f n = c n , and = 1 , b = 1 .
i. Using the results of Problem P18.5, show that, after the inputs have
been removed, all of the relative outputs of Layer 2 will decay to zero, except the one with the largest initial condition (winner-take-all
competition).
2
ii. For what values of c will the total output N (t) have a nonzero stable point (steady state value)?
iii. If the condition of part (ii) is satisfied, what will be the steady state
2
2
value of N (t) ? Will this depend on the initial condition N (0) ?
2+2
ans =
4
2+2
ans =
4
18
18 Grossberg Network
puts are effectively constant over the 0.2 seconds. The Layer 2 and Layer 1
outputs for the two different input patterns will be:
1
2
for pattern 1: n = 0.8 , n = 1 ,
0.2
0
1
2
for pattern 2: n = 0.5 , n = 0 .
0.5
1
2+2
ans =
4
E18.10 Repeat Exercise E18.9, but use the Hebb rule with decay, Eq. (18.24), instead of the instar learning of Eq. (18.25). Explain the differences between
the two responses.
18-48
Objectives
19
19-1
19-2
19-2
Layer 1
19-4
19-6
Layer 2
19-10
Orienting Subsystem
19-13
19-16
Subset/Superset Dilemma
19-17
Learning Law
19-18
19-20
19-21
Initialization
19-21
Algorithm
19-21
19-23
Summary of Results
19-24
Solved Problems
19-29
Epilogue
19-44
Further Reading
19-45
Exercises
19-47
19
Objectives
In Chapter 16 and Chapter 18 we learned that one key problem of competitive networks is the stability of learning. There is no guarantee that, as
more inputs are applied to the network, the weight matrix will eventually
converge. In this chapter we will present a modified type of competitive
learning, called adaptive resonance theory (ART), which is designed to
overcome the problem of learning stability.
19-1
19-2
Layer 1
Layer 2
Gain Control
Input
Expectation
Reset
Orienting
Subsystem
Figure 19.1 Basic ART Architecture
Recall from Chapter 18 that the L1-L2 connections of the Grossberg network are instars, which perform a clustering (or categorization) operation.
When an input pattern is presented to the network, it is multiplied (after
normalization) by the L1-L2 weight matrix. Then, a competition is performed at Layer 2 to determine which row of the weight matrix is closest to
the input vector. That row is then moved toward the input vector. After
learning is complete, each row of the L1-L2 weight matrix is a prototype
pattern, which represents a cluster (or category) of input vectors.
In the ART networks, learning also occurs in a set of feedback connections
from Layer 2 to Layer 1. These connections are outstars (see Chapter 15),
which perform pattern recall. When a node in Layer 2 is activated, this reproduces a prototype pattern (the expectation) at Layer 1. Layer 1 then
performs a comparison between the expectation and the input pattern.
When the expectation and the input pattern are not closely matched, the
orienting subsystem causes a reset in Layer 2. This reset disables the current winning neuron, and the current expectation is removed. A new competition is then performed in Layer 2, while the previous winning neuron
is disabled. The new winning neuron in Layer 2 projects a new expectation
to Layer 1, through the L2-L1 connections. This process continues until the
L2-L1 expectation provides a close enough match to the input pattern.
In the following sections we will investigate each of the subsystems of the
ART system, as they apply to one particular ART network ART1
([CaGr87a]). We will first describe the differential equations that describe
the subsystem operations. Then we will derive the steady state responses
of each subsystem. Finally, we will summarize the overall operation of the
ART1 system.
19-3
19
Layer 1
The main purpose of Layer 1 is to compare the input pattern with the expectation pattern from Layer 2. (Both patterns are binary in ART1.) If the
patterns are not closely matched, the orienting subsystem will cause a reset in Layer 2. If the patterns are close enough, Layer 1 combines the expectation and the input to form a new prototype pattern.
Layer 1 of the ART1 network, which is displayed in Figure 19.2, is very
similar to Layer 1 of the Grossberg network (see Figure 18.14). The differences occur at the excitatory and inhibitory inputs to the shunting model.
For the ART1 network, no normalization is performed at Layer 1; therefore
we dont have the on-center/off-surround connections from the input vector.
The excitatory input to Layer 1 of ART1 consists of a combination of the input pattern and the L1-L2 expectation. The inhibitory input consists of the
gain control signal from Layer 2. In the following we will explain how these
inputs work together.
Input
Layer 1
+
Expectation
+b1
S1 x 1
1/
.
n1
-b1
S1 x S2
n1
+
S1
a2
W2:1
f1
a1
S1
Gain Control
-W1
a2
S1 x S2
dn (t)
+ 1
1
1
2:1 2
-------------- = n (t) + b n (t) p + W a t
dt
1
- 1
n (t) + b W a t
and the output of Layer 1 is computed
19-4
(19.1)
Layer 1
a = hardlim n ,
(19.2)
1, n 0
+
.
hardlim n =
0, n 0
(19.3)
where
2:1 2
2:1 2
2:1
2:1
2:1
a = w 2:1
w S2
1 w2 wj
0
0
2:1
= wj ,
(19.4)
1
2:1
2:1
2:1
2:1
2:1 2
a = p + wj .
(19.5)
Therefore the excitatory input to Layer 1 is the sum of the input pattern
and the L2-L1 expectation. Each column of the L2-L1 matrix represents a
different expectation (prototype pattern). Layer 1 combines the input pattern with the expectation using an AND operation, as we will see later.
-
1 1 1
1
- 1
.
W = 1 1
19
(19.6)
1 1 1
Therefore, the inhibitory input to each neuron in Layer 1 is the sum of all
of the outputs of Layer 2. Since we will be using a winner-take-all competition in Layer 2, whenever Layer 2 is active there will be one, and only one,
2
nonzero element of a after the competition. Therefore the gain control input to Layer 1 will be one when Layer 2 is active, and zero when Layer 2 is
inactive (all neurons having zero output). The purpose of this gain control
will become apparent as we analyze the steady state behavior of Layer 1.
19-5
S
S
1
dn i
+ 1
- 1
1
1
2:1 2
1
2
-------- = n i + b n i p i + w i j a j n i + b a j ,
dt
j=1
j=1
(19.7)
Consider first the case where Layer 2 is inactive. Since each a j = 0 , Eq.
(19.7) simplifies to
1
dn
+ 1
1
1
-------i- = n i + b n i p i .
dt
(19.8)
+ 1
+ 1
0 = n i + b n i p i = 1 + p i n i + b p i .
(19.9)
b p
1
n i = -------------i .
1 + pi
1
(19.10)
1
+ 1
a = p.
(19.11)
19-6
Layer 1
dn
+ 1
- 1
1
1
2:1
1
-------i- = n i + b n i p i + w i j n i + b .
dt
(19.12)
= 1 + pi +
2:1
w i j
2:1
- 1
0 = n i + b n i p i + w i j n i + b
+
1
1 n i
+ 1
+ b pi +
2:1
w i j
(19.13)
- 1
b .
- 1
2:1
b p i + w i j b
1
-.
n i = -------------------------------------------2:1
2 + p i + w i j
(19.14)
Recall that Layer 1 should combine the input vector with the expectation
2:1
from Layer 2 (represented by w j ). Since we are dealing with binary patterns (both the input and the expectation), we will use a logical AND oper1
ation to combine the two vectors. In other words, we want n i to be less than
2:1
1
zero when either p i or w i j is equal to zero, and we want n i to be greater
2:1
than zero when both p i and w i j are equal to one.
If we apply these conditions to Eq. (19.14), we obtain the following equations:
+ 1
- 1
b 2 b 0 ,
+ 1
- 1
b b 0,
(19.15)
(19.16)
- 1
+ 1
b 2 b b .
+ 1
(19.17)
- 1
2:1
a = p wj ,
(19.18)
2:1
- 1
b p i + w i j b .
19-7
(19.19)
19
- 1
The term b is multiplied by the gain control term, which in this case is 1.
If this term did not exist, then Eq. (19.19) would be greater than zero (and
1
2:1
therefore n i would be greater than zero) whenever either p i or w i j was
greater than zero. This would represent an OR operation, rather than an
AND operation. As we will see when we discuss the orienting subsystem, it
is critical that Layer 1 perform an AND operation.
When Layer 2 is inactive, the gain control term is zero. This is necessary
because in that case we want Layer 1 to respond to the input pattern alone,
since no expectation will be activated by Layer 2.
To summarize the steady state operation of Layer 1:
2
a = p.
If Layer 2 is active (i.e., one
1
2
aj
(19.20)
= 1 ),
2:1
a = p wj .
2
+2
(19.21)
- 1
(19.22)
Assume also that we have two neurons in Layer 2, two elements in the input vector and the following weight matrix and input:
W
2:1
= 1 1 and p = 0 .
1
0 1
(19.23)
If we take the case where Layer 2 is active, and neuron 2 of Layer 2 wins
the competition, the equations of operation of Layer 1 are
1
dn 1
1
1
2:1
1
0.1 -------- = n 1 + 1 n 1 p 1 + w 1 2 n 1 + 1.5
dt
1
(19.24)
1
= n 1 + 1 n 1 0 + 1 n 1 + 1.5 = 3n 1 0.5
1
dn
1
1
2:1
1
0.1 -------2- = n 2 + 1 n 2 p 2 + w 2 2 n 2 + 1.5
dt
1
(19.25)
1
= n 2 + 1 n 2 1 + 1 n 2 + 1.5 = 4n 2 + 0.5 .
These can be simplified to obtain
19-8
Layer 1
dn 1
1
-------- = 30n 1 5 ,
dt
(19.26)
dn 2
1
-------- = 40n 2 + 5 .
dt
(19.27)
In this simple case we can find closed-form solutions for these equations. If
we assume that both neurons start with zero initial conditions, the solutions are
1
1
30t
n 1 t = --- 1 e ,
6
(19.28)
1
1
40t
n 2 t = --- 1 e .
8
(19.29)
n2 t
0.1
-0.1
n1 t
-0.2
0
0.05
0.1
0.15
0.2
t
Figure 19.3 Response of Layer 1
1
n1 t
Note that
converges to a negative value, and n 2 t converges to a pos1
1
itive value. Therefore, a 1 t converges to 0, and a 2 t converges to 1 (recall
+
that the transfer function for Layer 1 is hardlim ). This agrees with our
steady state analysis (see Eq. (19.21)), since
2:1
p w2
1
= 0 1 = 0 = a .
1
1
1
(19.30)
To experiment with Layer 1 of the ART1 network, use the Neural Network
Design Demonstration ART1 Layer 1 (nnd16al1).
19-9
19
Layer 2
Layer 2 of the ART1 network is almost identical to Layer 2 of the Grossberg
network of Chapter 18. Its main purpose is to contrast enhance its output
pattern. For our implementation of the ART1 network, the contrast enhancement will be a winner-take-all competition, so only the neuron that
receives the largest input will have a nonzero output.
.
n
a0
n
There is one major difference between the second layers of the Grossberg
and the ART1 networks. Layer 2 of the ART1 network uses an integrator
that can be reset. In this type of integrator, whose symbol is shown in the
0
left margin, any positive outputs are reset to zero whenever the a signal
becomes positive. The outputs that are reset remain inhibited for a long period of time, so that they cannot be driven above zero. (By a long period
of time we mean until an adequate match has occurred and the weights
have been updated.)
In the original ART1 paper, Carpenter and Grossberg suggested that the
reset mechanism could be implemented using a gated dipole field
[CaGr87]. They later suggested a more sophisticated biological model, using chemical neurotransmitters, in their ART3 architecture [CaGr90]. For
our purposes we will not be concerned with the specific biological implementation.
Figure 19.4 displays the complete Layer 2 of the ART1 network. Again, it
is almost identical to Layer 2 of the Grossberg network (see Figure 18.16),
0
with the primary exception of the resetable integrator. The reset signal, a ,
is the output of the orienting subsystem, which we will discuss in the next
section. It generates a reset whenever there is a mismatch at Layer 1 between the input signal and the L2-L1 expectation.
One other small difference between Layer 2 of the ART1 network and Layer 2 of the Grossberg network is that two transfer functions are used in
2
2
ART1. The transfer function f n is used for the on-center/off-surround
feedback connections, while the output of Layer 2 is computed as
2
+
2
a = hardlim n . The reason for the second transfer function is that we
want the output of Layer 2 to be a binary signal.
19-10
Layer 2
Layer 2
W1:2
On-Center
a1
+W2
+b2
S2 x S1
1/
S2 x S2
+
-
.
n2
f2
n2
a2
+
a0
-b2
Reset
S2
-W2
Off-Surround
S2 x S2
dn (t)
+ 2
+ 2 2 2
2
2
1:2 1
-------------- = n (t) + b n (t) W f (n (t)) + W a
dt
2
- 2
(19.31)
n (t) + b W f (n (t)) .
+
1:2 1
The inhibitory input to the shunting model is W f (n (t)) , where W provides off-surround feedback connections (identical to Layers 1 and 2 of the
Grossberg network Eq. (18.7)).
19-11
19
2
+2
w
- 2
1:2
= 0.1 , b = 1 , b = 1 , W = 1
= 0.5 0.5 , (19.32)
1:2 T
1
1
1 0
2w
+ 2
and
10 n 2 ,
2
f ( n) =
0,
n0
n0
(19.33)
dn 1(t)
1:2 T 1
2 2
2
2
- = n 1(t) + 1 n 1(t) f (n 1(t)) + 1w a
0.1 ------------dt
2
(19.34)
n 1(t) + 1 f (n 2(t))
2
dn 2(t)
1:2 T 1
2
2
2 2
- = n 2(t) + 1 n 2(t) f (n 2(t)) + 2w a
0.1 ------------dt
2
(19.35)
n 2(t) + 1 f (n 1(t)) .
This is identical in form to the Grossberg Layer 2 example in Chapter 18
- 2
2
(see Eq. (18.20) and Eq. (18.21)), except that b = 1 . This will allow n 1(t)
2
and n 2(t) to range between -1 and +1.
The inputs to Layer 2 are the inner products of the prototype patterns
1:2
(rows of the weight matrix W ) with the output of Layer 1. (The rows of
this weight matrix are normalized, as will be explained in a later section.)
The largest inner product will correspond to the prototype pattern that is
closest to the output of Layer 1. Layer 2 then performs a competition be2
tween the neurons. The transfer function f (n) is chosen to be a faster-thanlinear transfer function (see Chapter 18, page 18-20, for a discussion of the
2
effect of f (n) ). This choice will force the neuron with largest input to have
a positive n , and the other neuron to have a negative n (with appropriate
choice of network parameters). After the competition, one neuron output
will be 1, and the other neuron output will be zero, since we are using the
+
hardlim transfer function to compute the layer output.
Figure 19.5 illustrates the response of Layer 2 when the input vector is
T
1
1:2
1
a = 1 0 . The second row of W has a larger inner product with a
19-12
Orienting Subsystem
than the second row, therefore neuron 2 wins the competition. At steady
2
2
state, n 2(t) has a positive value, and n 1(t) has a negative value. The steady
state Layer 2 output will then be
2
a = 0 .
1
(19.36)
1:2 T 1
2w a
n2 t
0.5
1:2 T 1
1w a
0
-0.5
n1 t
-1
0
0.05
0.1
0.15
0.2
t
Figure 19.5 Response of Layer 2
We can summarize the steady state operation of Layer 2 as follows:
2
ai
1,
=
0,
1:2 T 1
1:2 T 1
if iw a = max jw a
otherwise
(19.37)
To experiment with Layer 2 of the ART1 network, use the Neural Network
Design Demonstration ART1 Layer 2 (nnd16al2).
Orienting Subsystem
One of the key elements of the ART architecture is the Orienting Subsystem. Its purpose is to determine if there is a sufficient match between
the L2-L1 expectation and the input pattern. When there is not enough of
a match, the Orienting Subsystem should send a reset signal to Layer 2.
The reset signal will cause a long-lasting inhibition of the previous winning
neuron, and thus allow another neuron to win the competition.
Figure 19.6 displays the Orienting Subsystem.
19-13
19
Orienting Subsystem
+b0
+W0
1 x S1
1/
.
n0
n0
1 x S1
-b0
a0
f0
Reset
-W0
a1
dn (t)
+ 0
+ 0
- 0 - 0 1
0
0
0
-------------- = n (t) + b n (t) W p n (t) + b W a .
dt
+
(19.38)
W = .
(19.39)
W p = p = pj = p ,
0
(19.40)
j=1
0 1
W = .
(19.41)
W a = a = aj t = a
0 1
j=1
19-14
1 2
(19.42)
Orienting Subsystem
Whenever the excitatory input is larger than the inhibitory input, the Orienting Subsystem will be driven on. Consider the following steady state operation:
0
+ 0
- 0
0 = n + b n p n + b a
= 1 + p
+ a
1 2
+ 0
1 2
- 0
n + b p b a
(19.43)
1 2
1 2
- 0
b p b a
n = -----------------------------------------------------------.
2
1 2
1 + p + a
0
+ 0
- 0
Let b = b = 1 , then n 0 if p
1 2
(19.44)
0 , or in other words:
1 2
0
n 0 if -----------2- --- = .
p
Vigilance
(19.45)
2:1
(19.46)
dn (t)
0
0
0.1 -------------- = n (t) + 1 n (t) 3 p 1 + p 2
dt
0
n (t) + 1 4 a 1 + a 2
19-15
(19.47)
19
or
0
dn (t)
0
-------------- = 110n (t) + 20 .
dt
(19.48)
The response is plotted in Figure 19.7. In this case a reset signal will be
0
sent to Layer 2, since n t is positive. In this example, because the vigilance parameter is set to = 0.75 , and p has only two elements, we will
1
have a reset whenever p and a are not identical. (If the vigilance param1
eter were set to = 0.25 , we would not have had a reset for the p and a
1 2
2
of Eq. (19.46), since a p = 1 2 .)
0.2
n t
0.1
-0.1
-0.2
0
0.05
0.1
0.15
0.2
t
Figure 19.7 Response of the Orienting Subsystem
The steady state operation of the Orienting Subsystem can be summarized
as follows:
1,
a =
0,
1 2
if a p
.
otherwise
(19.49)
To experiment with the Orienting Subsystem, use the Neural Network Design Demonstration Orienting Subsystem (nnd16os).
L2 instar learning law, and in the following section we will present the L2L1 outstar learning law.
Resonance
We should note that the L1-L2 connections and the L2-L1 connections are
updated at the same time. Whenever the input pattern and the expectation
have an adequate match, as determined by the Orienting Subsystem, both
1:2
2:1
W and W are adapted. This process of matching, and subsequent adaptation, is referred to as resonance, hence the name adaptive resonance
theory.
Subset/Superset Dilemma
The learning in the L1-L2 connections of the ART1 network is very close to
the learning in the Grossberg network of Chapter 18, with one major difference. In the Grossberg network, the input patterns are normalized in
Layer 1, and therefore all of the prototype patterns will have the same
length. In the ART1 network no normalization takes place in Layer 1.
Therefore a problem can occur when one prototype pattern is a subset of
another. For example, suppose that the L1-L2 connection matrix is
W
1:2
= 1 1 0 ,
1 1 1
(19.50)
1w
We say that 1w
a 1.
1:2
1:2
1
1
1:2
= 1 and 2w = 1 .
0
1
is a subset of 2w
1:2
, since 2w
1:2
(19.51)
has a 1 wherever 1w
1:2
has
19
(19.52)
19-17
(19.53)
Both prototype vectors have the same inner product with a , even though
1
the first prototype is identical to a and the second prototype is not. This is
called the subset/superset dilemma.
One solution to the subset/superset dilemma is to normalize the prototype
patterns. That is, when a prototype pattern has a large number of nonzero
entries, the magnitude of each entry should be reduced. For example, using
our preceding problem, we could modify the L1-L2 matrix as follows:
1:2
1
--= 2
1
--3
1
--2
1
--3
0
.
(19.54)
1
--3
1
--a = 2
1
--3
1:2 1
1
--2
1
--3
0 1
1
1 = 2 .
--1
--- 0
3
3
(19.55)
Now we have the desired result: the first prototype has the largest inner
1
product with a . The first neuron in Layer 2 will be activated.
In the Grossberg network of Chapter 18 we obtained normalized prototype
patterns by normalizing the input patterns in Layer 1. In the ART1 network we will normalize the prototype patterns by using an on-center/offsurround competition in the L1-L2 learning law.
Learning Law
The learning law for W
1:2
is
1:2
d iw t
1
+
1:2
+
2
------------------------= a i t b iw t W a t
dt
1:2
(19.56)
1
iw t + b W a t ,
where
19-18
0 0 1
1
0
1 0 0
0 1 1
1
+
+
0 and .
b = 1 , b = 0 , W = 0 1
W = 1 0
1 1 0
(19.57)
Fast Learning
dw i j t
2
1:2
1
1:2
1
------------------= a i t 1 w i j t a j t w i j t a k t .
dt
(19.58)
kj
If we assume that neuron i is active in Layer 2 ( a i t = 1 ) and set the derivative to zero in Eq. (19.58), we see that
1:2
1:2
0 = 1 w i j a j w i j
ak
(19.59)
kj
1:2
To find the steady state value of w i j , we will consider two cases. First, as1
sume that a j = 1 . Then we have
1:2
1:2
0 = 1 w i j w i j a
1 2
1 = + a
1 2
1:2
1 w i j + ,
(19.60)
or
1:2
-.
w i j = ----------------------------1 2
+ a 1
S
(Note that
19
(19.61)
ak
= a
1 2
k=1
1
0 = w i j a
or
19-19
1 2
(19.62)
1:2
w i j = 0 .
(19.63)
1:2
a
= -----------------------------,
1 2
+ a 1
(19.64)
2:1
2:1
d wj t
1
2
2:1
------------------------ = aj t wj t + a t .
dt
(19.65)
2:1
0 = w j + a , or w j
2:1
= a .
(19.66)
1
19-20
tern is modified to incorporate the current input pattern (if there is a close
enough match).
1:2
2:1
Keep in mind that W and W are updated at the same time. When neuron j of Layer 2 is active and there is a sufficient match between the expectation and the input pattern (which indicates a resonance condition), then
1:2
2:1
row j of W and column j of W are adapted. In fast learning, column
2:1
1
1:2
j of W is set to a , while row j of W is set to a normalized version of
1
a .
Initialization
The ART1 algorithm begins with an initialization of the weight matrices
1:2
2:1
2:1
W and W . The initial W matrix is set to all 1s. Thus, the first time
a new neuron in Layer 2 wins a competition, resonance will occur, since
2:1
1
1 2
2
a = p w j = p and therefore a p = 1 . This means that any
2:1
untrained column in W is effectively a blank slate and will cause a
match with any input pattern.
1:2
Since the rows of the W matrix should be normalized versions of the col2:1
1:2
umns of W , every element of the initial W matrix is set to
1
+ S 1 .
Algorithm
After initialization, the ART1 algorithm proceeds as follows:
1. First, we present an input pattern to the network. Since Layer 2 is not
2
active on initialization (i.e., each a j = 0 ), the output of Layer 1 is (Eq.
(19.20))
1
a = p.
(19.67)
1:2 1
a ,
(19.68)
and activate the neuron in Layer 2 with the largest input (Eq. (19.37)):
19-21
19
2
ai
1,
=
0,
1:2 T 1
1:2 T 1
if iw a = max kw a
otherwise
(19.69)
In case of a tie, the neuron with the smallest index is declared the winner.
3. We then compute the L2-L1 expectation (where we assume neuron j of
Layer 2 is activated):
2:1
2:1 2
a = wj .
(19.70)
4. Now that Layer 2 is active, we adjust the Layer 1 output to include the
L2-L1 expectation (Eq. (19.21)):
1
2:1
a = p wj .
(19.71)
5. Next, the Orienting Subsystem determines the degree of match between the expectation and the input pattern (Eq. (19.49)):
1,
a =
0,
1 2
if a p
.
otherwise
(19.72)
1:2
1:2
(Eq.
a
= -----------------------------.
1 2
+ a 1
2:1
(19.73)
(Eq. (19.66)):
1
= a .
(19.74)
To experiment with the ART1 algorithm, use the Neural Network Design
Demonstration ART1 (nnd16a1).
19-23
19
Summary of Results
Basic ART Architecture
Layer 1
Layer 2
Gain Control
Input
Expectation
Reset
Orienting
Subsystem
Layer 1
+
Expectation
+b1
S1 x 1
1/
.
n1
-b1
Gain Control
S1 x S2
n1
+
S1
a2
W2:1
f1
a1
S1
+
-W1
a2
S1 x S2
Summary of Results
Layer 1 Equation
1
dn (t)
+ 1
- 1 - 1 2
1
1
2:1 2
1
-------------- = n (t) + b n (t) p + W a t n (t) + b W a t
dt
Steady State Operation
2
2:1
ART1 Layer 2
Layer 2
W
On-Center
1:2
+b2
S2 x S1
a1
1/
+W2
S2 x S2
.
n2
f2
n2
a2
+
a0
-b2
Reset
Off-Surround
-W2
S2
S2 x S2
dn (t)
+ 2
+ 2 2 2
- 2 - 2 2 2
2
2
1:2 1
2
-------------- = n (t) + b n (t) W f (n (t)) + W a n (t) + b W f (n (t))
dt
Steady State Operation
2
ai
1,
=
0,
19-25
1:2 T 1
1:2 T 1
if iw a = max jw a
otherwise
19
Orienting Subsystem
Orienting Subsystem
+b0
+W0
1 x S1
1/
.
n0
n0
Reset
-W0
a1
1 x S1
a0
f0
1
-b0
dn (t)
+ 0
+ 0
- 0 - 0 1
0
0
0
-------------- = n (t) + b n (t) W p n (t) + b W a
dt
+
+ 0
- 0
where W = , W = , b = b = 1
Steady State Operation
1,
a =
0,
1 2
if a p
otherwise
d iw t
1
1
+
1:2
+
1:2
2
------------------------= a i t b iw t W a t iw t + b W a t
dt
0 0 1
1 1 0
19-26
0 1 1
1
W = 1 0
1 0 0
0
+
W = 0 1
0
b = 0
1
+
b = 1
Summary of Results
1:2
a
= ----------------------------- (Neuron i in Layer 2 Active)
1 2
+ a 1
d wj t
2
2:1
1
------------------------ = aj t wj t + a t
dt
Steady State Operation (Fast Learning)
2:1
wj
2:1
1:2
matrix is set to + S 1 .
Algorithm
1. First, we present an input pattern to the network. Since Layer 2 is not
2
active on initialization (i.e., each a j = 0 ), the output of Layer 1 is
1
a = p.
2. Next, we compute the input to Layer 2,
1:2 1
W a ,
and activate the neuron in Layer 2 with the largest input:
2
ai
1,
=
0,
1:2 T 1
1:2 T 1
if iw a = max kw a
otherwise
In case of a tie, the neuron with the smallest index is declared the winner.
3. We then compute the L2-L1 expectation (where we assume neuron j of
Layer 2 is activated):
2:1 2
2:1
W a = wj .
19-27
19
4. Now that Layer 2 is active, we adjust the Layer 1 output to include the
L2-L1 expectation:
2:1
a = p wj .
5. Next, the Orienting Subsystem determines the degree of match between the expectation and the input pattern:
1,
0
a =
0,
1 2
if a p
.
otherwise
1:2
1:2
a
= -----------------------------.
1 2
+ a 1
2:1
2:1
wj
:
1
= a .
19-28
Solved Problems
Solved Problems
P19.1 Consider Layer 1 of the ART1 network with the following parameters:
+ 1
= 0.01
b = 2
- 1
b = 3.
p = 1 .
1
= 0 1
1 1
2:1
dn
1
1
2:1
1
0.01 -------1- = n 1 + 2 n 1 p 1 + w 1 1 n 1 + 3
dt
1
= n 1 + 2 n 1 1 + 0 n 1 + 3 = 3n 1 1
1
dn
1
1
2:1
1
0.01 -------2- = n 2 + 2 n 2 p 2 + w 2 1 n 2 + 3
dt
1
= n 2 + 2 n 2 1 + 1 n 2 + 3 = 4n 2 + 1 .
These can be simplified to obtain
1
dn 1
1
-------- = 300n 1 100 ,
dt
1
dn 2
1
-------- = 400n 2 + 100 .
dt
If we assume that both neurons start with zero initial condition, the solutions are
19-29
19
1
300t
1
n 1 t = --- 1 e
,
3
1
1
400t
n 2 t = --- 1 e
.
4
These are displayed in Figure P19.1.
0.4
n2 t
0.2
-0.2
n1 t
-0.4
0
0.005
0.01
0.015
0.02
t
Figure P19.1 Response of Layer 1
1
p w1
1
= 1 0 = 0 = a .
1
1
1
(19.75)
P19.2 Consider Layer 2 of the ART1 network with the following parameters:
= 0.1
b = 2
2
+ 2
b = 2
2
- 2
1:2 T
1:2
1w
1:2 T
2w
and
10 n 2
2
f ( n) =
0
19-30
n0
n0
= 0.5 0.5
1 0
Solved Problems
dn 1(t)
1:2 T 1
2 2
2
2
- = n 1(t) + 2 n 1(t) f (n 1(t)) + 1w a
0.1 ------------dt
2
n 1(t) + 2 f (n 2(t)) ,
2
dn 2(t)
1:2 T 1
2 2
2
2
- = n 2(t) + 2 n 2(t) f (n 2(t)) + 2w a
0.1 ------------dt
2
n 2(t) + 2 f (n 1(t)) .
Figure P19.2 illustrates the response of Layer 2 when the input vector is
T
1
1:2
1
a = 1 0 . The second row of W has a larger inner product with a
than the first row, therefore neuron 2 wins the competition.
2
n2 t
1:2 T 1
2w a
19
1:2 T 1
1w a
-1
n1 t
-2
0
0.05
0.1
0.15
0.2
19-31
If we compare Figure P19.2 with Figure 19.5, we can see that the bias value
has three effects. First, the speed of response is increased; the neuron outputs move more quickly to their steady state values. Second, the range of
the response is increased from [ 1, 1] to [ 2, 2] . (Recall from Chapter 18
+
that for the shunting model the upper limit will be the excitatory bias b .
The lower limit will be the inhibitory bias b .) Third, the neuron responses
move closer to the upper and lower limits.
2
ii. At steady state, n 1(t) has a positive value, and n 2(t) has a negative value. The steady state Layer 2 output will then be
2
a = 1 .
0
This agrees with the desired steady state response characteristics of Layer
2:
2
ai
1,
=
0,
1:2 T 1
1:2 T 1
if iw a = max jw a
otherwise
P19.3 Consider the Orienting Subsystem of the ART1 network with the
following parameters:
= 0.1
= 0.5
= 2
( = 0.25 )
+ 0
- 0
b = b = 0.5 .
1
1
a = 0 .
1
0
dn (t)
0
0
0.1 -------------- = n (t) + 0.5 n (t) 0.5 p 1 + p 2 + p 3
dt
0
n (t) + 0.5 2 a 1 + a 2 + a 3
or
19-32
Solved Problems
dn (t)
0
-------------- = 65n (t) 12.5 .
dt
The response is then
0
n t = 0.1923 1 e
65t
0.15
n t
-0.15
-0.3
0
0.05
0.1
0.15
0.2
t
Figure P19.3 Response of the Orienting Subsystem
ii. The steady state operation of the Orienting Subsystem can be summarized as follows:
1,
a =
0,
1 2
if a p
.
otherwise
1 2
1
0
1
1
1
1
2
= --- = 0.25 .
3
19-33
19
P19.4 Show that the learning equation for the L2-L1 connections is
equivalent to the outstar equation described in Chapter 15.
The L2-L1 learning law (Eq. (19.65)) is
2:1
d wj t
2
2:1
1
------------------------ = aj t wj t + a t .
dt
If we approximate the derivative by
2:1
2:1
2:1
d w j (t) w j (t + t) w j (t)
----------------------- ------------------------------------------------- ,
dt
t
then we can rewrite Eq. (19.65) as
2:1
2:1
2:1
2:1
1 1 1
0.5 0.5 0.5
1:2
= 1 1 1 , W = 0.5 0.5 0.5 .
1 1 1
0.5 0.5 0.5
19-34
Solved Problems
2:1
a = p1 w1
0
1
0
= 1 1 = 1 .
0
1
0
5. Next, the Orienting Subsystem determines the degree of match between the expectation and the input pattern:
a
1 2
p1
1
0
= --- = 0.4 , therefore a = 0 (no reset).
1
1w
1:2
1:2
0
0 1 0
1
2a
1
1:2
,
a
W
= ----------------------------=
=
=
1
0.5 0.5 0.5 .
1 2
2+ a 1
0
0.5 0.5 0.5
8. Update column 1 of W
19-35
2:1
19
2:1
w1
0
0 1 1
1
2:1
= a = 1 ,W = 1 1 1 .
0
0 1 1
(19.76)
2:1
a = p2 w2
1
1
1
= 0 1 = 0 .
0
1
0
5. Next, the Orienting Subsystem determines the degree of match between the expectation and the input pattern:
a
1 2
p2
1
0
= --- = 0.4 , therefore a = 0 (no reset).
1
19-36
Solved Problems
2w
1:2
1:2
1
0 1 0
1
2a
1
1:2
a
,
W
= ----------------------------=
=
=
0
1 0 0 .
1 2
2+ a 1
0
0.5 0.5 0.5
8. Update column 2 of W
2:1
w2
2:1
1
0 1 1
1
2:1
= a = 0 ,W = 1 0 1 .
0
0 0 1
1:2 1
a =
0 1 0 1
1
=
1 0 0 1
1 .
0.5 0.5 0.5 0
1
Since all neurons have the same input, pick the first neuron as the winner:
1
2
a = 0 .
0
3. Now compute the L2-L1 expectation:
01 1 1
0
2:1 2
2:1
W a = 1 0 1 0 = w1 = 1 .
00 1 0
0
4. Adjust the Layer 1 output to include the L2-L1 expectation:
19-37
19
2:1
a = p3 w1
1
0
0
= 1 1 = 1 .
0
0
0
5. Next, the Orienting Subsystem determines the degree of match between the expectation and the input pattern:
a
1 2
p3
1
0
= --- = 0.4 , therefore a = 0 (no reset).
2
1w
1:2
1:2
0
0 1 0
1
2a
1
1:2
a
W
= ----------------------------=
=
=
,
1
1 0 0 .
1 2
2+ a 1
0
0.5 0.5 0.5
8. Update column 1 of W
2:1
w2
2:1
0
0 1 1
1
2:1
= a = 1 ,W = 1 0 1 .
0
0 0 1
This completes the training, since if you apply any of the three patterns
again they will not change the weights. These patterns have been successfully clustered. This type of result (stable learning) is guaranteed for the
ART1 algorithm, since it has been proven to always produce stable clusters.
P19.6 Repeat Problem P19.5, but change the vigilance parameter to
= 0.6 .
The training will proceed exactly as in Problem P19.5, until pattern p 3 is
presented, so lets pick up the algorithm at that point.
1. Compute the Layer 1 response:
1
1
a = p3 = 1 .
0
2. Next, compute the input to Layer 2:
19-38
Solved Problems
1:2 1
a =
0 1 0 1
1
=
1 0 0 1
1 .
0.5 0.5 0.5 0
1
Since all neurons have the same input, pick the first neuron as the winner:
1
2
a = 0 .
0
3. Now compute the L2-L1 expectation:
01 1 1
0
2:1
2:1 2
W a = 1 0 1 0 = w1 = 1 .
00 1 0
0
4. Adjust the Layer 1 output to include the L2-L1 expectation:
2:1
a = p3 w1
1
0
0
= 1 1 = 1 .
0
0
0
5. Next, the Orienting Subsystem determines the degree of match between the expectation and the input pattern:
a
0
1 2
p3
1
0
= --- = 0.6 , therefore a = 1 (reset).
2
2
19-39
19
1:2 1
a =
0 1 0 1
1
=
1 0 0 1
1 .
0.5 0.5 0.5 0
1
2:1
a = p3 w2
1
1
1
= 1 0 = 0 .
0
0
0
5. Next, the Orienting Subsystem determines the degree of match between the expectation and the input pattern:
a
0
1 2
p3
1
0
= --- = 0.6 , therefore a = 1 (reset).
2
2
1:2 1
a =
19-40
0 1 0 1
1
1 0 0 1 = 1 .
0.5 0.5 0.5 0
1
Solved Problems
2:1
a = p3 w3
1
1
1
= 1 1 = 1 .
0
1
0
5. Next, the Orienting Subsystem determines the degree of match between the expectation and the input pattern:
a
1 2
p3
2
0
= --- = 0.6 , therefore a = 0 (no reset).
2
3w
1:2
1:2
2
--0 1 0
3
1
2 1
2a
1:2
= ----------------------------- = --- a = 2 , W = 1 0 0 .
1 2
3
--2 2
2+ a 1
3
--- --- 0
3 3
0
8. Update column 3 of W
2:1
w3
2:1
1
0 1 1
1
2:1
= a = 1 ,W = 1 0 1 .
0
0 0 0
This completes the training, since if you apply any of the three patterns
again they will not change the weights. (Verify this for yourself by applying
19-41
19
each input pattern to the network.) These patterns have been successfully
clustered.
Note that in Problem P19.5, where the vigilance was = 0.4 , the patterns
were clustered into two categories. In this problem, with vigilance = 0.6 ,
the patterns were clustered into three categories. The closer the vigilance
is to 1, the more categories will be used. This is because an input pattern
must be closer to a prototype in order to be incorporated into that prototype. When the vigilance is close to zero, many different input patterns can
be incorporated into one prototype. The vigilance parameter adjusts the
coarseness of the categorization.
P19.7 Train an ART1 network using the following input vectors (see
[CaGr87a]):
p1
p2
p3
p4
Present the vectors in the order p 1 p 2 p 3 p 1 p 4 (i.e., p 1 is presented twice in each epoch). Use the parameters = 2 and = 0.6 ,
2
and choose S = 3 (3 categories). Train the network until the
weights have converged.
2:1
2
--------------------------- = ----------------------------- = 0.0769 .
1
2 + 25 1
+ S 1
To create the input vectors we will scan each pattern row-by-row, where
each blue square will be represented by a 1 and each white square will be
represented by a 0. Since the input patterns are 5 5 grids, this will create
25-dimensional input vectors.
We now begin the training. Since it is not practical to display all of the calculations when the vectors are so large, we have summarized the results of
the algorithm in Figure P19.4. Each row represents one iteration of the
ART1 algorithm (presentation of one input vector). The left-most pattern
in each row is the input vector. The remainder of the patterns represent the
2:1
three columns of the W matrix. At each iteration, a star indicates the
2:1
resonance point the column of W that matched with the input pattern.
Whenever a reset occurred, it is represented by a check mark. When more
than one reset occurred in a given iteration, the number beside the check
mark indicates the order in which the reset occurred.
19-42
Solved Problems
6
1
10
(a) First Epoch
19-43
19
Epilogue
Competitive learning, and many other types of neural network training algorithms, suffer from a problem called the stability/plasticity dilemma. If a
learning algorithm is sensitive to new inputs (plastic), then it runs the risk
of forgetting prior learning (unstable). The ART networks were designed to
achieve learning stability while maintaining sensitivity to novel inputs.
In this chapter, the ART1 network was used to illustrate the key concepts
of adaptive resonance theory. The ART1 network is based on the Grossberg
competitive network of Chapter 18, with a few modifications. The key innovation of ART is the use of expectations. As each input pattern is presented to the network, it is compared with the prototype vector that it most
closely matches (the expectation). If the match between the prototype and
the input vector is not adequate, a new prototype is selected. In this way,
previously learned memories (prototypes) are not eroded by new learning.
One important point to keep in mind when analyzing ART networks, is
that they were designed to be biologically plausible mechanisms for learning. They have as much to do with understanding how the brain works as
they do with inspiring practical pattern recognition systems. For this reason, the learning mechanisms are required to use only local information at
each neuron. This is not true of all of the learning rules discussed in this
text.
Although the ART networks solve the problem of learning instability, in
which the network weights never stabilize, there is another stability problem that we have not yet discussed. This is the stability of the differential
equations that implement the short-term memory equations of the network. In Layer 2, for example, we have a set of differential equations with
nonlinear feedback. Can we make some general statement about the stability of such systems? Chapter 20 will present a comprehensive discussion
of this problem.
19-44
Further Reading
Further Reading
[CaGr87a]
G. A. Carpenter and S. Grossberg, A massively parallel architecture for a self-organizing neural pattern recognition
machine, Computer Vision, Graphics, and Image Processing, vol. 37, pp. 54115, 1987.
In this original presentation of the ART1 architecture, Carpenter and Grossberg demonstrate that the architecture
self-organizes and self-stabilizes in response to an arbitrary number of binary input patterns. The key feature of
ART is a top-down matching mechanism.
[CaGr87b]
G. A. Carpenter and S. Grossberg, ART2: Self-organization of stable category recognition codes for analog input
patterns, Applied Optics, vol. 26, no. 23, pp. 49194930,
1987.
This article describes an extension of the ART1 architecture that is designed to handle analog input patterns.
[CaGr90]
[CaGrMa92]
[CaGrRe91]
19
[Gros76]
S. Grossberg, Adaptive pattern classification and universal recoding: I. Parallel development and coding of neural
feature detectors, Biological Cybernetics, vol. 23, pp. 121
134, 1976.
Grossberg describes a continuous-time competitive network, inspired by the developmental physiology of the visual cortex. The structure of this network forms the
foundation for other important networks.
[Gros82]
19-46
Exercises
Exercises
E19.1 Consider Layer 1 of the ART1 network with = 0.02 . Assume two neurons
in Layer 2, two elements in the input vector and the following weight matrix and input:
W
2:1
p = 0 .
1
= 0 1
1 1
+ 1
- 1
+ 1
- 1
+ 1
- 1
ans =
4
E19.2 Consider Layer 2 of the ART1 network with the following parameters:
1:2 T
= 0.1
1:2
1w
1:2 T
2w
2
--= 3
1
2
--3
0
19
and
10 n ,
2
f (n) =
0,
2
n0
n0
19-47
b = 2
2
b = 2 .
2
+ 2
- 2
b = 3 .
3
+ 2
- 2
b = 0 .
0
+ 2
- 2
iv. Do the results of all of the previous parts satisfy the desired steady
state response described in Eq. (19.37)? If not, explain why.
E19.3 Consider the Orienting Subsystem of the ART1 network with the following
parameters:
= 0.1
+ 0
- 0
b = b = 2.
0
1
a = 0 .
1
0
ii. Find and plot the response of the Orienting Subsystem n t , for
= 0.5 = 2 ( = 0.25 ).
iii. Verify that the steady state conditions are satisfied in parts (i) and
(ii).
2+2
ans =
4
iv. Check your answers to parts (i) and (ii) by writing a MATLAB M-file
to simulate the Orienting Subsystem.
19-48
Exercises
E19.4 To derive the steady state conditions for the L1-L2 and L2-L1 learning
rules, we have made the assumption that the input pattern and the neuron
outputs remain constant until the weight matrices converge. This is called
fast learning. Show that this fast learning assumption is equivalent to
setting the learning rate to 1 in the instar and outstar learning rules presented in Chapter 15 and the Kohonen competitive learning rule in Chapter 16.
E19.5 Train an ART1 network using the following input vectors:
0
1
1
1
p1 = 1 , p2 = 0 , p3 = 1 , p3 = 1 .
0
0
0
1
1
1
0
1
2
2+2
ans =
4
E19.7 Write a Matlab M-file to implement the ART1 algorithm (with the modification described in Exercise E19.6). Use this M-file to train an ART1 network using the following input vectors (see Problem P19.7):
19
p1
p2
p3
p4
19-49
2+2
E19.8 Recall the digit recognition problem described in Chapter 7 (page 7-10).
Train an ART1 network using the digits 0 9 , as displayed below:
ans =
4
p1
p2
p3
p4
p5
p6
p7
p8
p9
p10
Use the parameter = 2 , and choose S = 5 (5 categories). Use the Matlab M-file from Exercise E19.7.
i. Train the network to convergence using = 0.3 .
ii. Train the network to convergence using = 0.6 .
iii. Train the network to convergence using = 0.9 .
iv. Discuss the results of parts (i)(iii). Explain the effect of the vigilance parameter.
19-50
Objectives
20
Stability
Objectives
20-1
20-2
Recurrent Networks
20-2
Stability Concepts
20-3
Definitions
20-4
20-5
Pendulum Example
20-6
20-12
Definitions
20-12
Theorem
20-13
Example
20-14
Comments
20-18
Summary of Results
20-19
Solved Problems
20-21
Epilogue
20-28
Further Reading
20-29
Exercises
20-30
Objectives
The problem of convergence in a recurrent network was first raised in our
discussion of the Hopfield network, in Chapter 3. It was noted there that
the output of a recurrent network could converge to a stable point, oscillate,
or perhaps even diverge. The stability of the steepest descent process and
of the LMS algorithm were discussed in Chapter 9 and Chapter 10, respectively. The stability of Grossbergs continuous-time recurrent networks
was discussed in Chapter 18.
In this chapter we will define stability more carefully. Our objective is to
determine whether a particular set of nonlinear equations has points (or
trajectories) to which its output might converge. To help us study this topic
we will introduce Lyapunovs Stability Theorem and apply it to a simple,
but instructive, problem. Then, we will present a generalization of the
Lyapunov Theory: LaSalles Invariance Theorem. This will set the stage for
Chapter 21, where LaSalles theorem is used to prove the stability of
Hopfield networks.
20-1
20
20 Stability
(20.1)
Here p t is the input to the network, and a t is the output of the network.
(See Figure 20.1.)
.
a
a(0)
Stability Concepts
We want to know how these systems perform in the steady state. We will
be most interested in those cases where the network converges to a constant output a stable equilibrium point. A nonlinear system can have
many stable points. For some neural networks these stable points represent stored prototype patterns. When possible, we would like to know
where the stable points are, and which initial conditions a 0 converge to
a given stable point (i.e., what is the basin of attraction for a given stable
point?).
Stability Concepts
To begin our discussion, lets introduce some basic stability concepts with
a simple, intuitive example. Consider the motion of a ball bearing, with dissipative friction, in a gravity field. In the adjacent figure, we have a ball
bearing at the bottom of a trough (point a ). If we move the bearing to a
different position, it will oscillate back and forth in the trough, but, because
of friction, it will eventually settle back to the bottom of the trough. We will
call this position an asymptotically stable point, which we will define more
precisely in the next section.
Consider now the second figure in the left margin. Here we have a ball
bearing positioned at the center of a flat surface. If we place the bearing in
a different position, it will not move. The position at the center of the surface is not asymptotically stable, since the bearing does not move back to
the center if it is moved away. However, it is stable in a certain sense, because at least the ball does not roll farther away from the center point. We
call this kind of point stable in the sense of Lyapunov, which we will define
in the next section.
Now consider the third figure in the left margin. The ball bearing is positioned at the top of a hill. This is an equilibrium point, since the ball will
remain at the top of the hill, if we position it carefully. However, if the bearing is given the slightest disturbance, it will roll down the hill. This is an
unstable equilibrium point.
In the next chapter we will try to design Hopfield neural networks, in
which the stored prototype patterns will be asymptotically stable equilibrium points. We would also like the basins of attraction for these stable
points to be as large as possible.
For example, consider Figure 20.2. We would like to design neural networks with large basins of attraction such as those of Case A. One can certainly imagine that if a ball that rolls with high friction is placed (with zero
velocity) in any one of the basins of Case A, it will remain in that basin and
will eventually find its way to the bottom (stable point). However, Case B
is more complicated. If, for instance, one places a ball with friction at point
P, it is not clear which stable point will eventually capture the ball. The ball
may not come to rest at the stable point closest to P. It is also difficult to
tell how large the basin of attraction is for a specific stable point.
20-3
20
20 Stability
Case A
Case B
Definitions
Equilibrium Point
Stability
Asymptotic Stability
Positive Definite
Positive Semidefinite
(20.2)
20
20 Stability
Pendulum Example
We can gain some insight into Lyapunovs stability theorem by applying it
to a simple mechanical system. This system is very simple, and its operation is easy to visualize, and yet it illustrates important concepts that we
will apply to neural network design in the next chapter. The example system we will use is the pendulum shown in Figure 20.3.
m
mg
ml
dt
20-6
() = c
d
mg sin ,
dt
(20.3)
Pendulum Example
or
2
ml
d
dt
+c
d
+ mg sin = 0 ,
dt
(20.4)
d
.
dt
(20.5)
We can write equations for the pendulum in terms of these state variables
as follows:
da 1
= a2 ,
dt
(20.6)
da 2
g
c
= --- sin a 1 ------ a 2 .
dt
l
ml
(20.7)
Now we want to investigate the stability of the origin ( a = 0 ) for this pendulum system. (The origin corresponds to a pendulum angle of zero and a
pendulum velocity of zero.) We first want to check that the origin is an equilibrium point. We do this by substituting a = 0 into the state equations.
da 1
= a2 = 0 ,
dt
20-7
(20.8)
20
20 Stability
da 2
g
c
g
c
= --- sin a 1 ------ a 2 = --- sin 0 ------ 0 = 0
dt
l
ml
l
ml
(20.9)
(20.10)
In order to test the stability of the system, we need to evaluate the derivative of V with respect to time.
d
V da 1 V da 2
T
V a = V a g a =
+
dt
a1 d t a2 d t
(20.11)
The partial derivatives of V a can be obtained from Eq. (20.10), and the
derivatives of the two state variables are given by Eq. (20.6) and Eq. (20.7).
Thus we have
g
c
d
2
V a = mgl sin a 1 a 2 + ml a 2 --- sin a 1 ------ a 2 .
l
dt
ml
(20.12)
(20.13)
20-8
Pendulum Example
2
+2
(20.14)
da 2
= sin a 1 0.2a 2 .
dt
(20.15)
(20.16)
dV
2
= 19.208 a 2 .
dt
(20.17)
300
200
a2
100
-1
0
2
10
a2
-1
-2
-5
-10
a1
-2
-10
-5
10
a1
20
20 Stability
show this, we have plotted the energy contours, and one particular path for
the pendulum, in Figure 20.5. The response trajectory, shown by the blue
line, starts from an initial position, a 1 0 , of 1.3 radians (74) and an initial
velocity, a 2 0 , of 1.3 radians per second. The trajectory converges to the
equilibrium point a = 0 .
Contour Plot
x2
a2
-1
-2
-10
-5
ax11
10
20-10
Pendulum Example
a1
-1
a2
-2
0
10
20
30
40
t
Figure 20.6 State Variables a 1 (blue) and a 2 vs. Time
Notice that, although there are points where the derivative of the energy
curve is zero, the derivative does not remain zero until the energy is also
zero. This observation will lead to LaSalles Invariance Theorem, which we
will discuss in the next section. The key idea of that theorem is to identify
those points where the derivative of the Lyapunov function is zero, and
then to determine if the system will be trapped at those points. (Those places where a trajectory can be trapped are called invariant sets.) If the only
point that can trap the trajectory, and that has zero derivative, is the origin, then the origin is asymptotically stable.
160
120
80
Vt
40
10
20
30
40
t
Figure 20.7 Pendulum Lyapunov Function (Energy) vs. Time
The particular pendulum behavior shown in the graphs in this section depends on the initial conditions of the two state variables. The choice of a different set of initial conditions may give results entirely different from those
shown in these plots. We will expand on this in the next section.
20-11
20
20 Stability
To experiment with the pendulum, use the Neural Network Design Demonstration Dynamic System (nnd17ds).
Definitions
Lyapunov Function
(20.18)
Definition 6: Set Z
Z = a: dV a dt = 0 a in the closure of G .
20-12
(20.19)
Here the closure of G includes the interior and the boundary of G . This
is a key set. It contains all of those points where the derivative of the
Lyapunov function is zero. Later we will want to determine where in this
set the system trajectory can be trapped.
Invariant Set
A set of points in is invariant with respect to da dt = g a if every solution of da dt = g a starting in that set remains in the set for all time.
If the system gets into an invariant set, then it cant get out.
Set L
Definition 8: Set L
L is defined as the largest invariant set in Z .
This set includes all possible points at which the solution might converge.
The Lyapunov function does not change in L (because its derivative is zero), and the trajectory will be trapped in L (because it is an invariant set).
Now, if this set has only one stable point, then that point is asymptotically
stable. This is, in essence, what LaSalles theorem will say.
Theorem
LaSalles Invariance Theorem extends the Lyapunov Stability Theorem.
We will use it to design Hopfield networks in the next chapter. The theorem
proceeds as follows [Lasa67].
Theorem 2: LaSalles Invariance Theorem
If V is a Lyapunov function on G for da dt = g a , then each solution a t
that remains in G for all t 0 approaches L = L as t . ( G is a
basin of attraction for L , which has all of the stable points.) If all trajectories are bounded, then a t L as t .
If a trajectory stays in G , then it will either converge to L , or it will go to
infinity. If all trajectories are bounded, then all trajectories will converge
to L .
There is a corollary to LaSalles theorem that we will use extensively. It involves choosing the set G in a special way.
20-13
20
20 Stability
(20.20)
Example
2
+2
Lets apply Corollary 1 to the pendulum example. The first step in using the
corollary will be to choose the set . This set will then be used to select
the set G (a component of ).
For this example we will use the value = 100 , therefore 100 will be the
set of points where the energy is less than or equal to 100 .
100 = a:V a 100
(20.21)
a2
-1
-2
-10
-5
a1
10
origin, lets choose the component of 100 that contains a = 0 . The resulting set is shown in Figure 20.9.
2
a2
-1
-2
-10
-5
a1
10
(20.22)
(20.23)
We know from Eq. (20.17) that the derivative of V a is only zero when the
velocity is zero, which corresponds to the a 1 axis. Therefore Z consists of
the segment of the a 1 axis that falls within G . The set Z is displayed in
Figure 20.10.
The set L is the largest invariant set in Z . To find L we need to answer the
question: If we start the pendulum from an initial position between 1.6
and 1.6 radians, with zero initial velocity, will the velocity of the pendulum
remain zero? Clearly the only such initial condition would be 0 radians
(straight down). If we start the pendulum from any other position in Z , the
pendulum will start to fall, so the velocity will not remain zero and the trajectory will move out of Z . Therefore, the set L consists only of the origin:
L = a: a = 0 .
20-15
(20.24)
20
20 Stability
Z
a2
-1
-2
-10
-5
10
a1
(20.25)
(20.26)
a2
-1
-2
-10
-5
10
a1
20-16
Z = a: a 2 = 0 ,
(20.27)
which is shown by the blue bar on the horizontal axis of Figure 20.11. Thus,
it follows that
L = L = a: a 1 = n, a 2 = 0 .
(20.28)
This is because there are now several different positions within the set Z
where we can place the pendulum, without causing the velocity to become
nonzero. The pendulum can be pointing directly up or directly down. This
corresponds to the positions n for any integer n . If we place the pendulum in any of these positions, with zero velocity, then the pendulum will remain stationary. We can show this by setting the derivatives equal to zero
in Eq. (20.14) and Eq. (20.15).
da 1
= a2 = 0 ,
dt
(20.29)
(20.30)
For this choice of G = 300 we can say very little about where the trajectory will converge. We tried to increase the size of our known region of attraction for the origin, but this G is a region of attraction for all of the
equilibrium points. We made G too large. The set L is illustrated by the
blue dots in Figure 20.12.
2
a2
-1
-2
-10
-5
10
a1
20-17
20
20 Stability
Figure 20.13. This shows the pendulum response for an initial position of 2
radians and an initial velocity of 1.5 radians per second. This time the pendulum had enough velocity to go over the top, and it converged to the equilibrium point at 2 radians.
Now that we have discussed LaSalles Invariance Theorem, you might want
to experiment some more with the pendulum, in order to investigate the regions of attraction for the various stable points. To experiment with the pendulum, use the Neural Network Design Demonstration Dynamic System
(nnd17ds).
Contour Plot
x2
a2
-1
-2
-10
-5
ax11
10
Comments
The keys to LaSalles theorem are the choices of the Lyapunov function V
and the set G . We want G to be as large as possible, because that will indicate the region of attraction. However, we want to choose V so that the
set Z , which will contain the attractor set, is as small as possible.
For instance, we could try V = 0 . This is a Lyapunov function for the entire
n
space , since its derivative is zero (and therefore doesnt change sign) evn
erywhere. However, it gives us no information since Z = .
Notice that if V 1 and V 2 are both Lyapunov functions on G , and dV 1 dt
and dV 2 dt have the same sign, then V = V 1 + V 2 is also a Lyapunov function, where Z = Z 1 Z 2 . If Z is smaller than both Z 1 and Z 2 , then Z is a
better Lyapunov function than either V 1 or V 2 . V is always at least as
good as either V 1 or V 2 , since Z can never be larger than the smaller of Z 1
and Z 2 . Therefore, if you have found two different Lyapunov functions and
their derivatives have the same sign, then add them together and you may
have a better function. The best Lyapunov function for a given system is
the one that has the smallest attractor set and the largest region of attraction.
20-18
Summary of Results
Summary of Results
Stability Concepts
Definitions
Definition 1: Stability (in the sense of Lyapunov)
The origin is a stable equilibrium point if for any given value 0 there
exists a number 0 such that if a 0 , then the resulting motion
a t satisfies a t for t 0 .
Definition 2: Asymptotic Stability
The origin is an asymptotically stable equilibrium point if there exists a
number 0 such that whenever a 0 the resulting motion satisfies
a 0 0 as t .
Definition 3: Positive Definite
A scalar function V a is positive definite if V 0 = 0 and V a 0 for
a0.
Definition 4: Positive Semidefinite
A scalar function V a is positive semidefinite if V a 0 for all a .
20-19
20
20 Stability
(20.31)
Theorem
Theorem 2: LaSalles Invariance Theorem
If V is a Lyapunov function on G for da dt = g a , then each solution a t
that remains in G for all t 0 approaches L = L as t . ( G is a
basin of attraction for L , which has all of the stable points.) If all trajectories are bounded, then a t L as t .
Corollary 1: LaSalles Corollary
Let G be a component (one connected subset) of
= a:V a .
(20.32)
20-20
Solved Problems
Solved Problems
P20.1 Test the stability of the origin for the following system.
da 1 dt = a 1 + a 2
da 2 dt = a 2 a 1 + 1
The basic job here is to find a Lyapunov V a that is positive definite and
has a derivative that is negative semidefinite or, better yet, negative definite. (The latter is a stronger condition.)
2
da 2 dt = 5 a 2
2
20-21
20
20 Stability
da 2 dt = a 1 a 2
(nonlinear spring) .
a2
-2
-4
-4
-2
a1
20-22
Solved Problems
Further, we can increase to show that the entire is the basin of attraction for the origin.
Figure P20.3 shows the response of the spring-mass-damper from an initial
position of 2 and an initial velocity of 2 . Note that the trajectory is parallel
to the contour lines when the trajectory crosses the a 2 axis. This agrees
with our earlier result, which showed that the derivative of the Lyapunov
function was zero whenever a 2 = 0 . Fortunately, the a 2 axis is not an invariant set (except for the origin); therefore the trajectory is only attracted
to the origin.
Contour Plot
x2
a2
20
-2
-4
-4
-2
ax11
20-23
20 Stability
da 1 dt = a 1 a 1 + a 2 4 a 2
2
da 2 dt = a 1 + a 2 a 1 + a 2 4 .
This system has two invariant sets, the origin
a: a = 0 ,
and the circle
2
a: a 1 + a 2 = 4 .
Assuming the candidate Lyapunov function
2
V a = a1 + a2 ,
use LaSalles Invariance Theorem to find out as much as you can
about the region of attraction for the origin.
Our job, then, is to determine whether or not the given invariant sets represent a stable point or a stable trajectory. Lets first take a look at dV dt .
We recall that
V da 1 V da 2
dV a
-------- +
-------- ,
--------------- =
a 1 dt a 2 dt
dt
and substitute for the various terms to give
dV a
2
2
2
2
--------------- = 2a 1 a 1 a 1 + a 2 4 a 2 + 2a 2 a 1 + a 2 a 1 + a 2 4 .
dt
This can be simplified to
dV a
2
2
2
2
--------------- = 2 a 1 + a 2 a 1 + a 2 4 .
dt
2
20-24
Solved Problems
G = 1 = a: V a 1
Now we consider 1 . There are just two places that dV dt = 0 , and the
only point inside 1 is a = 0 . Therefore,
Z = a: a 1 = 0, a 2 = 0
and
L = L = Z .
The origin is the attractor, and 1 is in its region of attraction.We can use
the same arguments to show that the region of attraction for the origin in2
2
cludes all points inside the circle a 1 + a 2 = 4 .
Figure P20.4 displays two trajectories for this system, one that begins in2
2
side the circle a 1 + a 2 = 4 , and one that begins outside the circle. Although the circle is an invariant set, it is not an attractor. The only
attractor for this system is the origin.
Contour Plot
x2
a2
-1
-2
-3
-3
-2
-1
ax11
20-25
20
20 Stability
Va = a 2
G = 0.5 = a: a 2 0.5 .
2
20-26
Solved Problems
Figure P20.5 displays some typical responses for this system. Here we can
see that the equilibrium point a = 1 is actually unstable. Any initial condition above a = 1 converges to a = 2 . Anything less than a = 1 goes to
minus infinity.
4
0
0
20
20-27
20 Stability
Epilogue
In this chapter we have presented the concept of stability, as applied to dynamic systems. For nonlinear dynamic systems, like recurrent neural networks, we do not talk about the stability of the system. Rather, we discuss
the stability of certain system trajectories and, in particular, equilibrium
points.
There were two main stability theorems discussed in this chapter. The first
is the Lyapunov Stability Theorem, which introduces the concept of generalized energy the Lyapunov function. The concept behind this theorem
is that if a systems energy is always decreasing, then it will eventually
stabilize at a point of minimum energy.
The second theorem presented was LaSalles Invariance Theorem, which is
an enhancement of the Lyapunov Stability Theorem. There are two key improvements made by LaSalle. The first is a clarification of the cases in
which the Lyapunov function does not decrease throughout the state space,
but stays constant in some regions. LaSalles theorem introduced the concept of an invariant set to identify those regions that can trap the system
trajectory. The second improvement made by LaSalles theorem is that, in
addition to indicating the stability of equilibrium points, it also gave information about the regions of attraction of each stable point.
The ideas presented in this chapter are important tools for the analysis of
recurrent neural networks, like the Grossberg networks of Chapters 18 and
19. (See [CoGr83] for an application of LaSalles Invariance Theorem to recurrent neural networks.) In Chapter 21 we will use LaSalles theorem to
explain the operation of the Hopfield network.
20-28
Further Reading
Further Reading
[Brog91]
[CoGr83]
[Lasa67]
J. P. LaSalle, An invariance principle in the theory of stability, in Differential Equations and Dynamic Systems, J.
K. Hale and J. P. LaSalle, eds., New York: Academic Press,
pp. 277286, 1967.
This article provides a unified presentation of Lyapunovs
stability theory, including several extensions. It introduces
LaSalles Invariance Theorem and various corollaries.
[SlLi91]
J.-J. E. Slotine and W. Li, Applied Nonlinear Control, Englewood Cliffs, NJ: Prentice-Hall, 1991.
This text is an introduction to nonlinear control systems. A
significant portion of the book is devoted to the analysis of
nonlinear dynamic systems. A number of stability theorems are presented and demonstrated.
20
20-29
20 Stability
Exercises
E20.1 Use Lyapunovs Stability Theorem to test the stability of the origin for the
following systems.
3
da 1 dt = a 1 + a 2
i.
da 2 dt = a 1 a 2
da 1 dt = a 1 + a 2
ii.
da 2 dt = a 2 a 1 + 1
E20.2 Consider the following nonlinear system:
2
da 1 dt = a 2 2a 1 a 1 + a 2 ,
2
da 2 dt = a 1 2a 2 a 1 + a 2 .
i. Use Lyapunovs Stability Theorem and the candidate Lyapunov
function shown below to investigate the stability of the origin.
2
V a = a1 + a2
2+2
ans =
4
ii. Check your stability result from part (i) by writing a MATLAB Mfile to simulate the response of this system for several different initial conditions. Use the ode45 routine. Plot the responses.
E20.3 Consider the following nonlinear system:
da dt = a a + 1 ,
i. Find any equilibrium points.
ii. The following Lyapunov function is proposed. Show that this is a
valid Lyapunov function for use in Lasalles invariance theorem.
3
V a = 2a + 3a .
iii. Use the corollary to Lasalles theorem and the proposed Lyapunov
function to provide as much information as you can about the stable
equilibrium points and their basins of attraction. Identify the sets
Z, G and L. Use graphs wherever possible.
20-30
Exercises
E20.4 Repeat E20.3 for the following systems and Lyapunov functions. (In some
cases, it may be useful to sketch the Lyapunov functions.)
i. da dt = a 2 a + 1 , V a = a + 1
3
ii. da dt = a a + 1 , V a = 2a + 3a
3
iii. da dt = a a + 2 , V a = a 3 a
3
iv. da dt = a a 1 , V a = 2a 3a
v. da dt = cos a , find a V a
vi. da dt = sin a , find a V a
E20.5 Consider the following nonlinear system:
da 1 dt = a 2 ,
2
da 2 dt = a 2 1 a 2 a 1 .
We want to use the corollary to Lasalles invariance theorem to locate attractors and find out as much as we can about the basins of attraction, using the following Lyapunov function.
2
V a = a1 + a2 .
i. Find any equilibrium points.
ii. Find dV a dt .
iii. Choose a set G.
iv. Find the corresponding set Z.
v. Find the set L.
vi. What have you learned about the attractors of this system and the
basins of attraction? Can you learn more by modifying the set G?
Explain.
2+2
ans =
4
vii. Check your results by writing a MATLAB M-file to simulate the response of this system for several different initial conditions. Use the
ode45 routine. Plot the responses.
E20.6 Consider the following nonlinear system:
da 1 dt = a 2 ,
20-31
20
20 Stability
da 2 dt = a 1 a 2 .
i. Find any equilibrium points.
ii. Find as much information about the stability of the equilibrium
points as possible, using the corollary to LaSalles theorem and the
candidate Lyapunov function
2
V a = a1 + a2 .
2+2
ans =
4
iii. Check your results from parts (i) and (ii) by writing a MATLAB Mfile to simulate the response of this system for several different initial conditions. Use the ode45 routine. Plot the responses.
E20.7 Consider the following nonlinear system:
2
da dt = 1 a 1 + a = 1 a .
i. Find any equilibrium points.
ii. Find a suitable Lyapunov function. (Hint: Start with a form for
dV dt and work backward to find V .)
iii. Sketch the Lyapunov function.
iv. Use the corollary to LaSalles theorem and the Lyapunov function of
part (ii) to find as much information as possible about regions of attraction. Use graphs wherever possible.
(Hint: The graph shown in Figure E20.1 may be helpful.)
f (a) = 1 - (a / ) 2
20-32
Exercises
da 1 dt = a 2 a 1 a 1 + 2 a 2 10 ,
3
da 2 dt = a 1 3 a 2 a 1 + 2 a 2 10 .
2+2
ans =
4
i. Find any invariant sets. (You may want to simulate this system using MATLAB in order to help identify the invariant sets.)
ii. Using the candidate Lyapunov function shown below and the corollary to LaSalles theorem, investigate the stability of the invariant
sets you found in part (i).
4
V a = a 1 + 2 a 2 10
da 1 dt = a 2 + a 1 1 a 1 a 2 ,
2
da 2 dt = a 1 + a 2 1 a 1 a 2 ,
we know that the following sets are invariant:
a a = 0 ,
2
20
a a1 + a2 = 1 .
The following Lyapunov function is proposed:
2
V a = a1 + a2 1 .
20-33
20 Stability
Use the corollary to Lasalles theorem to find out as much as possible about
the basins of attraction for the two invariant sets given above, and graph
the sets , G, Z and L.
E20.11 Consider the system
da 1 dt = cos a 2 a 1 ,
da 2 dt = a 1 .
i. Find any equilibrium points.
ii. The following Lyapunov function is proposed. Show that this is a
valid Lyapunov function for use in Lasalles invariance theorem.
2
a1
- + sin a 2
V a = ----------2
iii. Use Lasalles theorem to find out as much information as you can
about the stable equilibrium points and their basins of attraction.
(Make a rough sketch of the contour plot for V a to assist you.)
20-34
Objectives
21
Hopfield Network
Objectives
21-1
21-2
Hopfield Model
21-3
Lyapunov Function
21-5
Invariant Sets
21-7
Example
21-8
Hopfield Attractors
21-11
Effect of Gain
21-13
Hopfield Design
21-16
Content-Addressable Memory
21-16
Hebb Rule
21-19
Lyapunov Surface
21-23
Summary of Results
21-25
Solved Problems
21-27
Epilogue
21-37
Further Reading
21-38
Exercises
21-41
Objectives
This chapter will discuss the Hopfield recurrent neural network a network that was highly influential in bringing about the resurgence of neural
network research in the early 1980s. We will begin with a description of the
network, and then we will show how Lyapunov stability theory can be used
to analyze the network operation. Finally, we will demonstrate how the
network can be designed to behave as an associative memory.
This chapter brings together many topics discussed in previous chapters:
the discrete-time Hopfield network (Chapter 3), eigenvalues and eigenvectors (Chapter 6); associative memory and the Hebb rule (Chapter 7); Hessian matrices, conditions for optimality, quadratic functions and surface
and contour plots (Chapter 8); steepest descent and phase plane trajectories (Chapter 9); continuous-time recurrent networks (Chapter 18); and
Lyapunovs Stability Theorem and LaSalles Invariance Theorem (Chapter
20). This chapter is, in some ways, a culmination of all our previous efforts.
21-1
21
21 Hopfield Network
Hopfield Model
sis of the Hopfield model. In the final section we will demonstrate how the
Hebb rule can be used to design Hopfield networks as content-addressable
memories.
Hopfield Model
Hopfield Model
I1
I2
R1,S
IS
RS,2
Amplifier
Inverting
Output
n1
R2,1
n2
nS
Resistor
a1
a2
aS
j=1
21-3
n i(t)
- + Ii ,
Ti j aj(t) --------Ri
21
(21.1)
21 Hopfield Network
where n i is the input voltage to the ith amplifier, a i is the output voltage
of the ith amplifier, C is the amplifier input capacitance and I i is a fixed
input current to the ith amplifier. Also,
S
T i j
1
1
1
= -------- , ----- = --- +
R i j R i
-, n
------R i j i
= f a i (or a i = f n i ),
(21.2)
j=1
Ri Ti j a j(t) n i(t) + Ri Ii .
(21.3)
j=1
(21.4)
wi j a j(t) + bi .
(21.5)
j=1
(21.6)
a(t) = f n(t) .
(21.7)
and
Lyapunov Function
Input
Recurrent Layer
Sx1
SxS
1/
.
n
b
Sx1
n
Sx1
-1
a
Sx1
-1
dn/dt = - n + W f(n) + b
Lyapunov Function
The application of Lyapunov stability theory to the analysis of recurrent
networks was one of the key contributions of Hopfield. (Cohen and Grossberg also used Lyapunov theory for the analysis of competitive networks at
about the same time [CoGr83].) In this section we will demonstrate how
LaSalles Invariance Theorem, which was presented in Chapter 20, can be
used with the Hopfield network. The first step in using LaSalles theorem
is to choose a Lyapunov function. Hopfield suggested the following function:
ai
T
f u du b a .
i=1 0
1 T
V a = --- a Wa +
2
(21.8)
21-5
21
21 Hopfield Network
T da
d 1 T
da
1
T
T da
T
--- a Wa = --- a Wa ------ = Wa ------ = a W ------ .
d t 2
dt
dt
dt
2
(21.9)
ai
da
da
da
d 1
d 1
f u du = d a f u du d t i = f1 a i d t i = n i d t i .
d t 0
i 0
(21.10)
T da
-.
f u du = n ----dt
0
i=1
d
----dt
(21.11)
Using Eq. (8.36), we can find the derivative of the third term in V a .
d
T
T T da
T da
b a = b a ------ = b -----dt
dt
dt
(21.12)
(21.13)
(21.14)
dn da
d
dn(t) T da
V a = ------------ ------ = i i .
dt dt
dt
dt
dt
(21.15)
i=1
1
21-6
(21.16)
Lyapunov Function
i=1
i=1
dn da
da 2
d
d 1
V a = i i = f a i i .
d ai
dt
dt dt
dt
(21.17)
(21.18)
(21.19)
Thus, if f a i is an increasing function, dV a dt is a negative semidefinite function. Therefore, V a is a valid Lyapunov function.
Invariant Sets
Now we want to apply LaSalles Invariance Theorem to determine equilibrium points for the Hopfield network. The first step is to find the set Z (Eq.
(20.19)).
Z = a: dV a dt = 0 a in the closure of G
(21.20)
This set includes all points at which the derivative of the Lyapunov funcS
tion is zero. For now, lets assume that G is all of .
We can see from Eq. (21.17) that such derivatives will be zero if the derivatives of all of the neuron outputs are zero.
da
------ = 0
dt
(21.21)
However, when the derivatives of the outputs are zero, the circuit is at
equilibrium. Thus, those points where the system energy is not changing
are also points where the circuit is at equilibrium.
This means that the set L , the largest invariant set in Z , is exactly equal
to Z .
L = Z
Thus, all points in Z are potential attractors.
Some of these features will be illustrated in the following example.
21-7
(21.22)
21
21 Hopfield Network
Example
2
+2
(21.23)
(21.24)
Assume two amplifiers, with the output of each connected to the input of
the other through a unit resistor, so that
R 1 2 = R 2 1 = 1 and T 1 2 = T 2 1 = 1 .
(21.25)
(21.26)
(21.27)
(21.28)
T
f u du b a .
i=1 0
1 T
V a = --- a Wa +
2
(21.29)
21-8
(21.30)
Lyapunov Function
The third term is zero, because the biases are zero. The ith part of the second term is
ai
ai
2
2
ai
(21.31)
f 1 u du
0
(21.32)
Finally, substituting all three terms into Eq. (21.29), we have our
Lyapunov function:
2
2
1.4
(21.33)
Now lets write out the network equation (Eq. (21.6)). With = 1 and
b = 0 , it is
dn
------ = n + Wf n = n + Wa .
dt
(21.34)
(21.35)
dn 2 dt = a 1 n 2 .
(21.36)
2 1 1.4
a 1 = --- tan ----------- n 1 ,
2
(21.37)
2 1 1.4
a 2 = --- tan ----------- n 2 .
2
(21.38)
Now that we have found expressions for the system Lyapunov function and
the network equation of operation, lets investigate the network behavior.
The Lyapunov function contour and a sample trajectory are shown in Figure 21.3.
21-9
21
21 Hopfield Network
2
0.5
a2
-0.5
1
1
0.5
a2 0
-1
-1
-0.5
0.5
0.5
0
-0.5
-1
-0.5
-1
a1
a1
Figure 21.3 Hopfield Example Lyapunov Function and Trajectory
The contour lines in this figure represent constant values of the Lyapunov
function. The system has two attractors, one in the lower left and one in the
upper right of Figure 21.3. Starting from the upper left, the system converges, as shown by the blue line, to the stable point at the lower left.
Figure 21.4 displays the time response of the two neuron outputs.
1
0.5
a2
-0.5
a1
-1
0
10
t
Figure 21.4 Hopfield Example Time Response
Figure 21.5 displays the time response of the Lyapunov function. As expected, it decreases continuously as the equilibrium point is approached.
The system also has an equilibrium point at the origin. If the network is
initialized anywhere on a diagonal line drawn from the upper-left corner to
the lower-right corner, the solution converges to the origin. Any initial conditions that do not fall on this line, however, will converge to one of the solutions in the lower-left or upper-right corner. The solution at the origin is
a saddle point of the Lyapunov function, not a local minimum. We will dis-
21-10
Lyapunov Function
cuss this problem in a later section. Figure 21.6 displays a trajectory that
converges to the saddle point.
2
1.5
Va
0.5
0
0
10
t
Figure 21.5 Lyapunov Function Response
1
0.5
a2
-0.5
-1
-1
-0.5
0.5
a1
Figure 21.6 Hopfield Convergence to a Saddle Point
To experiment with the Hopfield network, use the Neural Network Design
Demonstration Hopfield Network (nnd18hn).
This example has provided some insight into the Hopfield attractors. In the
next section we will analyze them more carefully.
Hopfield Attractors
In the example network in the previous section we found that the Hopfield
network attractors were stationary points of the Lyapunov function. Now
we want to show that this is true in the general case. Recall from Eq.
(21.21) that the potential attractors of the Hopfield network satisfy
21-11
21
21 Hopfield Network
da
------ = 0 .
dt
(21.39)
How are these points related to the minima of the Lyapunov function V a ?
In Chapter 8 (Eq. (8.27)) we showed that the minima of a function must be
stationary points (i.e., gradient equal to zero). The stationary points of
V a will satisfy
V = V V ... V
a1 a2
aS
= 0,
(21.40)
where
ai
T
f u du b a .
i=1 0
1 T
V a = --- a Wa +
2
(21.41)
If we follow steps similar to those we used to derive Eq. (21.13), we can find
the following expression for the gradient:
dn(t)
V a = W a + n b = ------------ .
dt
(21.42)
d 1
d 1
V a = i = ( f a i ) = f a i i .
ai
dt
d ai
dt
dt
(21.43)
(21.44)
21-12
(21.45)
Effect of Gain
da(t)
------------ = 0 ,
dt
(21.46)
V a = 0 .
(21.47)
Therefore, the attractors, which are members of the set L and satisfy Eq.
(21.39), will also be stationary points of the Lyapunov function V a .
Effect of Gain
The Hopfield Lyapunov function can be simplified if we consider those cases where the amplifier gain is large. Recall that the nonlinear amplifier
characteristic for our previous example was
2 1 n
a = f n = --- tan --------- .
2
(21.48)
This function is displayed in Figure 21.7 for four different gain values.
1
= 14
= 1.4
0.5
= 0.14
-0.5
-1
-5
-2.5
2.5
T
f u du b a .
i=1 0
21
1 T
V a = --- a Wa +
2
21-13
(21.49)
21 Hopfield Network
(21.50)
Therefore, the second term in the Lyapunov function takes the form
ai
f 1 u du
0
High-Gain
Lyapunov Function
a
2 2
= ------ --- log cos --------i
2
a
4
= -------2- log cos --------i .
2
(21.51)
A graph of this function is shown in Figure 21.8 for three different values
of the gain. Note that as increases the function flattens and is close to 0
most of the time. Thus, as the gain goes to infinity, the integral in the
second term of the Lyapunov function will be close to zero in the range
1 a i 1 . This allows us to eliminate that term, and the high-gain
Lyapunov function then reduces to
1 T
T
V a = --- a Wa b a .
2
(21.52)
1.5
= 0.14
1
= 1.4
0.5
= 14
-1
-0.5
0.5
a
Figure 21.8 Second Term in the Lyapunov Function
By comparing Eq. (21.52) with Eq. (8.35), we can see that the high-gain
Lyapunov function is, in fact, a quadratic function:
1 T
1 T
T
T
V a = --- a Wa b a = --- a Aa + d a + c ,
2
2
(21.53)
2V a = A = W , d = b and c = 0 .
(21.54)
where
21-14
Effect of Gain
This is an important development, for now we can apply our results from
Chapter 8 on quadratic functions to the understanding of the operation of
Hopfield networks.
Recall that the shape of the surface of a quadratic function is determined
by the eigenvalues and eigenvectors of its Hessian matrix. The Hessian
matrix for our example Lyapunov function is
0 1 .
1 0
2V a = W =
(21.55)
1
1
= 1 = + 1 1 .
(21.56)
Thus, the eigenvalues are 1 = 1 and 2 = 1 . It follows that the eigenvectors are
z 1 = 1 and z 2 = 1 .
1
1
(21.57)
What does the surface of the high-gain Lyapunov function look like? We
know, since the Hessian matrix has one positive and one negative eigenvalue, that we have a saddle point condition. The surface will have a negative
curvature along the first eigenvector and a positive curvature along the
second eigenvector. The surface is shown in Figure 21.9.
The function does not have a minimum. However, the network is constrained to the hypercube a: 1 a i 1 by the amplifier transfer function. Therefore, there will be constrained minima at the two corners of the
hypercube
a = 1 and a = 1 .
1
1
(21.58)
When the gain is very small, there is a single minimum at the origin (see
Exercise E21.1). As the gain is increased, two minima move out from the
origin toward the two corners given by Eq. (21.58). Figure 21.3 displays an
intermediate case, where the gain is = 1.4 . The minima in that figure occur at
a = 0.57 and a = 0.57 .
0.57
0.57
21-15
(21.59)
21
21 Hopfield Network
In the general case, where there are more than two neurons in the network,
the high-gain minima will fall in certain corners of the hypercube
a: 1 a i 1 . We will discuss the general case in more detail in later sections, after we describe the Hopfield design process.
1
1
0.5
0.5
0
0
-0.5
-1
1
-0.5
0.5
0.5
0
-1
-1
-0.5
0.5
-0.5
-1
-0.5
-1
Hopfield Design
The Hopfield network does not have a learning law associated with it. It is
not trained, nor does it learn on its own. Instead, a design procedure based
on the Lyapunov function is used to determine the weight matrix.
Consider again the high-gain Lyapunov function
1 T
T
V a = --- a Wa b a .
2
(21.60)
The Hopfield design technique is to choose the weight matrix W and the
bias vector b so that V takes on the form of a function that you want to
minimize. Convert whatever problem you want to solve into a quadratic
minimization problem. Since the Hopfield network will minimize V , it will
also solve the original problem. The trick, of course, is in the conversion,
which is generally not straightforward.
Content-Addressable Memory
Content-Addressable
Memory
Hopfield Design
(21.61)
Each of these vectors consists of S elements, having the values 1 or 1 . Assume further that Q S , so that the state space is large, and that the prototype patterns are well distributed in this space, and so will not be close
to each other.
In order for a Hopfield network to be able to recall the prototype patterns,
the patterns must be minima of the Lyapunov function. Since the high-gain
Lyapunov function is quadratic, we need the prototype patterns to be (constrained) minima of an appropriate quadratic function. We propose the following quadratic performance index:
Q
1
J a = --2
pq
a .
(21.62)
q=1
If the elements of the vectors a are restricted to be 1 , this function is minimized at the prototype patterns, as we will now show.
Assume that the prototype patterns are orthogonal. If we evaluate the performance index at one of the prototype patterns, we find
Q
1
J p j = --2
pq
2
2
1
S
T
p j = --- p j p j = --- .
2
2
(21.63)
q=1
The second equality follows from the orthogonality of the prototype patterns. The last equality follows because all elements of p j are 1 .
Next, evaluate the performance index at a random input pattern a , which
is presumably not close to any prototype pattern. Each element in the sum
in Eq. (21.62) is an inner product between a prototype pattern and the input. The inner product will increase as the input moves closer to a proto-
21-17
21
21 Hopfield Network
type pattern. However, if the input is not close to any prototype pattern,
then all terms of the sum in Eq. (21.62) will be small. Therefore, J a will
be largest (least negative) when a is not close to any prototype pattern, and
will be smallest (most negative) when a is equal to any one of the prototype
patterns.
We have now found a quadratic function that accurately indicates the performance of the content-addressable memory. The next step is to choose the
weight matrix W and bias b so that the Hopfield Lyapunov function V will
be equivalent to the quadratic performance index J .
If we use the supervised Hebb rule to compute the weight matrix (with target patterns being the same as input patterns) as
Q
pq pq
W =
(21.64)
q=1
(21.65)
1 T
1 T
V a = --- a Wa = --- a
2
2
1
p q p q a = --2
T
q=1
pq pq a .
(21.66)
q=1
1
V a = --2
pq
a = J a .
(21.67)
q=1
Therefore, the Lyapunov function is indeed equal to the quadratic performance index for the content-addressable memory problem. The Hopfield
network output will tend to converge to the stored prototype patterns
(among other possible equilibrium points, as we will discuss later).
As noted in Chapter 7, the supervised Hebb rule does not work well if there
is significant correlation between the prototype patterns. In that case the
pseudoinverse technique has been suggested. Another design technique,
which is beyond the scope of this text, is given in [LiMi89].
In the best situation, where the prototype patterns are orthogonal, every
prototype pattern will be an equilibrium point of the network. However,
there will be many other equilibrium points as well. The network may well
converge to a pattern that is not one of the prototype patterns. A general
rule is that, when using the Hebb rule, the number of stored patterns can
21-18
Hopfield Design
be no more than 15% of the number of neurons.The reference [LiMi89] discusses more complex design procedures, which minimize the number of
spurious equilibrium points.
In the next section we will analyze the location of the equilibrium points
more closely.
Hebb Rule
Lets take a closer look at the operation of the Hopfield network when the
Hebb rule is used to compute the weight matrix and the prototype patterns
are orthogonal. (The following analysis follows the discussion in the Chapter 7, Problem P7.5.) The supervised Hebb rule is given by
Q
W =
pq pq
(21.68)
q=1
Wp j =
pq pq
p j = p j p j p j = Sp j ,
(21.69)
q=1
where the second equality holds because the prototype patterns are orthogonal, and the third equality holds because each element of p j is either 1 or
1 . Eq. (21.69) is of the form
Wp j = p j .
(21.70)
(21.71)
This space contains all vectors that can be written as linear combinations
of the prototype vectors. That is, any vector a that is a linear combination
of the prototype vectors is an eigenvector.
Wa = W 1 p 1 + 2 p 2 + + Q p Q
= 1 Wp 1 + 2 Wp 2 + + Q Wp Q
21
= 1 Sp 1 + 2 Sp 2 + + Q Sp Q
= S 1 p 1 + 2 p 2 + + Q p Q = Sa
21-19
(21.72)
21 Hopfield Network
The entire space R can be divided into two disjoint sets [Brog85],
R = XX ,
(21.73)
not just the one we are considering here.) Every vector in X is orthogonal
p q a = 0, q = 1 2 Q .
(21.74)
Therefore, if a X ,
Q
Wa =
pq pq
q=1
Q
T
a =
pq 0
= 0 = 0a.
(21.75)
q=1
(21.76)
21-20
Hopfield Design
Spurious Patterns
2
+2
(21.77)
Suppose that this had been designed using the Hebb rule with one prototype pattern (obviously not an interesting practical case):
p1 = 1 .
1
(21.78)
T
W = p1 p1 = 1 1 1 = 1 1 .
1
1 1
(21.79)
Then
Notice that
W' = W I = 0 1
1 0
(21.80)
corresponds to our original connection matrix. More about this in the next
section.
The high-gain Lyapunov function is
1 T
1 T
V a = --- a Wa = --- a 1 1 a .
2
2
1 1
The Hessian matrix for V a is
21-21
(21.81)
21
21 Hopfield Network
2V a = W = 1 1 .
1 1
(21.82)
1 = S = 2 , and 2 = 0 ,
(21.83)
(21.84)
(21.85)
= a: a 1 = a 2 .
(21.86)
(21.87)
21-22
Hopfield Design
-0.5
0.5
-1
-1.5
-2
1
-0.5
0.5
0
-0.5
-1
-1
-0.5
0.5
-1
-1
-0.5
0.5
Lyapunov Surface
In many discussions of the Hopfield network the diagonal elements of the
weight matrix are set to zero. In this section we will analyze the effect of
this operation on the Lyapunov surface. (See also Chapter 7, Exercise
E7.5.)
For the content-addressable memory network, all of the diagonal elements
of the weight matrix will be equal to Q (the number of prototype patterns),
since the elements of each p q are 1 . Therefore, we can zero the diagonal
by subtracting Q times the identity matrix:
W' = W QI .
(21.88)
Lets investigate how this change affects the form of the Lyapunov function. If we multiply this new weight matrix times one of the prototype vectors we find
W'p q = W QI p q = Sp q Qp q = S Q p q .
(21.89)
Therefore, S Q is an eigenvalue of W' , and the corresponding eigenspace is X , the space spanned by the prototype vectors.
If we multiply the new weight matrix times a vector from the orthogonal
(21.90)
X .
To summarize, the eigenvectors of W' are the same as the eigenvectors of
W , but the eigenvalues are now S Q and Q , instead of S and 0 . There-
21-23
21
21 Hopfield Network
fore, the eigenvalues of the Hessian matrix of the modified Lyapunov function, 2V' a = W' , are S Q and Q .
This implies that the energy surface will have negative curvature in X and
21-24
Summary of Results
Summary of Results
Hopfield Model
dn(t)
------------ = n(t) + Wa(t) + b
dt
a(t) = f n(t)
Input
Recurrent Layer
Sx1
SxS
b
Sx1
1/
.
n
n
Sx1
a
Sx1
f -1
dn/dt = - n + W f(n) + b
Lyapunov Function
ai
T
f u du b a
i=1 0
1 T
V a = --- a Wa +
2
S
da 2
d
d 1
V a = f a i i
d ai
dt
dt
i=1
If
d 1
d
f a i 0 , then V a 0 .
d ai
dt
21
Invariant Sets
The Invariant Set Consists of the Equilibrium Points.
L = Z = a:da dt = 0 a in the closure of G
21-25
21 Hopfield Network
Hopfield Attractors
The Equilibrium Points Are Stationary Points.
da(t)
If ------------ = 0 , then V a = 0 .
dt
dn(t)
V a = Wa + n b = -----------dt
Content-Addressable Memory
Q
W =
pq pq
and b = 0
q=1
2 = 0 , with eigenspace X .
21-26
Solved Problems
Solved Problems
P21.1 Assume the binary prototype vectors
1
p1 = 1
1
1
1
p2 = 1 .
1
1
i. Design a continuous-time Hopfield network (specify connection weights) to recognize these patterns, using the Hebb
rule.
ii. Find the Hessian matrix of the high-gain Lyapunov function
for this network. What are the eigenvalues and eigenvectors
of the Hessian matrix?
iii. Assuming large gain, what are the stable equilibrium points
for this Hopfield network?
i. First calculate the weight matrix from the reference vectors, using the
supervised Hebb rule.
1
W = p1 p1 + p2 p2 = 1
1
1
T
1
1
1
1
1
1
1
1
1
1
1 + 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1 ,
1
1
which simplifies to
2
W = 0
0
2
0
2
2
0
0
2
2
0
2
0 .
0
2
ii. The Hessian of the high-gain Lyapunov function, from Eq. (21.54), is
the negative of the weight matrix:
2
2V a = 0
0
2
21-27
0
2
2
0
0
2
2
0
2
0 .
0
2
21
21 Hopfield Network
The prototype patterns are orthogonal ( p 1 p 2 = 0 ). Thus, the eigenvalues are 1 = S = 4 and 2 = 0 . The eigenspace for 1 = 4 is
X = span p 1 , p 2 .
The eigenspace for 2 = 0 is the orthogonal complement of X :
= span
1
1 ,
1
1
1
1
1
1
where we have chosen two vectors that are orthogonal to both p 1 and p 2 .
iii. The stable points will be p 1 , p 2 p 1 p 2 since the negative of the prototype patterns will also be equilibrium points. There may be other equilibrium points, if other corners of the hypercube lie in the span p 1 , p 2 .
4
There are a total of 2 = 16 corners of the hypercube. Four will fall in X
T
and four will fall in X . The other corners are partly in X and partly in X .
P21.2 Consider a high-gain Hopfield network with a weight matrix and
bias given by
W = 1 1 and b = 1 .
1 1
1
i. Sketch a contour plot of the high-gain Lyapunov function
for this network.
T
21-28
Solved Problems
2V a I =
1 1
1 1
= 2 + 1 1 = 2 .
1 .
1
T
21-29
21
21 Hopfield Network
1.5
0.5
1
0.5
0
1
-0.5
0.5
0
-0.5
-1
-1
-0.5
0.5
-1
-0.5
-1
0.5
ii. All trajectories will converge to 1 1 , regardless of the initial conditions. As we can see in Figure P21.2, the energy function has only one minT
imum, which is located at 1 1 . (Keep in mind that the output of the
network is constrained to fall within the hypercube a: 1 a i 1 .)
1
2
0.5
1
0
0
-1
-2
1
-0.5
0.5
0.5
-0.5
-1
-1
-0.5
0.5
-1
-0.5
-1
p2 = 1
1
21-30
Solved Problems
iii. What are the stable points for this Hopfield network (assume large gain)? What are the basins of attraction?
iv. How well does this network perform the pattern recognition
problem?
i.
or any linear combination. (The entire is the eigenspace for the eigenvalue = 2 .)
iii. From Chapter 8 we know that when the eigenvalues of the Hessian are
equal, the contours will be circular. Because the eigenvalues are negative,
the function will have a single maximum at the origin. There will be four
minima at the four corners of the hypercube a: 1 a i 1 . There are also
four saddle points. The high-gain Lyapunov function is displayed in Figure
P21.3.
21
21-31
21 Hopfield Network
0
0.5
-0.5
-1
0
-1.5
-2
1
-0.5
0.5
0.5
-0.5
-1
-1
-0.5
0.5
-1
-0.5
-1
0
0.5
-0.25
-0.5
0
-0.75
-1
1
-0.5
0.5
0.5
-0.5
-1
-1
-0.5
0.5
-1
-0.5
-1
Solved Problems
two-bit pattern has been stored, the network is not very useful. This is not
unexpected, since the number of patterns that the Hebb rule is expected to
store is only 15% of the number of neurons. Since we only have two neurons, we cant expect to successfully store many patterns. Try Exercise
E21.2 for a better network.
P21.4 A Hopfield network has the following high-gain Lyapunov function:
1
2
2
V a = --- 7 a 1 + 12a 1 a 2 2 a 2 .
2
i. Find the weight matrix.
ii. Find the gradient vector of the Lyapunov function.
iii. Find the Hessian matrix of the Lyapunov function.
iv. Sketch a contour plot of the Lyapunov function.
v. Sketch the path that a steepest descent algorithm would folT
low for V a with an initial condition of 0.25 0.25 .
i.
21-33
21
21 Hopfield Network
2V a I =
= + 5 50 = + 10 5 .
4
0.5
0
-4
-8
1
-0.5
0.5
0.5
-0.5
-1
-1
-0.5
0.5
-1
-0.5
-1
21-34
Solved Problems
the trajectory hits the edge of the hypercube, it follows the edge down to the
minimum point. The resulting trajectory is shown in Figure P21.5.
The high-gain Lyapunov function is only an approximation, since it assumes infinite gain. As a comparison, Figure P21.6 illustrates the
Lyapunov function, and the Hopfield trajectory, for a gain of 0.5 .
1
8
0.5
6
4
2
0
-2
-4
-6
1
-0.5
0.5
0.5
-0.5
-1
-1
-0.5
0.5
-1
-0.5
-1
ai 2
i 1
= a1 + a2 2 ,
i=1
ai 2
i=1
1
2i 1
a i a i 1 ,
--- 2
2
i 1
i=1
where the first term represents the A/D conversion error, and the
second term forces a 1 and a 2 to take on values of 0 or 1 .
Show that this performance index can be written as the Lyapunov
function of a Hopfield network and define the appropriate weight
matrix and bias vector.
21-35
21
21 Hopfield Network
ai 2
i=1
i 1
= y 2y a i 2
i 1
2i 1
a i a i 1 =
2
i=1
ai aj 2
i=1
j = 1i = 1
i 1 + j 1
2
2 2i 1
ai 2
i=1
ai 2
2i 1
i=1
2
2
2
1 2
i 1 + j 1
2i 1
i
J a = --- y + a i a j 2
+ ai 2
2 y .
2
j = 1i = 1
i=1
ij
The first term is not a function of a . Therefore, it does not affect where the
minima will occur, and we can ignore it.
We now want to show that this performance index takes the form of a highgain Lyapunov function:
1 T
T
V a = --- a Wa b a .
2
This will be the case if
W =
0 2 and b =
2 0
1
y --2 .
2y 2
In this Hopfield network, unlike the content-addressable memory, the input to the network is the scalar y , which is then used to compute the bias
vector. In the content-addressable memory, the inputs to the network were
vector patterns, which became the initial conditions on the network outputs.
Note that in this network the transfer function must limit the output to the
range 0 a 1 . One transfer function that could be used is
1
-.
f n = --------------------- n
1 e
21-36
Epilogue
Epilogue
In this chapter we have introduced the Hopfield model, one of the most influential neural network architectures. One of the reasons that Hopfield
was so influential was that he emphasized the practical considerations of
the network. He described how the network could be implemented as an
electrical circuit, and VLSI implementations of Hopfield-type networks
were built at an early stage.
Hopfield also explained how the network could be used to solve practical
problems in pattern recognition and optimization. Some of the applications
that Hopfield proposed for his networks were: content-addressable memory
[Hopf82], A/D conversion [TaHo86] and linear programming and optimization tasks, such as the traveling salesman problem [HoTa85].
One of Hopfields key contributions was the application of Lyapunov stability theory to the analysis of his recurrent networks. He also showed that,
for high-gain amplifiers, the Lyapunov function for his network was a quadratic function, which was minimized by the network. This led to several
design procedures. The idea behind the development of the design techniques was to convert a given task into a quadratic minimization problem,
which the network could then solve.
The Hopfield network is the last topic we will cover in any detail in this
text. However, we have certainly not exhausted all of the important neural
network architectures. In the next chapter we will give you some ideas
about where to go next to explore the subject further.
21
21-37
21 Hopfield Network
Further Reading
[Ande72]
J. Anderson, A simple neural network generating an interactive memory, Mathematical Biosciences, vol. 14, pp.
197220, 1972.
Anderson proposed a linear associator model for associative memory. The model was trained, using a generalization of the Hebb postulate, to learn an association between
input and output vectors. The physiological plausibility of
the network was emphasized. Kohonen published a closely
related paper at the same time [Koho72], although the two
researchers were working independently.
[AnSi77]
[CoGr83]
[Gros67]
21-38
Further Reading
[Hopf82]
[Hopf84]
J. J. Hopfield, Neurons with graded response have collective computational properties like those of two-state neurons, Proceedings of the National Academy of Sciences, vol.
81, pp. 30883092, 1984.
Hopfield demonstrates how an analog electrical circuit can
function as a model for a large network of neurons with a
graded response. The Lyapunov function for this network
is derived and is used to design a network for use as a content-addressable memory.
[HoTa85]
J. J. Hopfield and D. W. Tank, Neural computation of decisions in optimization problems, Biological Cybernetics,
vol. 52, pp. 141154, 1985.
This article describes the application of Hopfield networks
to the solution of optimization problems. The traveling
salesman problem, in which the length of a trip through a
number of cities with only one visit to each city is minimized, is mapped onto a Hopfield network.
[Koho72]
T. Kohonen, Correlation matrix memories, IEEE Transactions on Computers, vol. 21, pp. 353359, 1972.
Kohonen proposed a correlation matrix model for associative memory. The model was trained, using the outer product rule (also known as the Hebb rule), to learn an
association between input and output vectors. The mathematical structure of the network was emphasized. Anderson published a closely related paper at the same time
[Ande72], although the two researchers were working independently.
21
21-39
21 Hopfield Network
[LiMi89]
[McPi43]
[TaHo86]
D. W. Tank and J. J. Hopfield, Simple neural optimization networks: An A/D converter, signal decision circuit
and a linear programming circuit, IEEE Transactions on
Circuits and Systems, vol. 33, no. 5, pp. 533541, 1986.
The authors describe how Hopfield neural networks can be
designed to solve certain optimization problems. In one example the Hopfield network implements an analog-to-digital conversion.
21-40
Exercises
Exercises
E21.1 In the Hopfield network example starting on page 18-8 we used a gain of
= 1.4 . Figure 21.3 displays the Lyapunov function for that example. The
high-gain Lyapunov function for the example is shown in Figure 21.9.
i. Show that the minima of the Lyapunov function for this example
will be located at points where n 1 = n 2 = f n 1 = f n 2 . (Use Eq.
(21.42) and set the gradient of V a to zero.)
ii. Investigate the change in location of the minima as the gain is varied from = 0.1 to = 10 .
2+2
ans =
4
iii. Sketch the contour plot for several different values of gain in this interval. You will probably need to use MATLAB for this.
E21.2 In Problem P21.3 we used the supervised Hebb rule to design a Hopfield
network to recognize the following patterns:
p1 = 1
1
p2 = 1 .
1
If we use another design rule [LiMi89], we find the following weight matrix
and bias
W = 1 0
0 10
b =
0 .
11
i. Graph the contour plot for the high-gain Lyapunov function, if this
weight matrix and bias are used.
ii. Discuss the difference between the performance of this Hopfield
network and the one designed in Problem P21.3.
2+2
ans =
4
iii. Write a MATLAB M-file to simulate the Hopfield network. Use the
ode45 routine. Plot the responses of this network for several initial
conditions.
E21.3 A Hopfield network has the following high-gain Lyapunov function:
1
2
2
V a = --- a 1 + 2a 1 a 2 + 4 a 2 + 6a 1 + 10a 2 .
2
i. Find the weight matrix and bias vector for this network.
ii. Find the gradient and Hessian for V a .
21-41
21
21 Hopfield Network
p1 = 1 1 1 1 , p2 = 1 1 1 1 .
i. Design a continuous-time Hopfield network (specify connection
weights and biases only) to recognize these patterns, using the Hebb
rule.
ii. Find the Hessian matrix of the high-gain Lyapunov function for this
network. What are the eigenvalues and eigenvectors of the Hessian
matrix? (This requires very little computation.)
iii. Assuming large gain, what are the stable equilibrium points for this
Hopfield network?
E21.6 Repeat Exercise E21.5 for the following prototype vectors.
T
i. p 1 = 1 1 1 1 , p 2 = 1 1 1 1 .
T
ii. p 1 = 1 1 1 1 , p 2 = 1 1 1 1 .
T
iii. p 1 = 1 1 1 1 1 1 , p 2 = 1 1 1 1 1 1 .
E21.7 Consider a high-gain Hopfield network with weight matrix and bias given
by:
W = 1 3 and b = 3 .
3 9
1
21-42
Exercises
0.5
0.5
E21.8 Design a high-gain Hopfield network (give the weights and the biases) with
only one stable equilibrium point:
1
1
Explain your procedure, and show all steps. (Do not use the Hebb rule.)
E21.9 Consider a high-gain Hopfield network with weight matrix and bias given
by:
W = 1 1 and b = 1 .
1 1
1
i. Sketch a contour plot of the high-gain Lyapunov function for this
network.
ii. Assuming a large gain, what are the stable equilibrium points for
this Hopfield network? What can you say about the basins of attraction for these stable equilibrium points? Explain your answers.
E21.10 Repeat E21.9 for the following weight and bias:
W = 1 0 and b = 1 .
0 1
1
2+2
ans =
4
E21.11 In Exercise E7.11 we asked the question: How many prototype patterns
can be stored in one weight matrix? Repeat that problem using the
Hopfield network. Begin with the digits 0 and 1. (The digits are shown
at the end of this problem.) Add one digit at a time up to 6, and test how
often the correct digit is reconstructed after randomly changing 2, 4 and 6
pixels.
i. First use the Hebb rule to create the weight matrix for the digits 0
21-43
21
21 Hopfield Network
and 1. Then randomly change 2 pixels of each digit and apply the
noisy digits to the network. Repeat this process 10 times, and record
the percentage of times in which the correct pattern (without noise)
is produced at the output of the network. Repeat as 4 and 6 pixels of
each digit are modified. The entire process is then repeated when
the digits 0, 1 and 2 are used. This continues, one digit at a
time, until you test the network when all of the digits 0 through
6 are used. When you have completed all of the tests, you will be
able to plot three curves showing percentage error versus number of
digits stored, one curve each for 2, 4 and 6 pixel errors.
ii. Repeat part (i) using the pseudoinverse rule (see Chapter 7), and
compare the results of the two rules.
iii. For extra credit, repeat part (i) using the method described in
[LiMi89]. In that paper it is called Synthesis Procedure 5.1.
p1
p2
p3
21-44
p4
p5
p6
p7
p8
p9
p10
Objectives
22
22-1
22-2
Pre-Training Steps
22-3
Selection of Data
22-3
Data Preprocessing
22-5
22-8
22-13
Weight Initialization
22-13
22-14
Stopping Criteria
22-14
22-16
22-18
Fitting
22-18
Pattern Recognition
22-21
Clustering
22-23
Prediction
22-24
22-27
Sensitivity Analysis
22-28
Epilogue
22-30
Further Reading
22-31
Objectives
Previous chapters have focused on particular neural network architectures
and training rules, with an emphasis on fundamental understanding. In
this chapter, we will discuss some practical training tips that apply to a variety of networks. No derivations are provided for the techniques that are
presented here, but we have found these methods to be useful in practice.
There will be three basic sections in this chapter. The first section describes
things that need to be done prior to training a network, such as collecting
and preprocessing data and selecting the network architecture. The second
section addresses network training itself. The final section considers posttraining analysis.
22
22-1
Collect/Preprocess
Data
Select Network
Type/Architecture
Analyze Network
Performance
Select Training
Algorithm
Initialize Weights
&
Train Network
Use Network
22-2
Pre-Training Steps
Pre-Training Steps
There are a number of steps that need to be performed before the network
is trained. They can be grouped into three categories: Selection of Data,
Data Preprocessing, and Choice of Network Type and Architecture.
Selection of Data
It is generally difficult to incorporate prior knowledge into a neural network, therefore the network will only be as good as the data that is used to
train it. Neural networks represent a technology that is at the mercy of the
data. The training data must span the full range of the input space for
which the network will be used. As we discussed in Chapter 13, there are
training methods we can use to insure that the network interpolates accurately throughout the range of the data provided (generalizes well). However, it is not possible to guarantee network performance when the inputs
to the network are outside the range of the training set. Neural networks,
like other nonlinear black box methods, do not extrapolate well.
It is not always easy to be sure that the input space is adequately sampled
by the training data. For simple problems, in which the dimension of the
input vector is small, and each element of the input vector can be chosen
independently, we can sample the input space using a grid. However, these
conditions are not often satisfied. For many problems, the dimension of the
input space is large, which precludes the use of grid sampling. In addition,
it is often the case that the input variables are dependent. For example,
consider Figure 22.2. The shaded area represents the range over which the
two inputs can vary. Even though each variable can range from -1 to 1, we
would not need to create a grid in which both variables vary throughout
their range, as shown by the dots in Figure 22.2. The network only needs
to fit the function in the shaded area, since this is where the network will
be used. It would be inefficient to fit the network outside the range of its
use. This is especially true when the input dimension is large.
22
22-3
p2
p1
22-4
Pre-Training Steps
work. The amount of data that is required depends on the complexity of the
underlying function that we are trying to approximate (or the complexity
of the decision boundaries that we are trying to implement). If the function
to be approximated is very complex, with many inflection points, then this
requires a large amount of data. If the function is very smooth, then the
data requirements are significantly reduced (unless the data is very noisy).
The choice of the data set size is closely related to the choice of the number
of neurons in the neural network. This is discussed in the Choice of Network Architecture section on page 22-8. Of course, we generally dont know
how complex the underlying function is before we begin training the network. For this reason, as we discussed earlier, the entire neural network
training process is iterative. At the completion of training we will analyze
the performance of the network. The results of that analysis can help us decide if we have enough data or not.
Data Preprocessing
The main purpose of the data preprocessing stage is to facilitate network
training. Data preprocessing consists of such steps as normalization, nonlinear transformations, feature extraction, coding of discrete inputs/targets, handling of missing data, etc. The idea is to perform preliminary
processing of the data to make it easier for the neural network training to
extract the relevant information.
For example, in multilayer networks, sigmoid transfer functions are often
used in the hidden layers. These functions become essentially saturated
when the net input is greater than three ( exp 3 0.05 ). We dont want
this to happen at the beginning of the training process, because the gradient will then be very small. In the first layer, the net input is a product of
the input times the weight plus the bias. If the input is very large, then the
weight must be small in order to prevent the transfer function from becoming saturated. It is standard practice to normalize the inputs before applying them to the network. In this way, initializing the network weights to
small random values guarantees that the weight-input product will be
small. Also, when the input values are normalized, the magnitudes of the
weights have a consistent meaning. This is especially important when using regularization, as described in Chapter 13. Regularization requires the
weight values to be small. However, small is a relative term; if the input
values are very small, we need large weights to produce a significant net
input. Normalizing the inputs clarifies the meaning of small weights.
Normalization
There are two standard methods for normalization. The first method normalizes the data so that they fall into a standard range typically -1 to 1.
This can be done with
n
p = 2p p
min
./ p
max
min
1,
(22.1)
min
where p
is the vector containing the minimum values of each element of
max
the input vectors in the data set, p
contains the maximum values, ./
22-5
22
represents an element-by-element division of two vectors, and p is the resulting normalized input vector.
An alternative normalization procedure is to adjust the data so that they
have a specified mean and variance typically 0 and 1. This can be done
with the transformation
n
p = p p
mean
mean
./p
std
(22.2)
std
where p
is the average of the input vectors in the data set, and p is
the vector containing the standard deviations of each element of the input
vectors.
Generally, the normalization step is applied to both the input vectors and
the target vectors in the data set.
In addition to normalization, which involves a linear transformation, nonNonlinear Transformation linear transformations are sometimes also performed as part of the preprocessing stage. Unlike normalization, which is a standard process that
can be applied to any data set, these nonlinear transformations are casespecific. For example, many economic variables show a logarithmic dependence [BoJe94]. In that case, it might be appropriate to take the logarithm
of the input values before applying them to the neural network. Another
example is molecular dynamics simulation [RaMa05], in which atomic forces are calculated as functions of distances between atoms. Since it is known
that the forces are inversely related to the distances, we might perform the
reciprocal transformation on the inputs, before applying them to the network. This represents one way of incorporating prior knowledge into neural
network training. If the nonlinear transformation is cleverly chosen, it can
make the network training more efficient. The preprocessing will off-load
some of the work required of the neural network in finding the underlying
transformation between inputs and targets.
Feature Extraction
Principal Components
22-6
Pre-Training Steps
Softmax
Another transfer function that is used in the output layer of multilayer pattern recognition networks is the softmax function. This transfer function
has the form
S
a i = f n i = exp n i
exp nj .
(22.3)
j=1
22
22-7
The outputs of the softmax transfer function can be interpreted as the probabilities associated with each class. Each output will fall between 0 and 1,
and the sum of the outputs will equal 1. See Chapter 24 for an example application of the softmax transfer function.
Missing Data
Another practical issue to consider is missing data. It is often the case, especially when dealing with economic data, for example, that some of the
data is missing. For instance, we might have an input vector containing 20
economic variables that are collected at monthly intervals. There may be
some months in which one or two of the 20 variables were not collected
properly. The simplest solution to this problem would be to throw out the
data for any month in which any of the variables were missing. However,
we might be very limited in the amount of data available, and it might be
very expensive to collect additional data. In these cases, we would like to
make full use of any data that we have, even if it is incomplete.
There are several strategies for dealing with missing data. If the missing
data occurs in an input variable, one possibility is to replace the missing
value with the average value for that particular input variable. At the same
time, we could add an additional flag element to the input vector that
would indicate that missing data for that input variable had been replaced
with the average. This additional element of the input vector could be assigned the value 1 when the input variable was available, and 0 when the
input variable was missing for that case. This would provide the neural
network with information about which variables were missing. An additional flag element would be added to the input vector for every input variable that contained missing points.
If the missing data occurs in an element of the target, then the performance
index can be modified so that errors associated with the missing target values are not included. All known target values will contribute to the performance index, but missing target values will not.
Pre-Training Steps
Clustering
Clustering, or segmentation, is another use for neural networks. In clustering problems, you want a neural network to group data by similarity. For
example, businesses may wish to perform market segmentation, which is
22-9
22
done by grouping people according to their buying patterns. Computer scientists may want to perform data mining by partitioning data into related
subsets. Biologists may wish to perform bioinformatic analyses, such as
grouping genes with related expression patterns.
Any of the competitive networks described in Chapter 16 could be used for
clustering. The self-organizing feature map (SOFM) is the most popular
network for clustering. The main advantage of the SOFM is that it allows
visualization of high-dimensional spaces.
For an example of training a neural network for a clustering problem, see
Chapter 26.
Prediction
Prediction also falls under the categories of time series analysis, system
identification, filtering or dynamic modeling. The idea is that we wish to
predict the future value of some time series. An equities trader might want
to predict the future value of some security. A control engineer might want
to predict a future value of the concentration of some chemical, which is the
output of a processing plant. A power systems engineer might want to predict outages on the electric grid.
Prediction requires the use of dynamic neural networks, as discussed in
Chapter 14. The specific form of the network will depend on the particular
application. The simplest network for nonlinear prediction is the focused
time-delay neural network, which is shown in Figure 22.3. This is part of a
general class of dynamic networks, called focused networks, in which the
dynamics appear only at the input layer of a static multilayer feedforward
network. This network has the advantage that it can be trained using static
backpropagation algorithms, since the tapped-delay-line at the input of the
network can be replaced with an extended vector of delayed values of the
input.
Inputs
Layer 1
Layer 2
p1(t)
T
D
L
a (t)
IW
1,1
n (t)
a (t)
LW2,1
S1x1
S x (R d)
S2xS1
S2x1
n (t)
2
S x1
1
R
S x1
S1x1
S2x1
S2
22-10
Pre-Training Steps
example, the voltage applied to a motor, and the output could represent the
angular position of a robot arm. As with the focused time-delay neural network, the NARX network can be trained with static backpropagation. The
two tapped-delay-lines can be replaced with extended vectors of delayed inputs and targets. We can use targets, instead of feeding back the network
outputs (which would require dynamic backpropagation for training), because the output of the network should match the targets when training is
complete.This is discussed in more detail in Chapter 27.
Inputs
Layer 1
p1(t)
T
D
L
1
Layer 2
n1(t)
a1(t)
IW1,1
a2(t)
LW2,1
S x1
S1xR
S xS
R x1
S2x1
S x1
1
R
n (t)
b1
S x1
S1x1
T
D
L
LW
S x1
S2
1,3
22
Input Selection
venting overfitting during training. The input selection process for nonlinear networks can be quite difficult, and there is no perfect solution. The
Bayesian regularization method (Eq. (13.23)) can be modified to assist in
input selection. It is possible to have different parameters for different
sets of weights. For example, we can let each column of the weight matrix
in the first layer of a multilayer network have its own parameter. If a
given element of the input vector is irrelevant, then the corresponding
parameter would become large and force all elements of that column of the
weight matrix to be small. That element could then be eliminated from the
input vector.
Another technique that can assist in pruning the input vector is a sensitivity analysis of the trained network. In the Sensitivity Analysis section on
page 22-28 we discuss this technique.
Weight Initialization
Before training the network, we need to initialize the weights and biases.
The method we use will depend on the type of network. For multilayer networks, the weights and biases are generally set to small random values
(e.g., uniformly distributed between -0.5 and 0.5, if the inputs are normalized to fall between -1 and 1). As we discussed in Chapter 12, if we set the
weights and biases to zero, the initial condition may fall on a saddle point
of the performance surface. If we make the initial weights large, the initial
condition can fall on a flat part of the performance surface, caused by saturation of the sigmoid transfer functions.
There is another approach to setting the initial weights and biases for a
two-layer network. It was introduced by Widrow and Nguyen [WiNg90].
The idea is to set the magnitude of the weights in the first layer so that the
1
linear region of each sigmoid function covers 1 S of the range of the input.
The biases are then randomly set, so that the center of each sigmoid function falls randomly in the input space. The details of the method are as follows (assuming the inputs to the network have been normalized to values
between -1 and 1).
1
1 1R
= 0.7 S
22
22-13
and iw .
For competitive networks, the weights can also be set as small random
numbers. Another possibility is to randomly select some of the input vectors in the training set to become initial rows of the weight matrix. In this
way, we can be sure that the initial weights will fall within the range of the
input vectors, so we will be less likely to have dead units, as described in
Chapter 16. For the SOM, dead units are not a problem. The initial neighborhood size is set large enough so that all neurons will have the opportunity to learn during the initial stages of training. This will move all weight
vectors into the appropriate region of the input space. Training can converge faster, however, if rows of the weight matrix are initially placed in
the active input region.
22-14
Stopping Criteria
For most applications of neural networks, the training error never converges identically to zero. The error can reach zero for the perceptron network,
assuming a linearly separable problem, as we showed in Chapter 4. However, it is unlikely to happen for multilayer networks. For this reason, we
need to have other criteria for deciding when to stop the training.
We can stop the training when the error reaches some specified limit. However, it is usually difficult to know what an acceptable error level is. The
simplest criterion is to stop the training after a fixed number of iterations.
Because it is also difficult to know how many iterations will be required,
the maximum iteration number is generally set reasonably high. If the
weights have not converged after the maximum number of iterations has
been reached, we can restart training, using the final weights from the first
run as initial conditions for the restart. (We will talk more about how to tell
if a network has converged in the Post-Training Analysis section on page
22-18.)
Another stopping criterion is the norm of the gradient of the performance
index. If this norm reaches a sufficiently small threshold, then the training
can be stopped. Since the gradient should be zero at a minimum of the performance index, this criterion will stop the algorithm when it gets close to
the minimum. Unfortunately, as we have seen in Chapter 12, the performance surface for multilayer networks can have many flat regions, where
the norm of the gradient will be small. For this reason, the threshold for
6
the minimum norm should be set to a very small value (e.g., 10 for mean
square error performance indices, with normalized targets), so that the
training does not end prematurely.
We can also stop the training when the reduction in the performance index
per iteration becomes small. As with the norm of the gradient, this criterion
can stop the training too early. During the training of multilayer networks,
the performance can remain almost constant for a number of iterations before dropping suddenly. When training is complete, it is useful to view the
training performance curve on a log-log scale, as in Figure 22.5, to verify
convergence.
If we are using early stopping, as discussed in Chapter 13, to prevent overfitting, then we will stop the training when the performance on the validation set increases for a set number of iterations. In addition to preventing
overfitting, this stopping procedure also provides a significant reduction in
computation; for most practical problems, the validation error will increase
before any of the other stopping criteria are reached.
As shown in Figure 22.1, neural network training is an iterative process.
Even after the training algorithm has converged, post-training analysis
may suggest that the network be modified and retrained. In addition, several training runs should be made for each potential network to ensure that
a global minimum has been reached.
22-15
22
10
10
10
10
10
10
10
10
10
10
10
Epochs
1
T
F x = --------- tq aq tq aq ,
M
QS q = 1
or
22-16
(22.4)
1
2
F x = --------- t a i q .
M i q
QS q = 1 i = 1
(22.5)
The scale factor that occurs outside the sum has no effect on the location of
the optimum weights. Therefore, the sum square error performance index
will produce the same weights as the mean square error performance index. However, the appropriate scaling can be useful when comparing errors
on data sets of different size.
While mean square error is the most common performance index, there are
others that have been used. For example, we could use mean absolute error. This would be similar to Eq. (22.5), except that the absolute value of
the error would be used, instead of the square of the error. This performance index is generally less sensitive to one or two large errors in the data
set, and is therefore somewhat more robust to outliers than is the mean
square error algorithm. This concept can be extended to any power of the
absolute error, as follows
Q
1
K
F x = ---------t a i q ,
M i q
QS q = 1 i = 1
(22.6)
Cross-Entropy
Fx =
a i q
-.
t i q ln ------t i q
(22.7)
q = 1i = 1
Here we assume that the target values are 0 and 1, and they identify which
of the two classes the input vector belongs to. The softmax transfer function
22
22-17
is generally used in the last layer of the neural network, if the cross-entropy performance index is used.
As a closing note on the choice of performance index, recall from Chapter
11 that the backpropagation algorithm for computing training gradients
will work for any differentiable performance index. If you change the performance index, you only need to change the initialization of the sensitivities in the last layer (see Eq. (11.37)).
Post-Training Analysis
Before using a trained neural network, we need to analyze it to determine
if the training was successful. There are many techniques for post-training
analysis. We will discuss some of the more common ones. Since these techniques vary, depending on the application, we will organize them according
to these four application areas: fitting, pattern recognition, clustering and
prediction.
Fitting
One useful tool for analyzing neural networks trained for fitting problems
is a regression between the trained network outputs and the corresponding
targets. We fit a linear function of the form
a q = mt q + c + q ,
22-18
(22.8)
Post-Training Analysis
where m and c are the slope and offset, respectively, of the linear function,
t q is a target value, a q is a trained network output, and q is the residual
error of the regression.
The terms in the regression can be computed as follows:
Q
tq t aq a
q=1
= ---------------------------------------------- ,
m
Q
tq t
(22.9)
q=1
t,
c = a m
(22.10)
where
Q
1
a = ---Q
Outliers
q=1
1
a q , t = --Q
tq .
(22.11)
q=1
Figure 22.6 shows an example regression analysis. The blue line represents
the linear regression, the thin black line represents the perfect match
a q = t q , and the circles represent the data points. In this example, we can
see that the match is pretty good, although not perfect. The next step would
be to investigate data points that fall far from the regression line. For example, there are two points around t = 27 and a = 17 that seem to be outliers. We would investigate these points to see if there was a problem with
the data. This could be a bad data point, or it could be located far from other
training points. In the latter case, we would need to collect more data in
that region.
In addition to computing the regression coefficients, we often also compute
the correlation coefficient between the t q and a q , which is also known as
the R value:
Q
tq t aq a
q=1
R = ---------------------------------------------- ,
Q 1 s t s a
(22.12)
where
Q
st =
1
------------Q1
tq t
q=1
and s a =
1
------------Q1
aq a .
(22.13)
q=1
22
22-19
50
40
30
20
10
10
15
20
25
30
35
40
45
50
t
Figure 22.6 Regression Between Trained Network Outputs and Targets
The R value can generally range from -1 to 1, but we would expect it to be
close to 1 for our neural network application. If R = 1 , then all of the data
points will fall exactly on the regression line. If R = 0 , then the data will
not be concentrated around the regression line, but will be randomly scattered. For the data of Figure 22.6, R = 0.965 . We can see that the data does
not fall exactly on the regression line, but the variation is relatively small.
2
When the R or R values are significantly less than 1, then the neural network has not done a good job of fitting the underlying function. A close
analysis of the scatter plot may be helpful in determining problems in the
fit. For example, we might find that when the targets are large there is
more spread in the scatter plot. (This is not the case in Figure 22.6.) We
might also notice that there are fewer data points with large targets. This
would indicate that we need to have more data points in the training set for
these target values.
Recall that the original data set was divided into training, validation (if
early stopping is used) and testing subsets. The regression analysis should
be performed on each subset individually, as well as the full data set. Differences between the subsets would indicate overfitting or extrapolation.
For example, if the training set shows accurate fitting, but the validation
and test results are poor, then this would indicate overfitting (which can
sometimes happen, even when early-stopping is used). In this case, we
might reduce the size of the neural network and retrain. If both the training and validation results are good, but the testing results are poor, then
22-20
Post-Training Analysis
this could indicate extrapolation (where the testing data falls outside the
training and validation data). In this case, we need to provide more data
for training and validation. If the results for all three data sets are poor,
then it might be necessary to increase the number of neurons in the network. Another choice is to increase the number of layers in the network. If
you start with a single hidden layer, and the results are poor, then a second
hidden layer could be helpful. First, try more neurons in the single hidden
layer, and then increase the number of layers.
In addition to the regression/scatter plot, another tool that can identify outliers is a histogram of the errors, as shown in Figure 22.7. The y-axis represents the number of errors that falls within each interval on the x-axis.
Here we can see that two errors are greater than 8. These represent the
same two errors that we identified as outliers in Figure 22.6.
140
120
100
80
60
40
20
0
8
10
12
e = ta
Figure 22.7 Histogram of Network Errors
Pattern Recognition
Confusion Matrix
False Negative
22
False Positive
called Type II errors. The upper right cell shows that one input from Class
2 was misclassified by the network as Class 1. This would be considered a
false positive or a Type I error.
Output Class
Confusion Matrix
47
22.0%
1
0.5%
97.9%
2.1%
4
1.9%
162
75.7%
97.6%
2.4%
92.2%
7.8%
99.4%
0.6%
97.7%
2.3%
2
Target Class
22-22
Post-Training Analysis
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0
0.2
0.4
0.6
False Positive Rate
0.8
Clustering
Quantization Error
Topographic Error
Distortion Measure
The SOM is the most commonly used network for clustering. There are several measures of SOM performance. One is quantization error. This is the
average distance between each input vector and the closest prototype vector. It measures the map resolution. This can be made artificially small, if
we use a large number of neurons. If there are as many neurons as input
vectors in the data set, then the quantization error could be zero. This
would represent overfitting. If the number of neurons is not significantly
smaller than the number of input vectors, then the quantization error is
not meaningful.
Another measure of SOM performance is topographic error. This is 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.
Topographic error measures the preservation of the topology. In a welltrained SOM, prototypes that are neighbors in the topology should also be
neighbors in the input space. In this case, the topographic error should be
zero.
The performance of the SOM can also be assessed by the distortion measure:
Q
Ed =
h ic
iw
pq ,
(22.14)
q = 1i = 1
22-23
22
c q = arg min j jw p q .
(22.15)
iw jw
h ij = exp -------------------------- ,
2
2d
(22.16)
Prediction
As we discussed earlier, one application of neural networks is the prediction of the future values of some time series. For prediction problems, we
use dynamic networks, such as the focused time-delay neural network
shown in Figure 22.3. There are two important concepts that are used
when analyzing a trained prediction network:
1. the prediction errors should not be correlated in time, and
2. the prediction errors should not be correlated with the input sequence.
If the prediction errors were correlated in time, then we would be able to
predict the prediction errors and, therefore, improve our original prediction. Also, if the prediction errors were correlated with the input sequence,
then we would also be able to use this correlation to predict the errors.
Autocorrelation Function
In order to test the correlation of the prediction errors in time, we can use
the sample autocorrelation function:
Q
1
R e = -----------Q
e t e t + .
(22.17)
t=1
White Noise
If the prediction errors are uncorrelated (white noise), then we would expect R e to be close to zero, except when = 0 . To determine if R e is
close to zero, we can set an approximate 95% confidence interval [BoJe96]
using the range
2R e 0
2R e 0
-.
---------------- R e ---------------Q
Q
(22.18)
Post-Training Analysis
function does not fall totally within the bounds defined by Eq. (22.18),
which are indicated by the dashed lines in the figure. Figure 22.11 shows
the corresponding autocorrelation function when a network has been successfully trained. R e falls within the bounds, except at = 0 .
Correlation in the prediction errors can indicate that the length of the
tapped delay lines in the network should be increased.
0.2
0.1
0.1
40
20
20
40
0.02
0.01
40
20
20
40
22
1
R pe = -----------Q
p t e t + .
(22.19)
t=1
If there is no correlation between the prediction errors and the input sequence, then we would expect R pe to be close to zero for all . To determine if R pe is close to zero, we can set an approximate 95% confidence
interval [BoJe96] using the range
2 Re 0 Rp 0
2 Re 0 Rp 0
-.
--------------------------------------- R pe --------------------------------------Q
Q
(22.20)
This concept is illustrated in Figure 22.12 and Figure 22.13. Figure 22.12
shows a sample cross-correlation function for the prediction errors of a network that has not been adequately trained. We can see that the cross-correlation function does not fall totally within the bounds defined by Eq.
(22.20), which are indicated by the dashed lines. Figure 22.13 shows the
corresponding cross-correlation function when a network has been successfully trained. R pe falls within the bounds for all .
0.2
0.1
0.1
40
20
20
40
22-26
Post-Training Analysis
0.02
0.01
0.01
0.02
40
20
20
40
22
22-27
If the validation, training and test errors are all similar in size, but the errors are too large, then it is likely that the network is not powerful enough
to fit the data. In this case, we should increase the number of neurons in
the hidden layer and retrain the network. If Bayesian regularization is
used, this situation is indicated by the effective number of parameters becoming equal to the total number of parameters. When the network is large
enough, the effective number of parameters should remain below the total
number of parameters.
If the validation and training errors are similar in size, but the test errors
are significantly larger, then the network may be extrapolating. This indicates that the test data fall outside the range of the training and validation
data. In this case, we need to get more data. You can merge the test data
into the training/validation data and then collect new test data. You should
continue to add data until the results on all three data sets are similar.
If training, validation and test errors are similar, and the errors are small
enough, then we can put the multilayer network to use. However, we still
need to be careful about the possibility of extrapolation. If the multilayer
network inputs are outside the range of the data with which it was trained,
then extrapolation will occur. It is difficult to guarantee that training data
will encompass all future uses of a neural network.
Novelty Detection
Sensitivity Analysis
After a multilayer network has been trained, it is often useful to assess the
importance of each element of the input vector. If we can determine that a
given element of the input vector is unimportant, then we can eliminate it.
This can simplify the network, reduce the amount of computation and help
prevent overfitting. There is no one method that can absolutely determine
the importance of each input, but a sensitivity analysis can be helpful in
this regard. A sensitivity analysis computes the derivatives of the network
response with respect to each element of the input vector. If the derivative
with respect to a certain input element is small, then that element can be
eliminated from the input vector.
Because the multilayer network is nonlinear, the derivative of the network
output with respect to an input element will not be constant. For each input
vector in the training set, the derivatives will be different. For this reason,
we cant use a single derivative to determine sensitivity. One option would
22-28
Post-Training Analysis
be to take the average of the absolute derivatives, or else the rms derivatives, over the entire training set. Another option would be to compute the
derivative of the sum square error with respect to each element of the input
vector. Each of these will compute a single derivative for each element of
the input vector. The last computation can be performed with a simple variation of the backpropagation algorithm (see Eq. (11.44) to Eq. (11.47)). Recall from Eq. (11.32) that
F
m
s i --------m- ,
n i
(22.21)
i=1
1
F n
-------1- -------i- =
p j
n
i
i=1
n
1
s i -------i- .
p j
(22.22)
We know that
R
1
ni
w i j pj + b i ,
1
(22.23)
j=1
i=1
1
F n
-------1- -------i- =
p j
n
i
si w i j .
1
(22.24)
i=1
(22.25)
This will be the derivative for a single squared error. To get the derivative
of the sum square error, we sum the individual derivatives for each single
squared error. The resulting vector will contain the derivatives of the sum
square error for each element of the input vector. If we find that some of
these derivatives are much smaller than the maximum derivative, then we
can consider removing those inputs. After removing the potentially irrelevant inputs, we retrain the network and compare the performance with the
original network. If the performance is similar, then we accept the simplified network.
22
22-29
Epilogue
While previous chapters have focused on the fundamentals of particular
network architectures and training rules, this chapter has discussed some
practical aspects of neural network training. Neural network training is an
iterative process involving data collection and preprocessing, network architecture selection, network training and post-training analysis.
The next five chapters will demonstrate some of these practical aspects, as
we present some real-world case studies. The case studies will cover a variety of applications, including function fitting, density estimation, pattern
recognition, clustering and prediction.
22-30
Further Reading
Further Reading
[Bish95]
C.M. Bishop, Neural Networks for Pattern Recognition, Oxford University Press,1995.
This well-written and well-organized textbook presents
neural networks from a statistical perspective.
[BoJe94]
[HaBo07]
[HeOh97]
B. Hedn, H. hlin, R. Rittner, L. Edenbrandt, Acute Myocardial Infarction Detected in the 12-Lead ECG by Artificial Neural Networks, Circulation, vol. 96, pp. 17981802,
1997.
Describes the use of neural networks in detecting myocardial infarctions, using the electrocardiogram.
[Joll02]
[LeCu98]
[Moll93]
22
[NgWi90]
[PeCo93]
[PuFe97]
G.V. Puskorius and L.A. Feldkamp, Extensions and enhancements of decoupled extended Kalman filter training,
Proceedings of the 1997 International Conference on Neural
Networks, vol. 3, pp. 1879-1883, 1997.
The extended Kalman filter algorithm described in this paper is one of the faster sequential algorithms for neural network training.
[RaMa05]
L.M. Raff, M. Malshe, M. Hagan, D.I. Doughan, M.G. Rockley, and R. Komanduri, Ab initio potential-energy surfaces
for complex, multi-channel systems using modified novelty
sampling and feedforward neural networks, The Journal
of Chemical Physics, vol. 122, 2005.
This paper describes how neural networks can be used to
model molecular interactions.
[ScSm99]
22-32
Objectives
23
Case Study 1:
Function Approximation
Objectives
23-1
23-2
23-2
23-3
23-4
23-5
Validation
23-7
Data Sets
23-10
Epilogue
23-11
Further Reading
23-12
Objectives
This chapter represents the first of a series of case studies with neural networks. Neural networks can be used for a wide variety of applications, and
it would be impossible to provide case studies for each application. We will
limit our presentations to five important application areas: function approximation (aka, nonlinear regression), density function estimation, pattern recognition (aka, pattern classification), clustering and prediction
(aka, time series analysis, system identification, or dynamic modeling). For
each case study, we will step through the neural network design/training
process.
In this chapter, we present a function approximation problem. For function
approximation problems, the training set consists of a set of dependent
variables (response variables) and one or more independent variables (explanatory variables). The neural network learns to create a mapping between the explanatory variables and the response variables. In the case
study we consider in this chapter, the system in question is a smart sensor.
A smart sensor consists of one or more standard sensors that are coupled
with a neural network to produce a calibrated measurement of a single parameter. In this chapter, we will consider a smart position sensor, which
uses the voltages coming from two solar cells to produce an estimate of the
location of an object in one dimension.
23-1
23
v1
Shadow
v2
23-2
v2
v1
y
Figure 23.2 Example Solar Cell Outputs vs. Object Position
v2
v1
1
0
0
23
The next step is to divide the data into training, validation and test sets. In
this case, because we will be using the Bayesian regularization training
technique, we do not need to have a validation set. We did set aside 15% of
the data for testing purposes. To perform the division, we arranged the
data in order, according to object position, and then selected every sixth or
seventh point for testing. This resulted in 10 testing points. The testing
points are not used in any way for training the network, but after the network has been completely trained, we will use the testing data as an indicator of future network performance.
The input vector for network training will consist of the solar cell voltages
p =
v1
(23.1)
v2
and the target will be ball position
t = y.
(23.2)
The data were scaled using Eq. (22.1), so that both the inputs and the targets were in the range [-1,1]. The resulting scaled data is shown in Figure
23.4
v2
0.5
v1
0.5
1
1
0.5
0.5
23-4
which is defined in Eq. (23.1). The single target for the network is the ball
position, given in Eq. (23.2).
Figure 23.5 shows the network architecture. We are using the tan-sigmoid
transfer function in the hidden layer, and a linear output layer. This is the
standard network for function approximation. As we discussed in Chapter
11, this network has been shown to be a universal approximator. There are
cases in which two hidden layers are used, but we normally try first with
1
one hidden layer. The number of neurons in the hidden layer, S , will depend on the function to be approximated. This is something that cannot
generally be known before training. We will have more to say about this in
the next section.
Inputs
p1
2x1
Tan-Sigmoid Layer
Linear Layer
a1
S x1
n1
S x2
a2
1xS
S x1
1
2
1x1
S1x1
1x1
n2
a = tansig(W p + b )
1x1
2
1
2
a = purelin(W a + b )
23-5
23
10
10
SSE
10
10
10
10
10
10
10
Iterations
1
8.313e-004
1.068e-003
8.672e-004
8.271e-004
Table 23.1. Final Training SSE for Five Different Initial Conditions
Recall from Chapter 13 that the Bayesian regularization algorithm computes a parameter , which indicates the effective number of parameters
that are being used by the network. In Figure 23.7, we can see the variation
of during training. It eventually converges to 17.4. There are a total of 41
parameters in this 2-10-1 network, so we are only using about 40% of the
weights and biases. For each of the five training runs discussed above,
converged to values between 17 and 20. This indicates that we might be
able to use a smaller network, if we are concerned about the amount of computation required to compute a network response.
23-6
Validation
23
20
15
10
0
0
20
40
60
80
100
Iterations
1
S = 3
S = 5
S = 8
( S = 10 )
S = 20
4.406e-003
9.227e-004
8.088e-004
8.672e-004
8.096e-004
Table 23.2. Final Training SSE for Five Different Hidden Layer Sizes
The Bayesian regularization method allows us to train a network of almost
arbitrary size, and yet insure that only the required number of parameters
is effectively used. If we were concerned about the amount of time required
to compute the network output (e.g., for real-time applications), then we
1
would want to use the network with S = 5 . Otherwise, the original net1
work with S = 10 is satisfactory. We dont need to spend a lot of time finding the optimal number of neurons. The training algorithm will insure that
we do not overfit.
Validation
An important tool for network validation is a scatter plot of network outputs versus targets, as shown in Figure 23.8 (in normalized units). We ex-
23-7
pect that for a well trained network the points in the scatter plot will fall
close to the 45 output=target line. In this case, the fit is excellent. The figure on the left shows the training data, while the figure on the right shows
the testing data. Because the testing data fit is as good as the training data
fit, we can be confident that the network did not overfit.
1
Testing
Training
0.5
0.5
0.5
1
1
0.5
0.5
0.5
1
1
0.5
0.5
Figure 23.8 Scatter Plots of Network Outputs vs. Targets - Training and Testing Sets
Another useful plot is a histogram of network error, as shown in Figure
23.9. This gives us an idea of the accuracy of the network. For this histogram, we have converted the network output back into units of inches. This
is done by applying the reverse of the target preprocessing function to the
network output. The reverse of Eq. (22.1), for the targets, is given by
max
min
t
t min
n
a = a + 1 .* ----------------------------- + t
2
n
(23.3)
where a is the original network output, which was trained to match the
normalized target, and .* represents an element-by-element multiplication of two vectors. After the postprocessing operation of Eq. (23.3), the resulting un-normalized output is subtracted from the raw targets, to
produce an error in inches. Figure 23.9 shows the distribution of these errors for both training and testing sets. We can see that almost all errors are
within one hundredth of an inch. This is within the accuracy of the original
measurements, so we cannot expect to do better.
23-8
Validation
23
15
10
0
0.02
0.01
0.01
0.02
3
2.5
2
1.5
1
0.5
0
0
2
6
v2
2
0
v1
network will never be used there. If the network were retrained, the shape
of the response away from the blue circles might be very different, even
though the response near the blue circles will always be the same. This concept is very important for many neural network applications. Often, during
normal network operation, only a small portion of the input space will be
accessed. The network only has to fit the underlying function in these regions where the network will be used. This means that the size of the data
set can be modest, even when the input dimension is large. Of course, in
these cases, it is critical that the training data span the full range of potential network operation.
Data Sets
There are two data files associated with this case study:
ball_p.txt contains the input vectors in the original data set
ball_t.txt contains the target vectors in the original data set
They can be found with the demonstration software, which is described in
Appendix C.
23-10
Epilogue
23
Epilogue
This chapter has demonstrated the use of multilayer neural networks for
function approximation. This case study is representative of a large class
of neural network applications that could be termed soft sensors or
smart sensors. The idea is to use a neural network to fuse several raw
sensor outputs into a calibrated measurement of some key variable of interest.
A multilayer network with sigmoid transfer functions in the hidden layers
and linear transfer functions in the output layer is well suited to this type
of application, and Bayesian regularization is an excellent training algorithm to use in this situation.
In the next chapter, we will look at another neural network application
probability estimation. We will also use multilayer neural networks for
that application, but we will change the transfer function in the output layer.
23-11
Further Reading
[FoGi07]
L. Fortuna, P. Giannone, S. Graziani, M. G. Xibilia, Virtual Instruments Based on Stacked Neural Networks to Improve Product Quality Monitoring in a Refinery, IEEE
Transactions on Instrumentation and Measurement, vol.
56, no. 1, pp. 95101, 2007.
This paper describes the use of neural networks as soft sensors in a refinery. Measurements of reactor temperatures
and pressures are used to predict octane number in a gasoline product.
23-12
Objectives
24
Case Study 2:
Probability Estimation
Objectives
24-1
24-2
24-2
24-3
24-5
24-7
Validation
24-9
Data Sets
24-12
Epilogue
24-13
Further Reading
24-14
Objectives
This chapter represents the second of a series of case studies with neural
networks. The previous chapter demonstrated the use of neural networks
for function approximation. In this chapter we use a neural network to estimate a probability function.
Probability estimation is a special case of function approximation. In function approximation we want the neural network to map between a set of input variables and a set of response variables. However, in the case of
probability estimation the response variables correspond to a set of probabilities. Since probabilities have certain special properties they must always be positive, and they must sum to 1 we want the neural network
to enforce these conditions.
In the case study we consider in this chapter, the system in question is
chemical vapor deposition of diamond. A carbon dimer (a bound pair of carbon atoms) is projected toward a diamond surface. We want to determine
the probabilities for various reactions based on characteristics of the projected dimer. The input variables consist of such properties as translational
energy and incidence angle, and the response variables consist of the probabilities of the potential reactions, such as chemisorption and scattering.
24-1
24
CVD
For this probability estimation case study, we will train a neural network
to estimate reaction rates in a chemical process. Chemical vapor deposition
(CVD) of diamond is a process for making synthetic diamond. The idea is to
cause carbon atoms in a gas to settle on a substrate in crystalline form. In
order to study this process, scientists are often interested in reaction rates,
which will determine how quickly the diamond can be created. In this case
study, we will train a neural network to compute reaction rates as a carbon
dimer (a bound pair of carbon atoms) interacts with the crystalline diamond substrate.
We will begin by describing the CVD process and how simulated data can
be collected for this process. Then, we will show how a neural network can
be trained to learn the reaction probabilities. The details of the procedure
are described in [AgSa05].
cated by the origin of the axes in Figure 24.1). The angle represents the
angle between the x axis and the line from the origin to the central atom.
24
y
f
p =
(24.1)
v trans
v rot
The reaction process can be chemisorption ( X = C ), scattering ( X = S ), or
desorption ( X = D ). The probability estimates produced by the neural netNN
work will be indicated by P X p . The probability estimates obtained from
MC
the Monte Carlo simulations will be indicated by P X p .
The Monte Carlo estimates are obtained by
N
MC
P X p = -----X- ,
NT
(24.2)
24-4
PC p
t = P MC p ,
S
(24.3)
MC
PD p
MC
24
This is an ideal situation for using the softmax transfer function of Eq.
(22.3), which is repeated here:
S
a i = f n i = exp n i
exp nj .
(24.4)
j=1
This transfer function is different from others we have used, in that each
neuron output a i is affected by all of the net inputs n j . (In the other transfer functions, the net input n i affected only the neuron output a i .) This
does not cause any substantial difficulties in network training. The backpropagation algorithm of Eq. (11.44) and Eq. (11.45) can still be used to
compute the gradient. However, the derivative of the transfer function is
no longer a diagonal matrix. The derivative of the softmax function has the
following form:
m
m
a 1 a im a 1m
i = 1
a 1m a Smm
m
a 2 a im a 2m
i = 1
a 2m a Smm
a 1m a 2m
m
F m n m =
a 2m a 1m
(24.5)
a Smm a 1m
a Smm a 2m
m
a S m a im a Smm
i = 1
The complete network architecture is shown in Figure 24.2. The input vector of Eq. (24.1) has 5 elements. The output vector has 3 elements, which is
consistent with the target vector of Eq. (24.3). The transfer function in the
hidden layer is the hyperbolic tangent sigmoid, and the softmax transfer
function is used in the output layer. The number of neurons in the hidden
1
layer, S , is yet to be determined. It depends on the complexity of the function that we are trying to approximate, but we do not know at this point
how complex the function is. In general, the size of the hidden layer must
1
be determined as part of the training process. We must choose S so that
the network provides an accurate fit to the training data, without overfitting. We will discuss this selection in the next section.
24-6
Inputs
Tan-Sigmoid Layer
1
5x1
Softmax Layer
1
S1x1
n1
1
S x5
S1x1
1
5
3x1
S1
S1x1
1
3x1
n2
3xS1
b2
3x1
a = tansig(W p + b )
2 1
a = softmax(W a + b )
MSE
10
Training
Validation
10
10
10
10
10
Iterations
1
24
Validation RMSE
PC p
0.0496
0.0439
PS p
0.0634
0.0659
PD p
0.0586
0.0604
1
Validation RMSE
PC p
0.0634
0.0627
PS p
0.0669
0.0704
PD p
0.0617
0.0618
1
Table 24.3. shows the results for S = 20 . The validation error is slightly
higher than the training error, which might indicate some overfitting. The
main point is that neither training nor validation errors are significantly
1
1
smaller for S = 20 than for S = 10 . This indicates that ten hidden neurons are sufficient for this problem. We will investigate this further in the
next section.
24-8
Validation
Training RMSE
Validation RMSE
PC p
0.0432
0.0444
PS p
0.0603
0.0643
PD p
0.0569
0.0595
1
2.953e-003
3.031e-003
3.105e-003
3.050e-003
Table 24.4. Final Validation MSE for Five Different Initial Conditions
We have determined that a neural network with ten neurons in the hidden
layer produces a reasonable response without overfitting. The next step is
to analyze the performance of the network. Depending on the results of
that analysis, we might adjust the network architecture or training data
and retrain the network.
Validation
An important tool for network validation is a scatter plot of network outputs versus targets, as shown in Figure 24.4. Here we can see that there is
a strong linear relationship between the targets and the network outputs,
but there appears to be quite a bit of variation. We might expect that for a
well trained network the points in the scatter plot would fall exactly on the
outputs=target line. Why do we have so much variation in this plot? The
reason is that the targets of the network are not the true reaction probabilMC
ities, P X p , but the Monte Carlo estimates P X p . There is noise in the
targets.
24-9
24
NN
0.8
0.8
0.8
0.6
NN
0.6
NN
0.6
PD
PS
PC
0.4
0.4
0.4
0.2
0.2
0.2
0
0
0.2
0.4
0.6
0.8
0
0
0.2
0.4
MC
PC
0.6
0.8
0
0
0.2
0.4
0.6
0.8
MC
PD
MC
PS
P X 2 P X P X + 2 ,
(24.6)
where
=
PX 1 PX
.
---------------------------NT
(24.7)
0.8
0.6
MC
PX
0.4
0.2
0
0
0.2
0.4
PX
0.6
0.8
MC
for N T = 50
Validation
By comparing Figure 24.4 with Figure 24.5, we can see that the spread in
MC
the data is explained by the statistical variations in P X . To further verify
this observation, we generated additional testing data, in which 500 Monte
MC
Carlo trials were run to obtain each P X p (i.e., N T = 500 ). We applied
this testing data to the network that was trained on the original data set
with N T = 50 . The resulting scatter plots are shown in Figure 24.6. Here
we can see that the spread has decreased dramatically from Figure 24.4,
even though the network has not changed. This means that the neural network is fitting the true probabilities P X p and not the statistical fluctuaMC
tions in P X p .
NN
0.8
0.8
0.8
0.6
NN
0.6
NN
0.6
PD
PS
PC
0.4
0.4
0.4
0.2
0.2
0.2
0
0
0.2
0.4
MC
PC
0.6
0.8
0
0
0.2
0.4
MC
PS
0.6
0.8
0
0
0.2
0.4
0.6
0.8
MC
PD
24-11
24
NN
PC
0.5
0.5
1.5
2.5
3.5
0.5
1.5
2.5
3.5
0.5
1.5
2.5
3.5
NN
PS
0.5
0
1
NN
PD
0.5
b
Figure 24.7 Reaction Probabilities vs. Impact Parameter
Data Sets
There are four data files associated with this case study:
cvd_p.txt contains the input vectors in the original data set
cvd_t.txt contains the target vectors in the original data set
cvd_p500.txt contains the input vectors in the N T = 500 test set
cvd_t500.txt contains the target vectors in the N T = 500 test set
They can be found with the demonstration software, which is described in
Appendix C.
24-12
Epilogue
Epilogue
This chapter has illustrated the use of neural networks for probability estimation on a chemical vapor deposition problem. Monte Carlo simulations
were used to provide estimates of the reaction probabilities. These estimates were used as targets for the neural network. The network was able
to capture the true underlying probability function without overfitting to
the errors in the Monte Carlo estimates. This was accomplished by using
the early stopping procedure, which stops network training if the error on
an independent validation set increases.
In the next chapter, we apply neural networks to a pattern recognition
problem. We will also use multilayer neural networks for that application.
24-13
24
Further Reading
[AgSa05]
[Mill93]
[RaMa05]
L.M. Raff, M. Malshe, M. Hagan, D.I. Doughan, M.G. Rockley, and R. Komanduri, Ab initio potential-energy surfaces
for complex, multi-channel systems using modified novelty
sampling and feedforward neural networks, The Journal
of Chemical Physics, 122, 084104, 2005.
This paper explains how neural networks can be used for
molecular dynamics simulations.
24-14
Objectives
25
Case Study 3:
Pattern Recognition
Objectives
25-1
25-2
25-3
25-6
25-7
Validation
25-7
Data Sets
25-10
Epilogue
25-11
Further Reading
25-12
Objectives
This chapter presents a case study in using neural networks for pattern
recognition. In pattern recognition problems, you want a neural network to
classify inputs into a set of target categories, e.g., recognize the vineyard
that a particular bottle of wine came from, based on a chemical analysis, or
classify a tumor as benign or malignant, based on uniformity of cell size,
clump thickness, mitosis.
In this chapter we will demonstrate the application of multilayer neural
networks to the recognition of heart disease from a reading of the electrocardiogram. We will show each of the steps in the pattern recognition process: data collection, feature extraction, architecture selection, network
training and network validation.
25-1
25
25-2
25
0.6
0.4
0.2
0.2
0
0.5
1.5
Time (sec)
Figure 25.1 Example EKG Signal
Our data set has a total of 447 EKG records. Of these, 79 represent healthy
patients, and the remaining 368 have an MI diagnosis. A diagnosis for each
record was provided by a physician, but it is possible for the diagnosis to be
in error. We will have more to say about this when we come to the validation of the network.
Each EKG consists of 15 leads measured at a rate of 1000 Hz for a period
of several minutes. This is an enormous amount of data, and it would be
impractical to use the entire EKG as an input to the neural network. As
with many pattern recognition problems, we need to perform a feature extraction step before using the neural network to execute the pattern recognition step. Feature extraction involves mapping the high-dimensional
input space into a space with fewer dimensions, in order to simplify and
make more robust the pattern recognition step.
There are a number of general methods for dimensionality reduction. This
includes linear methods, like the principal components method that we
mentioned in Chapter 22, and nonlinear methods, like manifold learning
[TeSi00]. For this case study, instead of using general methods to generate
the low-dimensional feature space, we will extract features that are com-
25-3
monly used by physicians to detect abnormalities in the EKG. The first step
is to consider a typical cycle of an EKG signal, as shown in Figure 25.2.
PR
Segment
ST
Segment
T
Q
PR
Interval
S
QRS
Duration
QT Interval
age in years
2.
3.
4.
5.
6.
7.
8.
9.
25-4
To summarize, the data set contains 447 records. Each record has 47 input
variables, and one target value. The target is 1 for a healthy diagnosis and
-1 for an MI diagnosis.
One of the problems with the data set is that there are only 79 records for
the healthy diagnosis, while there are 368 records for the MI diagnosis. If
we train the network using the sum square error performance index, where
all of the errors are weighted equally, the network will be biased to indicate
25-5
25
Inputs
p
47 x 1
Tan-Sigmoid Layer
Tan-Sigmoid Layer
1
S x1
n1
1
S x 47
S x1
47
1x1
S1x1
a = tansig(W p + b )
1x1
2
1
2 1
a = tansig(W a + b )
1x1
n2
1xS1
10
10
MSE
Validation
1
10
Training
2
10
10
20
30
40
50
Iterations
1
Validation
As we discussed in previous chapters, an important tool for network validation in function approximation problems is a scatter plot of network outputs versus targets. For pattern recognition problems, the network outputs
and targets are discrete variables, so a scatter plot is not particularly useful. Instead of the scatter plot, we use the confusion matrix, which was discussed in Chapter 22. Figure 25.5 shows the confusion matrix for our
trained network on the test data. The upper left cell shows that 13 of the
14 healthy EKGs in the test set were classified correctly, while the 2,2 cell
shows that 66 of the 71 MI EKGs were classified correctly. A total of 92.9%
of the test data were classified correctly. The largest number of mistakes
were for MI records that were classified as healthy (5), as shown in cell 1,2.
25-7
25
Output Class
Confusion Matrix
13
15.3%
5
5.9%
72.2%
27.8%
1
1.2%
66
77.6%
98.5%
1.5%
92.9%
7.1%
93.0%
7.0%
92.9%
7.1%
2
Target Class
Figure 25.5 Confusion Matrix for Test Data (One Data Division)
Another useful validation tool for pattern recognition problems is the Receive Operating Characteristic (ROC) curve, described in Chapter 22. Figure 25.6 shows the ROC curve (blue line) for the test data. The ideal curve
would follow the path from 0,0 to 0,1 and then to 1,1. The curve for this test
set is close to the ideal path.
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0
0.2
0.4
0.6
False Positive Rate
0.8
Validation
times. For each division of the data, a neural network was trained with different random initial weights. The results of the 1,000 trials were averaged
together, and the results are shown in Figure 25.7.
Confusion Matrix
Output Class
9.11
14.0%
3.69
5.7%
71.2%
28.8%
25
2
2.51
3.9%
49.83
76.5%
95.2%
4.8%
78.4%
21.6%
93.1%
6.9%
90.5%
9.5%
2
Target Class
Figure 25.7 Average Test Confusion Matrix for 1,000 Monte Carlo Runs
Figure 25.7 represents the average results over the 1,000 different networks and data divisions. There were approximately 12 healthy patients
(on average) in each test set. Of these, more than 9 were correctly diagnosed. There were approximately 54 sick patients in each test set, and approximately 50 were correctly diagnosed. The average testing error was
approximately 9.5%. Note that none of the patients in the test set were
used to train the neural network, so these numbers should be conservative
estimates of how the network should perform on new patients.
The average test results for the Monte Carlo simulation are similar to our
original test results. However, in addition to knowing the average results,
it is also helpful to look at the distribution of errors. Figure 25.8 shows a
histogram of the percentage errors. The average percent error is 9.5%, but
there is a significant spread in the distribution of errors. The standard deviation of the percent error is 3.5.
25-9
160
120
80
40
10
15
20
25
Percent Error
Data Sets
There are two data files associated with this case study:
ekg_p.txt contains the input vectors in the ekg data set
ekg_t.txt contains the targets in the ekg data set
They can be found with the demonstration software, which is described in
Appendix C.
25-10
Epilogue
Epilogue
This chapter has demonstrated the use of multilayer neural networks for
pattern recognition. In this case study, the pattern recognition network
was used to classify EKG records into healthy and myocardial infarction diagnoses.
Most pattern recognition tasks involve a feature extraction step, in which
the original data set is reduced in dimension. The features that were extracted from the EKG data consisted of characteristics of the prototype
EKG cycle.
A Monte Carlo procedure was used as part of the network validation. The
data were randomly divided a number of times into training/validation/test
sets, and for each division a neural network was trained with random initial weights. The performances of all of the networks were analyzed to determine expected future performance. In addition, those records that were
misclassified by most of the networks, regardless of the data division, were
analyzed to assist in refining the data set and improving the pattern recognition.
In the next chapter, we apply neural networks to a clustering problem. We
will use a self-organizing feature map network for that application.
25-11
25
Further Reading
[Dubi00]
[MoMa01]
[Raff06]
[TeSi00]
25-12
Objectives
26
26-1
26-2
26-2
26-4
26-5
26-6
Validation
26-7
Data Sets
26-10
Epilogue
26-11
Further Reading
26-12
Objectives
This chapter presents a case study in using neural networks for clustering.
In clustering problems, you want a neural network to group data by similarity. For example, market segmentation can be done by grouping people
according to their buying patterns, data mining can be done by partitioning
data into related subsets, and bioinformatic analysis can be done by grouping genes with related expression patterns.
In this chapter, we will apply clustering to a problem in forestry, in which
we would like to analyze forest cover types. We will use the self-organizing
feature map network of Chapter 16 to perform the clustering, and we will
demonstrate a variety of visualization tools that can be used in conjunction
with the SOFM.
26-1
26
26-2
Variable Number
Description
Units
Elevation in meters
meters
azimuth
Slope in degrees
degrees
meters
meters
meters
0 to 255 index
0 to 255 index
0 to 255 index
10
meters
Name
Krummholz
Spruce/Fir
Lodgepole Pine
Ponderosa Pine
Cottonwood/Willow
Aspen
Douglas-fir
26-3
26
6000
8
4000
2000
0
1
0.5
0.5
8000
0.5
0
1
1
8000
0
7
8
1
1
0
7
0
8
9
6000
0.5
9
4000
2000
0
1
0
0.5
0
0.5
1
1
6000
4000
2000
0
1
26-4
There are several things we can look for in Figure 26.1. First, we want to
see how well the data is scattered throughout the range. If some variables
show little or no variation, then we would remove them from the analysis.
We also look for correlation between the variables. For example, if the
points in the scatter plot fell exactly along a line, then we would know that
the two variables were linearly related. There would be no need to use both
variables in the analysis. From Figure 26.1 we can see that there is some
correlation between the variables, but they are not linearly dependent.
Competitive Layer
W
150 x 10
||dist||
10 x 1
n
150 x 1
a
150 x 1
150
10
ni = ||iw-p||
a = compet(n)
15 x 10
Figure 26.2 SOM Network Architecture
After the network has been trained, we will analyze the results to determine if the network architecture is satisfactory. In practical cases, we often
try several different architectures. Unlike with supervised training, in
which we have a clear performance measure (normally sum square error),
there is no firm criterion for best performance in SOFM networks. Often
26-5
26
what we are looking for is insight into the data set. It is somewhat of an art
to selecting the best architecture and training regime for SOFM networks.
This will become more clear when we analyze the results of the trained network in a later section.
= iw q 1 + p q iw q 1
= 1 iw q 1 + p q
i N i d
(26.1)
(26.2)
defines the neuron neighborhood. For this case study, we have used a batch
form of the algorithm, in which all of the inputs in the training set are applied to the network before the weights are updated. To develop the batch
form, we can first modify the sequential form of Eq. (26.1) to
iw q
= iw q 1 + h i i p q iw q 1 ,
(26.3)
h i i =
0
i N i d
i N i d
(26.4)
Using this definition of neighborhood function, we can define a batch version of Eq. (26.1):
Q
hi q i p q
iw k
q=1
= ------------------------------------,
Q
h i q i
q=1
26-6
(26.5)
Validation
where k is the iteration number and i q is the winning neuron for input
p q . Note that for the batch algorithm we have to distinguish between the
iteration number and the input number, since all inputs are applied to the
network at each iteration. This is in contrast to the sequential algorithm of
Eq. (26.1), where there is one iteration for each input. Also, notice that the
learning rate does not affect the batch algorithm, since it would appear in
both the numerator and the denominator of Eq. (26.5).
For the neighborhood function of Eq. (26.4), this batch algorithm has the
effect of assigning each weight to the average of the input vectors for which
it is in the neighborhood of the winner. As with the sequential algorithm,
the neighborhood size is decreased during training. The neighborhood size
is set large at the beginning of training until all weights move into the region of the input space where the data lies. Then the neighborhood size is
reduced, to fine-tune the position of the weights.
The batch algorithm requires many fewer iterations than the sequential algorithm, although each iteration requires much more computation. For
this case study, we used two iterations of the batch algorithm. During the
first iteration the neighborhood size was 4, and during the second iteration
the neighborhood size was reduced to 1.
Validation
We will consider two numerical measures of the quality of a trained SOM:
resolution and topology preservation (see page 22-23). One measure of
SOM resolution is the quantization error, which is the average distance between each data vector and its winning neuron. If the average distance is
too large, then there are many input vectors that are not adequately represented by any of the prototypes.
A measure of SOM topology preservation is the topographic error. This is
the proportion of all input vectors for which the closest (winning) neuron
and the next closest neuron are not adjacent to each other in the feature
map topology. When this number is small, it means that the neurons that
are neighbors in the topology are also neighbors in the input space. It is important that this topology be preserved, so that the visualization tools we
will discuss later can provide valid insight into the data set.
For our trained SOM, the final quantization error was 0.535, and the final
topographic error was 0.037. This means that for less than 4% of all input
vectors, the winning neuron and the next closest neuron were not adjacent
to each other. It appears that the SOM has achieved the correct topology by
the completion of the training.
There are a number of visualization methods that can be used to assess the
trained SOM network. One of the key tools is called the unified distance
matrix, or u-matrix. This is a figure that shows the distance between neighboring neurons in the feature map. The u-matrix has a cell for each neuron
26-7
26
in the feature map and an additional cell between each pair of neurons. The
cells between neurons are color-coded with the distance between the corresponding weight vectors. The cells that represent the neurons are coded
with the mean of the surrounding values. Figure 26.3 shows the u-matrix
for our trained SOM.
0.6
0.5
0.4
0.3
0.2
0.1
Validation
map have consistent colors. The left side has medium gray levels, corresponding to type 2 cover. The darkest levels are in the center-left region of
the map, which corresponds to cover types 0 and 1. The lighter levels,
which correspond to types 5 and 6, are in the center-right region, and the
median levels of gray, corresponding to types 3 and 4, are on the right edge.
2
2
0
0
2
2
2
1
0
0
2
0
4
4
4
6
5
5
4
4
2
1
4
4
4
4
5
5
3
4
1
1
3
6
0
0
2
2
6
6
2
2
6
6
0
1
6
5
1
2
1
1
1
0
1
1
1
0
4
4
6
5
4
5
26-9
26
1
0
0.4
5
0.4
4
0.4
0.5
0.2
0.4
0.6
0.5
0.6
0.8
0.5
8
0.8
0.45
0.6
0.5
0.5
0.4
0.8
0.4
10
9
0.4
0.5
0.4
0.5
Data Sets
There are two data files associated with this case study:
cover_p.txt contains the input vectors in the data set
cover_t.txt contains the targets (labels) in the data set
They can be found with the demonstration software, which is described in
Appendix C.
26-10
Epilogue
Epilogue
This chapter has demonstrated the use of SOM networks for clustering, in
which input vectors in a data set are arranged so that similar vectors are
placed in the same cluster. In this case study, the SOM was used to cluster
forestry data. The idea was to cluster land into similar forest cover types.
One of the principal advantages of the SOM network, in addition to its ability to efficiently cluster a data set, is its ability to enable visualization of
high dimensional data sets.
In the next chapter, we apply neural networks to a prediction problem. We
will use a Nonlinear Autoregressive model with eXogenous inputs (NARX)
network for that application.
26-11
26
Further Reading
[BlDe99]
[HeBa99]
[Koho93]
T. Kohonen, Things you haven't heard about the Self-Organizing Map, Proceedings of the International Conference
on Neural Networks (ICNN), San Francisco, pp. 1147-1156,
1993.
This paper describes the batch form of the SOM learning
rule, as well as other variations on the SOM.
[Koho95]
26-12
Objectives
27
27-1
27-2
27-2
27-3
27-4
27-7
Validation
27-8
Data Sets
27-13
Epilogue
27-14
Further Reading
27-15
Objectives
This chapter presents a case study in using neural networks for prediction.
Prediction is a kind of dynamic filtering, in which past values of one or
more time series are used to predict future values. Dynamic networks, such
as those described in Chapter 10 and Chapter 14, are used for filtering and
prediction. Unlike the previous case studies, the input to these dynamic
networks is a time sequence.
There are many applications for prediction. For example, a financial analyst might want to predict the future value of a stock, bond, or other financial instrument. An engineer might want to predict the impending failure
of a jet engine. Predictive models are also used for system identification (or
dynamic modeling), in which we build dynamic models of physical systems.
These dynamic models are important for analysis, simulation, monitoring
and control of a variety of systems, including manufacturing systems,
chemical processes, robotics and aerospace systems. In this chapter we will
demonstrate the development of predictive models for a magnetic levitation system.
27-1
27
N
S
y(t)
i(t)
+
-
i t sgn i t dy t
d yt
-------------- = g + ----- --------------------------------- ----- -----------2
yt
M dt
M
dt
(27.1)
The objective of the case study will be to develop a dynamic neural network
model that can predict the next value of the magnet position, based on previous values of the magnet position and the input current. Once the model
has been developed, it can be used to find a controller that can determine
the correct current to apply to the electromagnet, so as to move the magnet
to some desired position. We wont go in to the control design in this case
study, but the reader is referred to [HaDe02] and [NaMu97].
Current (A)
Position (m)
10
20
30
40
20
30
40
8
6
4
2
0
0
10
Time (Sec)
Figure 27.2 Magnetic Levitation Data
The skyline form of input function has the advantage that it can explore
both transient and steady state operation of the system. Because some of
the pulses are long, the system will approach steady state at the end of
27-3
27
those pulses. Shorter width pulses explore transient operation of the system.
When steady state performance is poor, it is useful to increase the duration
of the input pulses. Unfortunately, within a training data set, if we have
too much data in steady state conditions, the training data may not be representative of typical plant behavior. This is due to the fact that the input
and output signals do not adequately cover the region that is going to be
controlled. This will result in poor transient performance. We need to
choose the training data so that we produce adequate transient and steady
state performance. This can be done by using an input sequence with a
range of pulse widths and amplitudes.
After the data has been collected, the next step is to divide the data into
training, validation and test sets. In this case, because we will be using the
Bayesian regularization training technique, we do not need to have a validation set. We did set aside 15% of the data for testing purposes. When the
input is a time sequence, it is useful to have the testing sequence consist of
a contiguous segment of the original data set. For our tests, we used the
last 15% of the data as the testing set.
The data were scaled using Eq. (22.1), so that both the inputs and the targets were in the range [-1,1]. The resulting scaled data is shown in Figure
27.3
Current
1
0.5
0
0.5
1
0
10
20
30
40
20
30
40
Position
1
0.5
0
0.5
1
0
10
Time (Sec)
Figure 27.3 Scaled Data
27-4
Inputs
Layer 1
Layer 2
1
p (t)
T
D
L
n (t)
a (t)
IW1,1
a (t)
LW
2,1
2
S x1
1
S x1
1xS
1x1
n (t)
1x1
S2x1
b1
S1x1
1
T
D
L
LW
S1x1
S1
b2
1x1
1,3
27
u(t)
T
D
L
T
D
L
Feed
Forward
Network
^y(t)
u(t)
T
D
L
y(t)
T
D
L
Parallel Architecture
Feed
Forward
Network
^y(t)
Series-Parallel Architecture
(27.3)
27-6
(27.4)
10
10
10
SSE
10
10
10
10
10
10
10
10
10
10
10
Iterations
1
27-7
27
There is no need to decrease the number of neurons, since the network computation time is not critical for this application. The only other reason for
reducing the number of neurons would be to prevent overfitting. In terms
of preventing overfitting, having 39 effective parameters is equivalent to
having 39 total parameters. That is the beauty of using the Bayesian regularization technique. This method chooses the correct number of parameters for each problem, as long as we have a sufficient number of potential
parameters in the network.
40
30
20
10
0
0
200
400
600
800
1000
Iterations
1
Validation
As we discussed in previous chapters, an important tool for network validation is a scatter plot of network outputs versus targets, as shown in Figure 27.8 (in normalized units). The figure on the left shows the training
data, while the figure on the right shows the testing data. Because the testing data fit is as good as the training data fit, we can be confident that the
network did not overfit.
For prediction problems, there is another set of tools for model validation.
These tools are based on two basic properties of accurate prediction models.
The first property is that the prediction errors,
2
e t = y t y t = y t a t ,
(27.5)
should be uncorrelated with each other from one time step to the next. The
second property is that prediction errors should be uncorrelated with the
input sequence u t . (See [BoJe86].)
27-8
Validation
If the prediction errors were correlated with each other, then we could use
that correlation to improve the predictions. For example, if prediction errors one time step apart had a positive correlation, then a large positive
prediction error at the current time point would suggest that the prediction
error at the next time point would also be positive. By lowering our next
prediction, we could then reduce the next prediction error.
1
Testing
Training
0.5
0.5
0.5
0.5
27
1
1
0.5
0.5
1
1
0.5
0.5
Figure 27.8 Scatter Plots of Network Outputs vs. Targets - Training and Testing Sets
The same argument holds for correlation between the input sequence and
the prediction error. For accurate prediction models, there should be no correlation between the input and the prediction error. If there was correlation, then we could use this correlation to improve the predictor.
To measure the correlation in a time sequence, we use the autocorrelation
function, which can be estimated by
Q
1
R e = -----------Q
e t e t + .
(27.6)
t=1
27-9
Re 0
2 ------------.
Q
(27.7)
x 10
Re
2
50
50
Figure 27.9 R e ( n y = n u = 2 , S = 10 )
The dashed blue lines in Figure 27.9 indicate these confidence bounds. We
can see that the estimated autocorrelation function for the prediction errors falls outside these bounds at a number of points. This indicates that
we may need to increase n y and n u .
To measure correlation between the input sequence u t and the prediction
error e t , we use the cross-correlation function, which can be estimated by
Q
1
R ue = -----------Q
u t e t + .
(27.8)
t=1
(27.9)
The dashed blue lines in Figure 27.10 represent these confidence bounds.
The cross-correlation function remains within these bounds, so it does not
indicate a problem.
27-10
Validation
x 10
0.8
0.4
R ue 0
0.4
0.8
50
50
Figure 27.10 R ue ( n y = n u = 2 , S = 10 )
Because the autocorrelation function of the prediction errors in Figure 27.9
indicated correlation in the errors, we increased the n y and n u values from
2 to 4 and retrained our neural network predictor. The resulting estimated
autocorrelation function is shown in Figure 27.11. Here we can see that
R e falls within the confidence bounds, except at = 0 , which indicates
that our model is performing correctly.
8
x 10
Re
1
50
50
Figure 27.11 R e ( n y = n u = 4 , S = 10 )
The estimated cross-correlation function, with the increased delay order, is
shown in Figure 27.12. All of the points are well within the zero confidence
27-11
27
interval. There is no significant correlation between the errors and the input.
6
x 10
8
R ue
8
50
50
Figure 27.12 R ue ( n y = n u = 4 , S = 10 )
With n y = n u = 4 , we have white prediction errors, and there is no significant correlation between the prediction errors and the model input. It appears that we have an accurate prediction model.
The errors for the final prediction model are shown in Figure 27.13. We can
see that the errors are very small. However, because of the series-parallel
configuration, these are errors for only a one-step-ahead prediction. A more
stringent test would be to rearrange the network into the original parallel
form and then to perform an iterated prediction over many time steps. We
will now demonstrate the parallel operation.
Figure 27.14 illustrates the iterated prediction. The solid line is the actual
position of the magnet, and the dashed line is the position predicted by the
NARX neural network. The network prediction is very accurate - even 600
time steps ahead.
27-12
Data Sets
x 10
4
0
10
20
30
Time (Sec)
40
27
Normalized Position
0.5
0.5
1
0
Time (Sec)
Data Sets
There are two data files associated with this case study:
maglev_u.txt contains the input sequence in the original data set
maglev_y.txt contains the output sequence in the original data set
They can be found with the demonstration software, which is described in
Appendix C.
27-13
Epilogue
This chapter has demonstrated the use of multilayer neural networks for
prediction, in which a future value of a time series is predicted from past
values of that series and potentially other series. In this case study, the
prediction network was used as a model of a magnetic levitation system.
This modeling of dynamic systems is referred to as system identification.
A Nonlinear Autoregressive model with eXogenous inputs (NARX) network
is well suited to this problem, and Bayesian regularization is an excellent
training algorithm to use in this situation.
27-14
Further Reading
Further Reading
[BoJe94]
[HaDe02]
[NaMu97]
Narendra, K.S.; Mukhopadhyay, S., Adaptive control using neural networks and approximate models, IEEE
Transactions on Neural Networks, vol. 8, no. 3, pp. 475 485, 1997.
This paper introduced the NARMA-L2 model and controller. Once the NARMA-L2 model is trained, it can be easily
inverted to form a controller for the identified system.
[NaPa90]
27-15
27
A Bibliography
Bibliography
[AgSa05]
[Albe72]
A. Albert, Regression and the Moore-Penrose Pseudoinverse, New York: Academic Press, 1972. (Chapter 7)
[AmMu97]
[Ande72]
J. A. Anderson, A simple neural network generating an interactive memory, Mathematical Biosciences, vol. 14, pp.
197220, 1972. (Chapter 1, 15, 21)
[AnRo88]
J. A. Anderson and E. Rosenfeld, Neurocomputing: Foundations of Research, Cambridge, MA: MIT Press, 1989.
(Chapter 1, 10)
[AnSi77]
[Barn92]
[BaSu83]
[Batt92]
[Bish91]
A Bibliography
[Bish95]
C.M. Bishop, Neural Networks for Pattern Recognition, Oxford University Press,1995. (Chapter 22)
[BlDe99]
[BoJe94]
[BrLo88]
D.S. Broomhead and D. Lowe, Multivariable function interpolation and adaptive networks, Complex Systems,
vol.2, pp. 321-355, 1988. (Chapter 17)
[Brog91]
[CaGr87a]
G. A. Carpenter and S. Grossberg, A massively parallel architecture for a self-organizing neural pattern recognition
machine, Computer Vision, Graphics, and Image Processing, vol. 37, pp. 54115, 1987. (Chapter 19)
[CaGr87b]
G. A. Carpenter and S. Grossberg, ART2: Self-organization of stable category recognition codes for analog input
patterns, Applied Optics, vol. 26, no. 23, pp. 49194930,
1987. (Chapter 19)
[CaGr90]
[CaGrMa92]
G. A. Carpenter, S. Grossberg, N. Markuzon, J. H. Reynolds and D. B. Rosen, Fuzzy ARTMAP: A neural network
architecture for incremental learning of analog multidimensional maps, IEEE Transactions on Neural Networks,
vol. 3, pp. 698713, 1992. (Chapter 19)
[CaGrRe91]
[Char92]
C. Charalambous, Conjugate gradient algorithm for efficient training of artificial neural networks, IEEE Proceedings, vol. 139, no. 3, pp. 301310, 1992. (Chapter 12)
A-2
A Bibliography
[ChCo91]
[ChCo92]
[ChCh96]
S. Chen, E. S. Chng, and K. Alkadhimi, Regularised orthogonal least squares algorithm for constructing radial
basis function networks, International Journal of Control,
vol. 64, no. 5, pp. 829837, 1996. (Chapter 17)
[ChCo99]
S. Chen, C.F.N. Cowan, and P.M. Grant, Combined Genetic Algorithm Optimization and Regularized Orthogonal
Least Squares Learning for Radial Basis Function Networks, IEEE Transactions on Neural Networks, vol.10,
no.5, pp.302-309, 1999. (Chapter 17)
[CoGr83]
[DARP88]
DARPA Neural Network Study, Lexington, MA: MIT Lincoln Laboratory, 1988. (Chapter 1)
[DeHa07]
[Dubi00]
[Fahl89]
S. E. Fahlman, Fast learning variations on back-propagation: An empirical study, in Proceedings of the 1988 Connectionist Models Summer School, D. Touretzky, G. Hinton
and T. Sejnowski, eds., San Mateo, CA: Morgan Kaufmann,
pp. 3851, 1989. (Chapter 12)
[FoGi07]
L. Fortuna, P. Giannone, S. Graziani, M. G. Xibilia, Virtual Instruments Based on Stacked Neural Networks to Improve Product Quality Monitoring in a Refinery, IEEE
Transactions on Instrumentation and Measurement, vol.
56, no. 1, pp. 95101, 2007. (Chapter 23)
A-3
A Bibliography
[FoHa97]
[FrSk91]
[Gill81]
P. E. Gill, W. Murray and M. H. Wright, Practical Optimization, New York: Academic Press, 1981. (Chapter 8, 9)
[GoLa98]
C. Goutte and J. Larsen, Adaptive Regularization of Neural Networks Using Conjugate Gradient, Proceedings of
the IEEE International Conference on Acoustics, Speech
and Signal Processing, vol. 2, pp. 1201-1204, 1998. (Chapter 13)
[GrMi89]
S. Grossberg, E. Mingolla and D. Todorovic, A neural network architecture for preattentive vision, IEEE Transactions on Biomedical Engineering, vol. 36, no. 1, pp. 6584,
Jan. 1989. (Chapter 18)
[Gros67]
[Gros68]
S. Grossberg, Some physiological and biochemical consequences of psychological postulates, Proceedings of the National Academy of Sciences, vol. 60, pp. 758765, 1968.
(Chapter 15)
[Gros76]
S. Grossberg, Adaptive pattern classification and universal recoding: I. Parallel development and coding of neural
feature detectors, Biological Cybernetics, vol. 23, pp. 121
134, 1976. (Chapter 1, 18, 19)
[Gros80]
[Gros82]
[Gros90]
S. Grossberg, Neural networks: From foundations to applications, Short-Course Notes, Boston University, Boston, MA, May 611, 1990. (Chapter 18)
[HaBo07]
A Bibliography
[HaMe94]
M. T. Hagan and M. Menhaj, Training feedforward networks with the Marquardt algorithm, IEEE Transactions
on Neural Networks, vol. 5, no. 6, pp. 989993, 1994. (Chapter 12)
[HeBa99]
[Hebb 49]
[Hech90]
[HeOh97]
B. Hedn, H. hlin, R. Rittner, L. Edenbrandt, Acute Myocardial Infarction Detected in the 12-Lead ECG by Artificial Neural Networks, Circulation, vol. 96, pp. 17981802,
1997. (Chapter 22)
[Himm72]
[Hopf82]
[Hopf84]
J. J. Hopfield, Neurons with graded response have collective computational properties like those of two-state neurons, Proceedings of the National Academy of Sciences, vol.
81, pp. 30883092, 1984. (Chapter 21)
[HoTa85]
J. J. Hopfield and D. W. Tank, Neural computation of decisions in optimization problems, Biological Cybernetics,
vol. 52, pp. 141154, 1985. (Chapter 21)
[HoSt89]
A-5
A Bibliography
[Hube88]
[Jaco88]
[John01]
[Joll02]
[Koho72]
T. Kohonen, Correlation matrix memories, IEEE Transactions on Computers, vol. 21, pp. 353359, 1972. (Chapter
1, 15, 21)
[Koho87]
[Koho93]
T. Kohonen, Things you haven't heard about the Self-Organizing Map, Proceedings of the International Conference
on Neural Networks (ICNN), San Francisco, pp. 1147-1156,
1993. (Chapter 26)
[Koho95]
T. Kohonen, Self-Organizing Map, 2nd ed., Springer-Verlag, Berlin, 1995. (Chapter 26)
[LaSa67]
J. P. LaSalle, An invariance principle in the theory of stability, in Differential Equations and Dynamic Systems, J.
K. Hale and J. P. Lasalle, eds., New York: Academic Press,
pp. 277286, 1967. (Chapter 20)
[LeCu85]
[LeCu98]
[Leib90]
D. Lieberman, Learning, Behavior and Cognition, Belmont, CA: Wadsworth, 1990. (Chapter 15)
A-6
A Bibliography
[LiMi89]
[Lowe89]
[MacK92]
D. J. C. MacKay, Bayesian Interpolation, Neural Computation, vol. 4, pp. 415-447, 1992. (Chapter 13)
[MaNe99]
J.R. Magnu and H. Neudecker, Matrix Differential Calculus, John Wiley & Sons, Ltd., Chichester, 1999. (Chapter
14)
[MaGa00]
[McPi43]
[Mill90]
[Mill93]
[MoDa89]
[Moll93]
[MoMa01]
[MiPa69]
A-7
A Bibliography
[NaMu97]
Narendra, K.S.; Mukhopadhyay, S., Adaptive control using neural networks and approximate models, IEEE
Transactions on Neural Networks, vol. 8, no. 3, pp. 475 485, 1997. (Chapter 27)
[NaPa90]
[NgWi90]
[OrHa00]
M. J. Orr, J. Hallam, A. Murray, and T. Leonard, Assessing rbf networks using delve, IJNS, 2000. (Chapter 17)
[Park85]
D. B. Parker, Learning-logic: Casting the cortex of the human brain in silicon, Technical Report TR-47, Center for
Computational Research in Economics and Management
Science, MIT, Cambridge, MA, 1985. (Chapter 11)
[PaSa93]
J. Park and I.W. Sandberg, Universal approximation using radial-basis-function networks, Neural Computation,
vol. 5, pp. 305-316, 1993. (Chapter 17)
[PeCo93]
[PhHa13]
M. Phan and M. Hagan, Error Surface of Recurrent Networks, IEEE Transactions on Neural Networks and
Learning Systems, vol. 24, no. 11, pp. 1709 - 1721, October,
2013. (Chapter 14)
[Powe87]
M.J.D. Powell, Radial basis functions for multivariable interpolation: a review, Algorithms for Approximation, pp.
143-167, Oxford, 1987. (Chapter 17)
[PuFe97]
G.V. Puskorius and L.A. Feldkamp, Extensions and enhancements of decoupled extended Kalman filter training,
Proceedings of the 1997 International Conference on Neural
Networks, vol. 3, pp. 1879-1883, 1997. (Chapter 22)
[RaMa05]
L.M. Raff, M. Malshe, M. Hagan, D.I. Doughan, M.G. Rockley, and R. Komanduri, Ab initio potential-energy surfaces
for complex, multi-channel systems using modified novelty
sampling and feedforward neural networks, The Journal
of Chemical Physics, vol. 122, 2005. (Chapter 22, 24)
A-8
A Bibliography
[RiIr90]
A. K. Rigler, J. M. Irvine and T. P. Vogl, Rescaling of variables in back propagation learning, Neural Networks, vol.
3, no. 5, pp 561573, 1990. (Chapter 12)
[Rose58]
[Rose61]
[RuHi86]
[RuMc86]
D. E. Rumelhart and J. L. McClelland, eds., Parallel Distributed Processing: Explorations in the Microstructure of
Cognition, vol. 1, Cambridge, MA: MIT Press, 1986. (Chapter 1, 11, 16)
[Sarle95]
W. S. Sarle, Stopped training and other remedies for overfitting, In Proceedings of the 27th Symposium on Interface,
1995. (Chapter 13)
[Scal85]
[ScSm99]
[Shan90]
[SjLj94]
[SlLi91]
J.-J. E. Slotine and W. Li, Applied Nonlinear Control, Englewood Cliffs, NJ: Prentice-Hall, 1991. (Chapter 20)
[StDo84]
A-9
A Bibliography
[Stra76]
[TaHo86]
D. W. Tank and J. J. Hopfield, Simple neural optimization networks: An A/D converter, signal decision circuit
and a linear programming circuit, IEEE Transactions on
Circuits and Systems, vol. 33, no. 5, pp. 533541, 1986.
(Chapter 21)
[TeSi00]
[Tikh63]
[Toll90]
[vanT75]
[VoMa88]
[vond73]
C. von der Malsburg, Self-organization of orientation sensitive cells in the striate cortex, Kybernetic, vol. 14, pp. 85
100, 1973. (Chapter 18)
[WaVe94]
C. Wang, S. S. Venkatesh, and J. S. Judd, Optimal Stopping and Effective Machine Complexity in Learning, Advances in Neural Information Processing Systems, J. D.
Cowan, G. Tesauro, and J. Alspector, Eds., vol. 6, pp. 303310, 1994. (Chapter 13)
[Werbo74]
[Werb90]
A Bibliography
[WeTe84]
J. F. Werker and R. C. Tees, Cross-language speech perception: Evidence for perceptual reorganization during the
first year of life, Infant Behavior and Development, vol. 7,
pp. 49-63, 1984. (Chapter 1)
[WhSo92]
D. White and D. Sofge, eds., Handbook of Intelligent Control, New York:Van Nostrand Reinhold, 1992. (Chapter 4)
[WiHo60]
[WiSt 85]
[WiWi 88]
B. Widrow and R. Winter, Neural nets for adaptive filtering and adaptive pattern recognition, IEEE Computer
Magazine, March 1988, pp. 2539. (Chapter 10)
[WiZi89]
R. J. Williams and D. Zipser, A learning algorithm for continually running fully recurrent neural networks, Neural
Computation, vol. 1, pp. 270280, 1989. (Chapter 14)
A-11
B Notation
Notation
Basic Concepts
Scalars: small italic letters.....a,b,c
Vectors: small bold nonitalic letters.....a,b,c
Matrices: capital BOLD nonitalic letters.....A,B,C
Language
Vector means a column of numbers.
Row vector means a row of a matrix used as a vector (column).
w i j t
i - row, j - column, k - layer, t - time or iteration
Matrix
k
W t
Column Vector
k
wj t
Row Vector
iw
Bias Vector
Scalar Element
bi t
Vector
k
b t
B-1
B Notation
Input Vector
Scalar Element
pi t
As One of a Sequence of Input Vectors
pt
As One of a Set of Input Vectors
pq
n i t or n i q
Vector
k
n t or n q
Output Vector
Scalar Element
k
a i t or a i q
Vector
k
a t or a q
Transfer Function
Scalar Element
k
ai = f ni
Vector
k
a = f n
Target Vector
Scalar Element
t i t or t i q
B-2
B Notation
Vector
t t or t q
Error Vector
Scalar Element
e i t = t i t a i t or e i q = t i q a i q
Vector
e t or e q
Norm
x
Performance Index
F x
B-3
B Notation
fn =
f n
dn
Matrix
m m
f n 1
m
m
F n =
m m
f n2
m m
f n Sm
Jacobian Matrix
Jx
H = J J
Sensitivity Vector
Scalar Element
F
m
s i --------mn i
Vector
F
m
s --------mn
B-4
B Notation
S q and S
= S m S m S m
1
2
Q
Dynamic Networks
Sensitivity
e u
ak t
u m
s k i t ---------------m
n i t
Weight Matrices
IW
m l
LW
m l
Index Sets
DL m l - delays in the tapped delay line between Layer l and Layer m.
DI m l - delays in the tapped delay line between Input l and Layer m.
I m - indices of input vectors that connect to layer m.
f
E LW x = u U LW
X
ES u
= x X S
E S u = x S
X
E LW u
U
ES x
u x
u x
d 0 d 0
= x X LW
= u U S
B-5
x u
u x
x u
d 0 d 0
B Notation
Definitions
Input Layer (X) - has an input weight, or contains any delays with
any of its weight matrices
Output Layer (U) - its output will be compared to a target during
training, or it is connected to an input layer through a matrix that
has delays associated with it.
Generalization
Regularization Parameters
, and = --
Effective Number of Parameters
Selected Model
M
Sum Squared Error and Sum Squared Weights
ED , EW
Maximum Likelihood and Most Probable Weights
x
ML
,x
MP
B-6
B Notation
0 0 1
1 0 0
0 1 1
0
+ 1
- 1
1 0 1
W = 0 1
and W =
1 1 0
b and b
Time Constant
Relative Intensity
p
p i = ----i where P =
P
pj
j=1
1:2
and W
2:1
B-7
B Notation
Lyapunov Stability
Lyapunov Function
Va
Zero Derivative Set, Largest Invariant Set and Closure
Z , L and L
Bounded Lyapunov Function Set
= a:V a
B-8
Introduction
Software
Introduction
We have used MATLAB, a numeric computation and visualization software package, in this text. However, MATLAB is not essential for using
this book. The computer exercises can performed with any available programming language, and the Neural Network Design Demonstrations,
while helpful, are not critical to understanding the material covered in this
book.
MATLAB is widely available and, because of its matrix/vector notation and
graphics, is a convenient environment in which to experiment with neural
networks. We use MATLAB in two different ways. First, we have included
a number of exercises for the reader to perform in MATLAB. Many of the
important features of neural networks become apparent only for large scale
problems, which are computationally intensive and not feasible for hand
calculations. With MATLAB, neural network algorithms can be quickly implemented, and large scale problems can be tested conveniently. If MATLAB is not available, any other programming language can be used to
perform the exercises.
The second way in which we use MATLAB is through the Neural Network
Design Demonstrations, which can be downloaded from the website
hagan.okstate.edu/nnd.html. These interactive demonstrations illustrate
important concepts in each chapter. The icon to the left identifies references to these demonstrations in the text.
MATLAB, or the student edition of MATLAB, version 2010a or later,
should be installed on your computer in a a folder named MATLAB. To create this directory or folder and complete the MATLAB installation process,
follow the instructions given in the MATLAB documentation. Take care to
follow the guidelines given for setting the path.
After the Neural Network Design Demonstration software has been loaded
into the MATLAB directory on your computer (or if the MATLAB path has
been set to include the directory containing thedemonstration software),
the demonstrations can be invoked by typing nnd at the MATLAB prompt.
All demonstrations are easily accessible from a master menu.
C
C-1
C Software
Sound
Many of the demonstrations use sound. In many cases the sound adds to
the understanding of a demonstration. In other cases it is there simply for
fun. If you need to turn the sound off you can give MATLAB the following
command and all demonstrations will run quietly:
nnsound off
You may note that demonstrations that utilize sound often run faster when
sound is off. In addition, on some machines which do not support sound errors can occur unless the sound is turned off.
List of Demonstrations
General
nnd - Splash screen.
nndtoc - Table of contents.
nnsound - Turn Neural Network Design sounds on and off.
Chapter 2, Neuron Model and Network Architectures
nnd2n1 - One-input neuron.
nnd2n2 - Two-input neuron.
Chapter 3, An Illustrative Example
nnd3pc - Perceptron classification.
nnd3hamc - Hamming classification.
nnd3hopc - Hopfield classification.
C-2
C
C-3
C Software
C-4
C
C-5
Index
Index
A
Abbreviated notation 2-8
ADALINE network 10-2
decision boundary 10-4
mean square error 10-4
Adaptive filtering 10-13
Adaptive noise cancellation 10-15
Adaptive resonance theory (ART) 19-2
Amacrine cells 18-4
Amari, S. 18-2
AND gate 4-7
Anderson, J.A. 1-2, 1-3, 15-2, 18-2
Angle 5-7
Apple and Orange Example 3-2
Hamming network solution 3-8
Hopfield solution 3-12
perceptron 3-3
perceptron solution 3-5
problem statement 3-2
Applications of neural networks 1-5
aerospace 1-5
automotive 1-5
banking 1-5
defense 1-6
electronics 1-6
entertainment 1-6
financial 1-6
insurance 1-6
manufacturing 1-6
medical 1-6
oil and gas 1-6
robotics 1-7
securities 1-7
speech 1-7
telecommunications 1-7
transportation 1-7
ART1
fast learning 19-19
Layer 1 19-4
Layer 2 19-10
learning law
L1 - L2 19-17
L2 - L1 19-20
orienting subsystem 19-13
resonance 19-17
subset/superset dilemma 19-17
summary 19-21
vigilance 19-15
ART2 19-23
ART3 19-23
ARTMAP 19-23
Associative learning
Hebb rule 7-4
instar rule 15-11
Kohonen rule 15-15
outstar rule 15-17
pseudoinverse rule 7-7
unsupervised Hebb rule 15-5
Associative memory 7-3
autoassociative memory 7-10
Hopfield network 21-5
linear associator 7-3
Associative networks 15-3
instar 15-9
outstar 15-16
Attractors 21-11
Autoassociative memory 7-10
Autocorrelation function 22-24
B
Backpropagation 11-7
batching 12-7
CGBP 12-15
choice of network architecture 11-18
conjugate gradient 12-14
convergence 11-20
Index-1
Index
delta-bar-delta 12-13
drawbacks 12-3, 14-3
example 11-14
generalization 11-22
initial weights 12-6
Jacobian matrix 12-23
Levenberg-Marquardt 12-19, 12-21
Jacobian calculation 12-22
Marquardt sensitivity 12-24
LMBP 12-25
MOBP 12-11
performance index 11-8
performance surface 12-3
Quickprop 12-14
SDBP 12-2
sensitivity 11-10
summary 11-13
SuperSAB 12-14
VLBP 12-12
Backpropagation order 14-4
Backpropagation-through-time (BPTT) 14-2, 1411, 14-22
Backward elimination 17-18
Basis set 5-5
Batch SOFM learning algorithm 26-6
Batch training 11-17
Batching 12-7
Bayes rule 13-10
Bayes Theorem 13-10
Bayesian analysis 13-12
effective number of parameters 13-16
evidence 13-13
Gauss-Newton approximation to Bayesian
regularization 13-17
likelihood function 13-13
posterior density 13-13
prior density 13-13
Bayesian regularization 13-12, 23-6
effective number of parameters 23-6
Baysian analysis
most probable 13-14
Biological inspiration of neural networks 1-8
Bipolar cells 18-3
Brightness constancy 18-8
C
Carpenter, G. 19-2
Center 17-6
CGBP 12-15
Chain rule 11-9
Change of basis 6-6
similarity transformation 6-8
Chemical vapor deposition 24-2
Choice of network architecture 11-18
Circular hollow 8-16
Clustering 22-9
Coding the targets 22-7
Committee of networks 22-18, 25-10
Competitive learning 16-7
adaptive resonance theory 19-2
ART1 19-4
ART2 19-23
ART3 19-23
ARTMAP 19-23
Fuzzy ARTMAP 19-23
instar rule 16-7
Kohonen rule 16-7
learning rate 16-9
LVQ2 16-21
problems 16-9
Competitive networks 16-5
ART1 19-4
Grossberg 18-13
Hamming network 16-3
Lateral inhibition 16-5
learning vector quantization 16-16
self-organizing feature map 16-12
winner-take-all 16-5
Conditioned stimulus 15-3
Cones 18-3
Confusion matrix 22-21, 25-7
Conjugate directions 9-16
Conjugate gradient 9-15, 12-14
golden section search 12-17
interval location 12-16
interval reduction 12-16
Content-addressable memory 21-16
Contour plot 8-8
Contrast enhance 18-18
Index-2
Index
control
electromagnet 27-2
Correlation matrix 10-6
Cross-correlation function 22-25
Cross-entropy 22-17
Cross-validation 13-6
Curse of dimensionality 17-11
D
Decay rate 15-7
Decision boundary 4-5, 10-4, 11-4
Delay 2-13
Delta rule 7-13, 10-7
Delta-bar-delta 12-13
Descent direction 9-3
Diagonalization 6-13
Directional derivative 8-5
Distortion measure 22-23
Domain 6-2
Dynamic networks 14-2
E
Early stopping 13-7, 13-19, 25-7
Echo cancellation 10-21
EEG 10-15
Effective number of parameters 13-16, 13-23, 236
Eigenvalues 6-10
Eigenvectors 6-10
Electrocardiagram 25-2
electromagnet 27-2
Elliptical hollow 8-17
Emergent segmentation 18-6
Equilibrium point 20-4
Euclidean space 5-3
evidence 13-13
Excitatory 18-10
Extended Kalman filter algorithm 22-14
Extrapolation 13-3, 22-21, 22-27
F
Fahlman, A.E. 12-14
False negative 22-21
False positive 22-22
H
Hamming network 3-8, 16-3
feedforward layer 3-8, 16-3
recurrent layer 3-9, 16-4
Hebb rule 7-4, 21-18
decay rate 15-7
performance analysis 7-5
supervised 7-4
unsupervised 7-4, 15-5
with decay 7-12
Hebb, D.O. 1-3, 7-2
Hebbs postulate 7-2
Hebbian learning 7-2
variations 7-12
Index-3
Index
Hessian 8-5
eigensystem 8-13
Hidden layer 2-11
High-gain Lyapunov function 21-13
Hinton, G.E. 11-2
Histogram of errors 22-21
History of neural networks 1-2
Hoff, M.E. 1-3, 10-2, 11-2
Hopfield model 21-3
Hopfield network 3-12, 6-2, 21-5
attractors 21-11
design 21-16
content-addressable memory 21-16
effect of gain 21-12
example 21-7
Hebb rule 21-18
high-gain Lyapunov function 21-13
Lasalles invariance theorem 21-7
Lyapunov function 21-5
Lyapunov surface 21-22
spurious patterns 21-20
Hopfield, J.J. 1-4
Horizontal cells 18-4
Hubel, D.H. 16-2, 18-12
I
Illusions 18-4
Incremental training 11-17
Infinite impulse response 14-7
Inhibitory 18-10
Inner product 5-6
Input selection 22-12
Input weight 14-3
Instar 15-9
Instar rule 15-11, 16-7
Integrator 2-13
Interpolation 13-3
Interval location 12-16
Interval reduction 12-16
Invariant set 20-13
J
Jacobian matrix 12-20
Jacobs, R.A. 12-13
K
Kohonen rule 15-15, 16-7
graphical representation 16-7
Kohonen, T. 1-3, 15-2, 18-2
L
LaSalles corollary 20-14
LaSalles invariance theorem 20-13
invariant set 20-13
Set
L 20-13
Z 20-12
Lateral inhibition 16-5
Layer 2-9
competitive 16-5
problems 16-9
hidden 2-11
output layer 2-11
superscript 2-11
Layer weight 14-3
Layered Digital Dynamic Network (LDDN) 14-3
Le Cun, Y. 11-2
Leaky integrator 18-9
Learning rate 9-3, 10-8
competitive learning 16-9
stable 9-6, 10-10
Learning rules 4-2
ART1 19-21
backpropagation 11-7
competitive learning 16-7
delta rule 7-13
Grossberg competitive network 18-22
Hebb rule 7-4
Hebbian learning 7-2
learning vector quantization 16-16
LMS algorithm 10-7
local learning 15-5
perceptron 4-8, 4-13
proof of convergence 4-15
performance learning 8-2
pseudoinverse rule 7-7
reinforcement learning 4-3
supervised learning 4-3
unsupervised learning 4-3
Index-4
Index
Widrow-Hoff 7-13
Learning vector quantization (LVQ) 16-16
subclass 16-17
Levenberg-Marquardt algorithm 12-19, 12-21,
22-14, 24-7
Jacobian calculation 12-22
Jacobian matrix 12-20
Likelihood function 13-13
Linear associator 7-3
Linear independence 5-4
Linear initialization 26-6
Linear least squares 17-11
Linear separability 4-19
Linear transformation 6-2
change of basis 6-6
domain 6-2
matrix representation 6-3
change of basis 6-6
range 6-2
Linear vector spaces 5-2
LMBP 12-25
LMS algorithm 10-2, 10-7
adaptive filtering 10-13
adaptive noise cancellation 10-15
analysis of convergence 10-9
learning rate 10-8
stable learning rate 10-10
Local learning 15-5
Long term memory (LTM) 18-12, 18-22
LVQ2 16-21
Lyapunov function 20-12
Lyapunov stability theorem 20-6
M
Mach, E. 1-2
magnet 27-2
Marquardt algorithm 12-19
Marquardt sensitivity 12-24
Matrix representation 6-3
change of basis 6-6
diagonalization 6-13
McClelland, J.L. 1-4, 11-2
McCulloch, W.S. 1-3, 4-2
Mean square error 10-4, 11-8
N
NARX network 22-10
Negative definite matrix 8-11
Negative semidefinite 8-11
Neighborhood 16-12
Network architectures 2-9
layer 2-9
multiple layers 2-10
Neural Network Toolbox for MATLAB 1-5
Neuron model 2-2
multiple input neuron 2-7
single input neuron 2-2
transfer functions 2-3
Newtons method 9-10
Nguyen-Widrow weight initialization 22-13, 24-9
Nilsson, N. 16-2
Noise cancellation
adaptive 10-15
echo cancellation 10-21
Norm 5-7
Index-5
Index
single-neuron 4-5
test problem 4-9
training multiple-neuron perceptrons 4-13
two-input case 3-4
unified learning rule 4-12
Performance Index 11-8
Performance index 8-2, 22-16
cross-entropy 22-17
mean squared error 22-16
Minkowski error 22-17
quadratic function 8-12
Performance learning 8-2
Pitts, W.H. 1-3, 4-2
Positive definite 20-5
Positive definite matrix 8-11
Positive semidefinite 8-11, 20-5
posterior density 13-13
Post-training analysis 22-18
Prediction 22-10, 22-24
Preprocessing 22-5
coding the targets 22-7
feature extraction 22-6
normalization 22-5, 25-6, 26-4
principal component analysis 22-6
Principal component analysis 22-6
Prior density 13-13
Probability estimation 24-2
Projection 5-8
Prototype patterns 21-16
Pseudoinverse rule 7-7
Index-6
Index
R
R value 22-20
Radial basis network 17-2
backpropagation 17-25
center 17-6
pattern classification 17-6
Range 6-2
RBF 17-2
Real-time recurrent learning (RTRL) 14-2, 14-11,
14-12
Receiver operating characteristic (ROC) curve
22-22, 25-8
Reciprocal basis vectors 5-10
Recurrent 14-2
Recurrent network 2-13, 2-14, 20-2
regression 22-8
Regression/scatter plot 22-20
Regularization 13-8, 13-19, 13-21
Reinforcement learning 4-3
Resonance 19-17
Retina 18-3
Rods 18-3
Rosenblatt, F. 1-3, 4-2, 10-2, 11-2, 16-2
Rosenfeld, E. 1-2
Rumelhart, D.E. 1-4, 11-2
S
Saddle point 8-8, 8-18
Scaled conjugate gradient algorithm 22-14
SDBP 12-2
Segmentation 22-9
Self-organizing feature map (SOFM) 16-12, 2216, 26-2
distortion measure 22-23
neighborhood 16-12
quantization error 22-23
topographic error 22-23
Sensitivity 11-10
backpropagation 11-11
Sensitivity analysis 22-28
Set
L 20-13
Z 20-12
Shakespeare, W. 1-5
T
Tapped delay line 10-13
Target 4-3
Index-7
Index
W
Weight indices 2-7
Weight initialization 22-13, 24-9
Weight matrix 2-7
Werbos, P.J. 11-2
White noise 22-24
Widrow, B. 1-3, 10-2, 11-2
Widrow-Hoff algorithm 7-13, 10-7
adaptive filtering 10-13
Wiesel, T. 16-2, 18-12
Williams, R.J. 11-2
Winner-take-all 16-5
U
Unconditioned stimulus 15-3
Unsupervised learning 4-3
Hebb rule 7-4, 15-5
V
Validation set 13-7
Vector expansion 5-9
reciprocal basis vectors 5-10
Vector space 5-2
angle 5-7
basis set 5-5
orthonormal 5-9
projection 5-8
spanning 5-5
vector expansion 5-9
Vigilance 19-15
Vision 18-3
Index-8
This book provides a clear and detailed coverage of fundamental neural network
architectures and learning rules. In it, the authors emphasize a coherent presentation of the
principal neural networks, methods for training them and their applications to practical
problems.
Features
Extensive coverage of training methods for both feedforward networks (including
multilayer and radial basis networks) and recurrent networks. In addition to conjugate
gradient and Levenberg-Marquardt variations of the backpropagation algorithm, the
text also covers Bayesian regularization and early stopping, which ensure the
generalization ability of trained networks.
Associative and competitive networks, including feature maps and learning vector
quantization, are explained with simple building blocks.
A chapter of practical training tips for function approximation, pattern recognition,
clustering and prediction, along with five chapters presenting detailed real-world case
studies.
Detailed examples and numerous solved problems. Slides and comprehensive
demonstration software can be downloaded from hagan.okstate.edu/nnd.html.