NNDesign PDF
NNDesign PDF
NNDesign PDF
Network
Design
Hagan
Demuth
2nd Edition Beale
De Jess
Neural Network Design
2nd Edtion
Martin T. Hagan
Oklahoma State University
Stillwater, Oklahoma
Howard B. Demuth
University of Colorado
Boulder, Colorado
Orlando De Jess
Consultant
Frisco, Texas
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.
Introduction
Objectives 1-1
History 1-2
Applications 1-5
Biological Inspiration 1-8
Further Reading 1-10
i
An Illustrative Example
3 Objectives 3-1
Theory and Examples 3-2
Problem Statement 3-2
Perceptron 3-3
Two-Input Case 3-4
Pattern Recognition Example 3-5
Hamming Network 3-8
Feedforward Layer 3-8
Recurrent Layer 3-9
Hopfield Network 3-12
Epilogue 3-15
Exercises 3-16
ii
Signal and Weight Vector Spaces
5 Objectives 5-1
Theory and Examples 5-2
Linear Vector Spaces 5-2
Linear Independence 5-4
Spanning a Space 5-5
Inner Product 5-6
Norm 5-7
Orthogonality 5-7
Gram-Schmidt Orthogonalization 5-8
Vector Expansions 5-9
Reciprocal Basis Vectors 5-10
Summary of Results 5-14
Solved Problems 5-17
Epilogue 5-26
Further Reading 5-27
Exercises 5-28
iii
Supervised Hebbian Learning
7 Objectives 7-1
Theory and Examples 7-2
Linear Associator 7-3
The Hebb Rule 7-4
Performance Analysis 7-5
Pseudoinverse Rule 7-7
Application 7-10
Variations of Hebbian Learning 7-12
Summary of Results 17-4
Solved Problems 7-16
Epilogue 7-29
Further Reading 7-30
Exercises 7-31
iv
Performance Optimization
9 Objectives 9-1
Theory and Examples 9-2
Steepest Descent 9-2
Stable Learning Rates 9-6
Minimizing Along a Line 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
10 Widrow-Hoff Learning
Objectives 10-1
Theory and Examples 10-2
ADALINE Network 10-2
Single ADALINE 10-3
Mean Square Error 10-4
LMS Algorithm 10-7
Analysis of Convergence 10-9
Adaptive Filtering 10-13
Adaptive Noise Cancellation 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
v
Backpropagation
11 Objectives 11-1
Theory and Examples 11-2
Multilayer Perceptrons 11-2
Pattern Classification 11-3
Function Approximation 11-4
The Backpropagation Algorithm 11-7
Performance Index 11-8
Chain Rule 11-9
Backpropagating the Sensitivities 11-11
Summary 11-13
Example 11-14
Batch vs. Incremental Training 11-17
Using Backpropagation 11-18
Choice of Network Architecture 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
12 Variations on Backpropagation
Objectives 12-1
Theory and Examples 12-2
Drawbacks of Backpropagation 12-3
Performance Surface Example 12-3
Convergence Example 12-7
Heuristic Modifications of Backpropagation 12-9
Momentum 12-9
Variable Learning Rate 12-12
Numerical Optimization Techniques 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
vi
Generalization
13 Objectives 13-1
Theory and Examples 13-2
Problem Statement 13-2
Methods for Improving Generalization 13-5
Estimating Generalization Error 13-6
Early Stopping 13-6
Regularization 13-8
Bayesian Analysis 13-10
Bayesian Regularization 13-12
Relationship Between Early Stopping
and Regularization 13-19
Summary of Results 13-29
Solved Problems 13-32
Epilogue 13-44
Further Reading 13-45
Exercises 13-47
14 Dynamic Networks D
Objectives 14-1
Theory and Examples 14-2
Layered Digital Dynamic Networks 14-3
Example Dynamic Networks 14-5
Principles of Dynamic Learning 14-8
Dynamic Backpropagation 14-12
Preliminary Definitions 14-12
Real Time Recurrent Learning 14-12
Backpropagation-Through-Time 14-22
Summary and Comments on
Dynamic Training 14-30
Summary of Results 14-34
Solved Problems 14-37
Epilogue 14-46
Further Reading 14-47
Exercises 14-48
vii
Associative Learning
15 Objectives 15-1
Theory and Examples 15-2
Simple Associative Network 15-3
Unsupervised Hebb Rule 15-5
Hebb Rule with Decay 15-7
Simple Recognition Network 15-9
Instar Rule 15-11
Kohonen Rule 15-15
Simple Recall Network 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
16 Competitive Networks
Objectives 16-1
Theory and Examples 16-2
Hamming Network 16-3
Layer 1 16-3
Layer 2 16-4
Competitive Layer 16-5
Competitive Learning 16-7
Problems with Competitive Layers 16-9
Competitive Layers in Biology 16-10
Self-Organizing Feature Maps 16-12
Improving Feature Maps 16-15
Learning Vector Quantization 16-16
LVQ Learning 16-18
Improving LVQ Networks (LVQ2) 16-21
Summary of Results 16-22
Solved Problems 16-24
Epilogue 16-37
Further Reading 16-38
Exercises 16-39
viii
Radial Basis Networks
17 Objectives 17-1
Theory and Examples 17-2
Radial Basis Network 17-2
Function Approximation 17-4
Pattern Classification 17-6
Global vs. Local 17-9
Training RBF Networks 17-10
Linear Least Squares 17-11
Orthogonal Least Squares 17-18
Clustering 17-23
Nonlinear Optimization 17-25
Other Training Techniques 17-26
Summary of Results 17-27
Solved Problems 17-30
Epilogue 17-35
Further Reading 17-36
Exercises 17-38
18 Grossberg Network
Objectives 18-1
Theory and Examples 18-2
Biological Motivation: Vision 18-3
Illusions 18-4
Vision Normalization 18-8
Basic Nonlinear Model 18-9
Two-Layer Competitive Network 18-12
Layer 1 18-13
Layer 2 18-17
Choice of Transfer Function 18-20
Learning Law 18-22
Relation to Kohonen Law 18-24
Summary of Results 18-26
Solved Problems 18-30
Epilogue 18-42
Further Reading 18-43
Exercises 18-45
ix
Adaptive Resonance Theory
19 Objectives 19-1
Theory and Examples 19-2
Overview of Adaptive Resonance 19-2
Layer 1 19-4
Steady State Analysis 19-6
Layer 2 19-10
Orienting Subsystem 19-13
Learning Law: L1-L2 19-17
Subset/Superset Dilemma 19-17
Learning Law 19-18
Learning Law: L2-L1 19-20
ART1 Algorithm Summary 19-21
Initialization 19-21
Algorithm 19-21
Other ART Architectures 19-23
Summary of Results 19-25
Solved Problems 19-30
Epilogue 19-45
Further Reading 19-46
Exercises 19-48
20 Stability
Objectives 20-1
Theory and Examples 20-2
Recurrent Networks 20-2
Stability Concepts 20-3
Definitions 20-4
Lyapunov Stability Theorem 20-5
Pendulum Example 20-6
LaSalles Invariance Theorem 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 30
x
Hopfield Network
21 Objectives 21-1
Theory and Examples 21-2
Hopfield Model 21-3
Lyapunov Function 21-5
Invariant Sets 21-7
Example 21-7
Hopfield Attractors 21-11
Effect of Gain 21-12
Hopfield Design 21-16
Content-Addressable Memory 21-16
Hebb Rule 21-18
Lyapunov Surface 21-22
Summary of Results 21-24
Solved Problems 21-26
Epilogue 21-36
Further Reading 21-37
Exercises 21-40
xi
Case Study 1:Function Approximation
23 Objectives 23-1
Theory and Examples 23-2
Description of the Smart Sensor System 23-2
Data Collection and Preprocessing 23-3
Selecting the Architecture 23-4
Training the Network 23-5
Validation 23-7
Data Sets 23-10
Epilogue 23-11
Further Reading 23-12
xii
Case Study 4: Clustering
26 Objectives 26-1
Theory and Examples 26-2
Description of the Forest Cover Problem 26-2
Data Collection and Preprocessing 26-4
Selecting the Architecture 26-5
Training the Network 26-6
Validation 26-7
Data Sets 26-11
Epilogue 26-12
Further Reading 26-13
xiii
Appendices
A Bibliography
B Notation
C Software
I 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 recog-
nition, 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 prob-
lems.
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 net-
work implementation technologies, such as VLSI, optical devices and par-
allel computers. Finally, we do not present the biological and psychological
foundations of neural networks in any depth. These are all important top-
ics, 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 suit-
able for short courses, self-study and reference.) The reader is expected to
have some background in linear algebra, probability and differential equa-
tions.
P-1
Preface
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 compris-
es the main body of each chapter. It includes the development of fundamen-
tal ideas as well as worked examples (indicated by the icon shown here in
2 the left margin). The Summary of Results section provides a convenient
+2
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.
1 7
Introduction Performance 8 Supervised
Surfaces Hebb
2
Architectures
Peformance 9 Associative 15
Optimization Learning
Illustrative 3
Example 10 Competitive 16
Widrow-Hoff
Learning
Perceptron 4 11
Learning Rule Backpropagation 18
Grossberg
Radial Basis 17
22
Networks Practical Training
Case Study 23 Case Study 24 Case Study 25 Case Study 27 Case Study 26
Function Probability Pattern Prediction Clustering
Approximation Estimation Recognition
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 ba-
P-2
sic neural network architectures. The notation that is introduced in this
chapter is used throughout the book. In Chapter 3 we present a simple pat-
tern recognition problem and show how it can be solved using three differ-
ent types of neural networks. These three networks are representative of
the types of networks that are presented in the remainder of the text. In
addition, the pattern recognition problem presented here provides a com-
mon thread of experience throughout the book.
Much of the focus of this book will be on methods for training neural net-
works to perform various tasks. In Chapter 4 we introduce learning algo-
rithms and present the first practical algorithm: the perceptron learning
rule. The perceptron network has fundamental limitations, but it is impor-
tant for historical reasons and is also a useful tool for introducing key con-
cepts that will be applied to more powerful networks in later chapters.
One of the main objectives of this book is to explain how neural networks
operate. For this reason we will weave together neural network topics with
important introductory material. For example, linear algebra, which is the
core of the mathematics required for understanding neural networks, is re-
viewed in Chapters 5 and 6. The concepts discussed in these chapters will
be used extensively throughout the remainder of the book.
Chapters 7, and 1519 describe networks and learning rules that are
heavily inspired by biology and psychology. They fall into two categories:
associative networks and competitive networks. Chapters 7 and 15 intro-
duce basic concepts, while Chapters 1619 describe more advanced net-
works.
Chapters 814 and 17 develop a class of learning called performance learn-
ing, in which a network is trained to optimize its performance. Chapters 8
and 9 introduce the basic concepts of performance learning. Chapters 10
13 apply these concepts to feedforward neural networks of increasing pow-
er and complexity, Chapter 14 applies them to dynamic networks and
Chapter 17 applies them to radial basis networks, which also use concepts
from competitive learning.
Chapters 20 and 21 discuss recurrent associative memory networks. These
networks, which have feedback connections, are dynamical systems. Chap-
ter 20 investigates the stability of these systems. Chapter 21 presents the
Hopfield network, which has been one of the most influential recurrent net-
works.
Chapters 2227 are different than the preceding chapters. Previous chap-
ters focus on the fundamentals of each type of network and their learning
rules. The focus is on understanding the key concepts. In Chapters 2227,
we discuss some practical issues in applying neural networks to real world
problems. Chapter 22 describes many practical training tips, and Chapters
2327 present a series of case studies, in which neural networks are ap-
plied to practical problems in function approximation, probability estima-
tion, pattern recognition, clustering and prediction.
P-3
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 under-
standing the material covered in this book.
However, we have made use of the MATLAB software package to supple-
ment the textbook. This software is widely available and, because of its ma-
trix/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 ap-
parent only for large-scale problems, which are computationally intensive
and not feasible for hand calculations. With MATLAB, neural network al-
gorithms can be quickly implemented, and large-scale problems can be
2+2
tested conveniently. These MATLAB exercises are identified by the icon
ans = shown here to the left. (If MATLAB is not available, any other program-
4 ming 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 Mill-
er 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 Na-
tional des Sciences Appliques and ECE 5120 at the University of Colo-
rado, 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
1 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 net-
works operate. It is generally understood that all biological neural func-
tions, 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 understand-
ing of biological neural networks, is it possible to construct a small set of
simple artificial neurons and perhaps train them to serve a useful func-
tion? The answer is yes. This book, then, is about artificial neural net-
works.
The neurons that we consider here are not biological. They are extremely
simple abstractions of biological neurons, realized as elements in a pro-
gram 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 neu-
rons, the networks that contain them and their training.
1-1
1 Introduction
History
The history of artificial neural networks is filled with colorful, creative in-
dividuals from a variety of fields, many of whom struggled for decades to
develop concepts that we now take for granted. This history has been doc-
umented by various authors. One particularly interesting book is Neuro-
computing: 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 re-
peated here. However, it seems appropriate to give a brief overview, a sam-
ple 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 circula-
tory 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 be-
fore the availability of high-speed computers and efficient algorithms final-
ly made it practical to implement a useful CAT system.
The history of neural networks has progressed through both conceptual in-
novations and implementation developments. These advancements, how-
ever, 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 interdis-
ciplinary work in physics, psychology and neurophysiology by such scien-
tists 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 net-
work field.
McCulloch and Pitts were followed by Donald Hebb [Hebb49], who pro-
posed that classical conditioning (as discovered by Pavlov) is present be-
cause 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 learn-
ing rule by Frank Rosenblatt [Rose58]. Rosenblatt and his colleagues built
a perceptron network and demonstrated its ability to perform pattern rec-
ognition. This early success generated a great deal of interest in neural net-
work 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] intro-
duced 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 Chap-
ter 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 Mar-
vin Minsky and Seymour Papert [MiPa69]. Rosenblatt and Widrow were
aware of these limitations and proposed new networks that would over-
come them. However, they were not able to successfully modify their learn-
ing algorithms to train the more complex networks.
Many people, influenced by Minsky and Papert, believed that further re-
search 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 re-
search 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 investi-
gation 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
1
Applications
A newspaper article described the use of neural networks in literature re-
search 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 sci-
ence television program documented the use of neural networks by an Ital-
ian research institute to test the purity of olive oil. Google uses neural
networks for image tagging (automatically identifying an image and as-
signing keywords), and Microsoft has developed neural networks that can
help convert spoken English speech into spoken Chinese speech. Research-
ers at Lund University and Skne University Hospital in Sweden have
used neural networks to improve long-term survival rates for heart trans-
plant 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 net-
works 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 repro-
duced here from the Neural Network Toolbox for MATLAB with the per-
mission of the MathWorks, Inc.
A 1988 DARPA Neural Network Study [DARP88] lists various neural net-
work applications, beginning with the adaptive channel equalizer in about
1984. This device, which is an outstanding commercial success, is a single-
neuron 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 com-
ponent 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 evalua-
tors, cash forecasting, firm classification, exchange rate fore-
casting, predicting loan recovery rates, measuring credit risk
Defense
Weapon steering, target tracking, object discrimination, facial
recognition, new kinds of sensors, sonar, radar and image sig-
nal processing including data compression, feature extraction
and noise suppression, signal/image identification
Electronics
Code sequence prediction, integrated circuit chip layout, pro-
cess control, chip failure analysis, machine vision, voice syn-
thesis, nonlinear modeling
Entertainment
Animation, special effects, market forecasting
Financial
Real estate appraisal, loan advisor, mortgage screening, corpo-
rate bond rating, credit line use analysis, portfolio trading pro-
gram, 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 identifica-
tion, visual quality inspection systems, beer testing, welding
quality analysis, paper quality prediction, computer chip qual-
ity analysis, analysis of grinding operations, chemical product
design analysis, machine maintenance analysis, project bid-
ding, planning and management, dynamic modeling of chemi-
cal process systems
1-6
Applications
Medical
1
Breast cancer cell analysis, EEG and ECG analysis, prosthesis
design, optimization of transplant times, hospital expense re-
duction, hospital quality improvement, emergency room test
advisement
Robotics
Trajectory control, forklift robot, manipulator controllers, vi-
sion 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 in-
vested 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 re-
lated 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 con-
nected elements (approximately 104 connections per element) called neu-
rons. 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
1-8
Biological Inspiration
it has been shown that if a young cat is denied use of one eye during a crit-
1
ical window of time, it will never develop normal vision in that eye. Lin-
guists have discovered that infants over six months of age can no longer
discriminate certain speech sounds, unless they were exposed to them ear-
lier 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 ob-
jective 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 neu-
ral 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 com-
puters, their parallel structure makes them ideally suited to implementa-
tion 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 in-
teractive memory, Mathematical Biosciences, Vol. 14, pp.
197220, 1972.
Anderson proposed a linear associator model for associa-
tive memory. The model was trained, using a generaliza-
tion 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: Foun-
dations of Research, Cambridge, MA: MIT Press, 1989.
Neurocomputing is a fundamental reference book. It con-
tains 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 Lin-
coln Laboratory, 1988.
This study is a compendium of knowledge of neural net-
works as they were known to 1988. It presents the theoret-
ical 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 im-
plementation technology.
[Gros76] S. Grossberg, Adaptive pattern classification and univer-
sal 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 contin-
uous-time competitive network. It forms a basis for the
adaptive resonance theory (ART) networks.
1-10
Further Reading
1-11
1 Introduction
1-12
Further Reading
1-13
Objectives
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 in-
terconnected to form a variety of network architectures. We will also illus-
trate the basic operation of these networks through some simple examples.
The concepts and notation introduced in this chapter will be used through-
out 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 architec-
tures 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 read-
ing. Instead, treat it as a sample to get you started and a resource to which
you can return.
2-1
2 Neuron Model and Network Architectures
Notation
Unfortunately, there is no single neural network notation that is universal-
ly accepted. Papers and books on neural networks have come from many di-
verse fields, including engineering, physics, psychology and mathematics,
and many authors tend to use vocabulary peculiar to their specialty. As a
result, many books and papers in this field are difficult to read, and con-
cepts are made to seem more complex than they actually are. This is a
shame, as it has prevented the spread of important new ideas. It has also
led to more than one reinvention of the wheel.
In this book we have tried to use standard notation where possible, to be
clear and to keep matters simple without sacrificing rigor. In particular, we
have tried to define practical conventions and use them consistently.
Figures, mathematical equations and text discussing both figures and
mathematical equations will use the following notation:
Scalars small italic letters: a,b,c
Vectors small bold nonitalic letters: a,b,c
Matrices capital BOLD nonitalic letters: A,B,C
Additional notation concerning the network architectures will be intro-
duced as you read this chapter. A complete list of the notation that we use
throughout the book is given in Appendix B, so you can look there if you
have a question.
Neuron Model
Single-Input Neuron
A single-input neuron is shown in Figure 2.1. The scalar input p is multi-
Weight plied by the scalar weight w to form wp , one of the terms that is sent to the
Bias summer. The other input, 1 , is multiplied by a bias b and then passed to
Net Input the summer. The summer output n , often referred to as the net input, goes
Transfer Function into a transfer function f , which produces the scalar neuron output a .
(Some authors use the term activation function rather than transfer func-
tion and offset rather than bias.)
If we relate this simple model back to the biological neuron that we dis-
cussed 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
w n a
p f
b
1
a = f (wp + b)
a = f wp + b .
a = f 3 2 1.5 = f 4.5
The actual output depends on the particular transfer function that is cho-
sen. 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 pa-
rameters w and b will be adjusted by some learning rule so that the neu-
ron 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 The hard limit transfer function, shown on the left side of Figure 2.2, sets
Transfer Function 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 cre-
ate neurons that classify inputs into two distinct categories. It will be used
extensively in Chapter 4.
2-3
2 Neuron Model and Network Architectures
a a
+1 +1
n p
0 -b/w 0
-1 -1
a = hardlim (n) a = hardlim (wp + b)
Hard Limit Transfer Function Single-Input hardlim Neuron
a a
+1 +b
-b/w
n p
0 0
-1
a = purelin (n) a = purelin (wp + b)
Linear Transfer Function Single-Input purelin Neuron
2-4
Neuron Model
a a
+1 +1
n p
0 -b/w 0
-1 -1
a = logsig (n) a = logsig (wp + b)
Log-Sigmoid Transfer Function Single-Input logsig Neuron
1
-.
a = ---------------
n
(2.2)
1+e
2-5
2 Neuron Model and Network Architectures
MATLAB
Name Input/Output Relation Icon Function
a = 0 n0
Hard Limit hardlim
a = 1 n0
a = 1 n0
Symmetrical Hard Limit hardlims
a = +1 n0
Linear a = n purelin
a = 0 n0
Saturating Linear a = n 0n1 satlin
a = 1 n1
a = 1 n 1
Symmetric Saturating
a = n 1 n 1 satlins
Linear
a = 1 n1
1
Log-Sigmoid a = ---------------
n
- logsig
1+e
n n
Hyperbolic Tangent e e
a = -----------------
- tansig
Sigmoid n
e +e
n
a = 0 n0
Positive Linear poslin
a = n 0n
Competitive
a = 1
a = 0
neuron with max n
all other neurons
C compet
2-6
Neuron Model
Multiple-Input Neuron
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
Weight Matrix corresponding elements w 1 1 ,w 1 2 ,... ,w 1 R of the weight matrix W .
p1 w1, 1
p2
p3 n a
f
w1, R b
pR
1
a = f (Wp + b)
n = w 1 1 p 1 + w 1 2 p 2 + ... + w 1 R p R + b . (2.3)
n = Wp + b , (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)
2-7
2 Neuron Model and Network Architectures
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 de-
tail might obscure the main features. Thus, we will use an abbreviated no-
Abbreviated Notation tation. A multiple-input neuron using this notation is shown in Figure 2.6.
p a
Rx1 W 1x1
n
1xR
1x1 f
1 b
1x1
R 1
a = f (Wp + b)
As shown in Figure 2.6, the input vector p is represented by the solid ver-
tical bar at the left. The dimensions of p are displayed below the variable
as R 1 , indicating that the input is a single vector of R elements. These
inputs go to the weight matrix W , which has R columns but only one row
in this single neuron case. A constant 1 enters the neuron as an input and
is multiplied by a scalar bias b . The net input to the transfer function f is
n , which is the sum of the bias b and the product Wp . The neurons output
a is a scalar in this case. If we had more than one neuron, the network out-
put would be a vector.
The dimensions of the variables in these abbreviated notation figures will
always be included, so that you can tell immediately if we are talking about
a scalar, a vector or a matrix. You will not have to guess the kind of variable
or its dimensions.
Note that the number of inputs to a network is set by the external specifi-
cations of the problem. If, for instance, you want to design a neural network
that is to predict kite-flying conditions and the inputs are air temperature,
wind velocity and humidity, then there would be three inputs to the net-
work.
To experiment with a two-input neuron, use the Neural Network Design
Demonstration Two-Input Neuron (nnd2n2).
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 A single-layer network of S neurons is shown in Figure 2.7. Note that each
of the R inputs is connected to each of the neurons and that the weight ma-
trix now has S rows.
n1 a1
w1,1
p1 f
b1
p2 1
n2 a2
p3
f
b2
1
pR nS aS
wS, R f
bS
1
a = f(Wp + b)
2-9
2 Neuron Model and Network Architectures
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)
As noted previously, the row indices of the elements of matrix W indicate
the destination neuron associated with that weight, while the column indi-
ces indicate the source of the input for that weight. Thus, the indices in
w 3 2 say that this weight represents the connection to the third neuron
from the second source.
Fortunately, the S-neuron, R-input, one-layer network also can be drawn in
abbreviated notation, as shown in Figure 2.8.
p a
Rx1 W Sx1
n
SxR
Sx1 f
1 b
Sx1
R S
a = f(Wp + b)
Here again, the symbols below the variables tell you that for this layer, p
is a vector of length R , W is an S R matrix, and a and b are vectors of
length S . As defined previously, the layer includes the weight matrix, the
summation and multiplication operations, the bias vector b , the transfer
function boxes and the output vector.
2-10
Network Architectures
Output Layer A layer whose output is the network output is called an output layer. The
Hidden Layers other layers are called hidden layers. The network shown above has an out-
put layer (layer 3) and two hidden layers (layers 1 and 2).
The same three-layer network discussed previously also can be drawn us-
ing our abbreviated notation, as shown in Figure 2.10.
2-11
2 Neuron Model and Network Architectures
p a1 a2 a3
Rx1
W1 S1 x 1
W2 S2 x 1
W3 S3 x 1
n1 n2 n3
S1 x R
S1 x 1
f1 S2 x S1
S2 x 1
f2 S3 x S2
S3 x 1
f3
1 b1 1 b2 1 b3
S1 x 1 S2 x 1 S3 x 1
R S1 S2 S3
2-12
Network Architectures
than those without, and that is true. Note, for instance, that a neuron with-
out 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 param-
eters. With just two variables, we can plot system convergence in a two-di-
mensional plane. Three or more variables are difficult to display.
Recurrent Networks
Before we discuss recurrent networks, we need to introduce some simple
Delay building blocks. The first is the delay block, which is illustrated in Figure
2.11.
Delay
u(t) a(t)
D
a(0)
a(t) = u(t - 1)
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.
Another related building block, which we will use for the continuous-time
Integrator recurrent networks in Chapters 1821, is the integrator, which is shown in
Figure 2.12.
2-13
2 Neuron Model and Network Architectures
Integrator
u(t) a(t)
a(0)
t
a(t) = u() d + a(0)
0
The initial condition a 0 is indicated by the arrow coming into the bottom
of the integrator block.
Recurrent Network We are now ready to introduce recurrent networks. A recurrent network is
a network with feedback; some of its outputs are connected to its inputs.
This is quite different from the networks that we have studied thus far,
which were strictly feedforward with no backward connections. One type of
discrete-time recurrent network is shown in Figure 2.13.
Initial
Condition Recurrent Layer
p
Sx1 W n(t + 1) a(t + 1) a(t)
SxS
Sx1 Sx1 D Sx1
1 b
Sx1
S S
2-14
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 , . . . 2
Recurrent networks are potentially more powerful than feedforward net-
works and can exhibit temporal behavior. These types of networks are dis-
cussed in Chapters 3, 14 and 1821.
2-15
2 Neuron Model and Network Architectures
Summary of Results
Single-Input Neuron
Inputs General Neuron
w n a
p f
b
1
a = f (wp + b)
Multiple-Input Neuron
Inputs Multiple-Input Neuron
p1 w1, 1
p2
p3 n a
f
w1, R b
pR
1
a = f (Wp + b)
p a
Rx1 W 1x1
n
1xR
1x1 f
1 b
1x1
R 1
a = f (Wp + b)
2-16
Summary of Results
Transfer Functions
MATLAB
Name Input/Output Relation Icon Function 2
a = 0 n0
Hard Limit hardlim
a = 1 n0
a = 1 n0
Symmetrical Hard Limit hardlims
a = +1 n0
Linear a = n purelin
a = 0 n0
Saturating Linear a = n 0n1 satlin
a = 1 n1
a = 1 n 1
Symmetric Saturating
a = n 1 n 1 satlins
Linear
a = 1 n1
1
Log-Sigmoid a = ---------------
n
- logsig
1+e
n n
Hyperbolic Tangent e e
a = -----------------
- tansig
Sigmoid n
e +e
n
a = 0 n0
Positive Linear poslin
a = n 0n
Competitive
a = 1
a = 0
neuron with max n
all other neurons
C compet
2-17
2 Neuron Model and Network Architectures
Layer of Neurons
Input Layer of S Neurons
p a
Rx1 W Sx1
n
SxR
Sx1 f
1 b
Sx1
R S
a = f(Wp + b)
p a1 a2 a3
Rx1
W1 S1 x 1
W2 S2 x 1
W3 S3 x 1
n1 n2 n3
S1 x R
S1 x 1
f1 S2 x S1
S2 x 1
f2 S3 x S2
S3 x 1
f3
1 b1 1 b2 1 b3
S1 x 1 S2 x 1 S3 x 1
R S1 S2 S3
Delay
Delay
u(t) a(t)
D
a(0)
a(t) = u(t - 1)
2-18
Summary of Results
Integrator
Integrator
u(t) a(t)
2
a(0)
t
a(t) = u() d + a(0)
0
Recurrent Network
Initial
Condition Recurrent Layer
p
Sx1 W n(t + 1) a(t + 1) a(t)
SxS
Sx1 Sx1 D Sx1
1 b
Sx1
S S
2-19
2 Neuron Model and Network Architectures
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:
1
a = logsig 1.6 = ------------------
1.6
- = 0.8320
1+e
2+2
ans = Verify this result using MATLAB and the function logsig, which is in the
4 MININNET directory (see Appendix B).
2-20
Solved Problems
n = Wp + b = 3 2 5 + 1.2 = 1.8 .
2
6
P2.4 A single-layer neural network is to have six inputs and two out-
puts. The outputs are to be limited to and continuous over the
range 0 to 1. What can you tell about the network architecture?
Specifically:
i. How many neurons are required?
ii. What are the dimensions of the weight matrix?
iii. What kind of transfer functions could be used?
iv. Is a bias required?
The problem specifications allow you to say the following about the net-
work.
i. Two neurons, one for each output, are required.
ii. The weight matrix has two rows corresponding to the two neurons and
six columns corresponding to the six inputs. (The product Wp is a two-el-
ement vector.)
iii. Of the transfer functions we have discussed, the logsig transfer func-
tion would be most appropriate.
iv. Not enough information is given to determine if a bias is required.
2-21
2 Neuron Model and Network Architectures
Epilogue
This chapter has introduced a simple artificial neuron and has illustrated
how different neural networks can be created by connecting groups of neu-
rons 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 mem-
ory 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 oppor-
tunity 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 = iii. Summarize your network by naming the transfer function and stat-
4 ing 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 vec-
T
tor: W = 3 2 and p = 5 7 , we would like to have an output of 0.5. Do
you suppose that there is a combination of bias and transfer function that
might allow this?
i. Is there a transfer function from Table 2.1 that will do the job if the
bias is zero?
ii. Is there a bias that will do the job if the linear transfer function is
used? If yes, what is it?
iii. Is there a bias that will do the job if a log-sigmoid transfer function
is used? Again, if yes, what is it?
iv. Is there a bias that will do the job if a symmetrical hard limit trans-
fer function is used? Again, if yes, what is it?
E2.4 A two-layer neural network is to have four inputs and six outputs. The
range of the outputs is to be continuous between 0 and 1. What can you tell
about the network architecture? Specifically:
2-23
2 Neuron Model and Network Architectures
p w n a
S f
b
1
a = f (wp + b)
2-24
Exercises
a = satlin(W p + b )
1 1 1 2 2 1 2
a = purelin(W a + b )
1 1 1 1 2 2 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
3 An Illustrative Example
Objectives 3-1
Theory and Examples 3-2
Problem Statement 3-2
Perceptron 3-3
Two-Input Case 3-4
Pattern Recognition Example 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 ex-
pect 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 net-
works (represented here by the perceptron), competitive networks (repre-
sented here by the Hamming network) and recurrent associative memory
networks (represented here by the Hopfield network).
3-1
3 An Illustrative Example
Problem Statement
A produce dealer has a warehouse that stores a variety of fruits and vege-
tables. When fruit is brought to the warehouse, various types of fruit may
be mixed together. The dealer wants a machine that will sort the fruit ac-
cording to type. There is a conveyer belt on which the fruit is loaded. This
conveyer passes through a set of sensors, which measure three properties
of the fruit: shape, texture and weight. These sensors are somewhat primi-
tive. The shape sensor will output a 1 if the fruit is approximately round
and a 1 if it is more elliptical. The texture sensor will output a 1 if the sur-
face of the fruit is smooth and a 1 if it is rough. The weight sensor will
output a 1 if the fruit is more than one pound and a 1 if it is less than one
pound.
The three sensor outputs will then be input to a neural network. The pur-
pose of the network is to decide which kind of fruit is on the conveyor, so
that the fruit can be directed to the correct storage bin. To make the prob-
lem even simpler, lets assume that there are only two kinds of fruit on the
conveyor: apples and oranges.
Neural
Network
Sensors
Sorter
Apples Oranges
3-2
Perceptron
shape
p = texture . (3.1)
weight
1
p1 = 1 , (3.2)
1
1
p2 = 1 . (3.3)
1
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 prob-
lem, 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 hard-
lims.
p a
Rx1
W Sx1
SxR
n
Sx1
1 b
R Sx1 S
- Exp (Wp
a = hardlims - + b)
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 use-
ful to investigate the capabilities of a two-input/single-neuron perceptron
( R = 2 ), which can be easily analyzed graphically. The two-input percep-
tron is shown in Figure 3.2.
p1 w1,1
n a
p2
w1,2 b
1
a = hardlims (Wp + b)
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. Fig-
ure 3.3 illustrates this for the case where b = 1 . The blue line in the fig-
ure 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 bound-
ary 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
1
n>0 n<0
p1
-1 1
Wp + b = 0 . (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 . (3.7)
p3
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 di-
vides these two vectors symmetrically is the p 1 p 3 plane.
p3
p2
p1
p1 (orange) p2 (apple)
p2 = 0 , (3.8)
or
p1
0 1 0 p2 + 0 = 0 . (3.9)
p3
W = 0 1 0 , b = 0. (3.10)
The weight matrix is orthogonal to the decision boundary and points to-
ward 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:
1
a = hardlims 0 1 0 1 + 0 = 1 orange , (3.11)
1
Apple:
3
1
a = hardlims 0 1 0 1 + 0 = 1 apple . (3.12)
1
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 . (3.13)
1
1
a = hardlims 0 1 0 1 + 0 = 1 orange . (3.14)
1
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 classifica-
tion problem, use the Neural Network Design Demonstration Perceptron
Classification (nnd3pc).
This example has demonstrated some of the features of the perceptron net-
work, 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 neu-
rons 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 proto-
type 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.
p
Rx1
W1 n2(t + 1) a2(t + 1) a2(t)
n1 a1
SxR
Sx1 Sx1
W2 Sx1 Sx1 D Sx1
SxS
1 b 1
Sx1
R S S
- Exp 1(W
a1 = purelin - 1 p + b 1) a2(0) = a1 a2(t + 1) = poslin (W2a2(t))
3-8
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 con-
1
nection matrix W , are set to the prototype patterns. For our apple and or-
ange example this would mean
p 1T
W1 = = 1 1 1 . (3.15)
p 2T 1 1 1
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 in-
put vector. For our example the bias vector would be
b1 = 3 . (3.16)
3
With these choices for the weight matrix and bias vector, the output of the
feedforward layer is
T T
p1 p1 p + 3
p+ 3 =
1 1 1
a = W p+b = . (3.17)
T 3 T
p2 p2 p + 3
Note that the outputs of the feedforward layer are equal to the inner prod-
ucts 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 oppo-
site 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 in-
put pattern.
3-9
3 An Illustrative Example
Recurrent Layer
The recurrent layer of the Hamming network is what is known as a com-
petitive layer. The neurons in this layer are initialized with the outputs of
the feedforward layer, which indicate the correlation between the proto-
type 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 in-
put was presented to the network (for our example the two categories are
apples and oranges). The equations that describe the competition are:
1
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 , (3.20)
1
2 2
a t a 2 t
a 2 t + 1 = poslin 1 a 2 t = poslin 1 . (3.21)
1 2 2
a 2 t a 1 t
Each element is reduced by the same fraction of the other. The larger ele-
ment 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 pat-
tern that is closest in Hamming distance to the input).
To illustrate the operation of the Hamming network, consider again the ob-
long orange that we used to test the perceptron:
3-10
Hamming Network
1
p = 1 . (3.22)
1
1
a 1 = 1 1 1 1 + 3 = 1 + 3 = 4 , (3.23)
1 1 1 3 1 + 3 2
1
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 re-
current layer produces
poslin 1 0.5 4
0.5 1 2
a 2 1 = poslin W 2 a 2 0 = . (3.24)
poslin 3 = 3
0 0
poslin 1 0.5 3
0.5 1 0
a 2 2 = poslin W 2 a 2 1 = . (3.25)
poslin 3 = 3
1.5 0
Since the outputs of successive iterations produce the same result, the net-
work has converged. Prototype pattern number one, the orange, is chosen
as the correct match, since neuron number one has the only nonzero out-
1 T
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 in-
put pattern is 2.
To experiment with the Hamming network and the apple/orange classifica-
tion 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 prin-
ciples as the Hamming network; that is, where an inner product operation
(feedforward layer) is followed by a competitive dynamic layer. These com-
petitive 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 net-
work. This is a recurrent network that is similar in some respects to the re-
current 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 con-
cepts.)
The neurons in this network are initialized with the input vector, then the
network iterates until the output converges. When the network is operat-
ing 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
p
Sx1 W n(t + 1) a(t + 1) a(t)
SxS
Sx1 Sx1 D Sx1
1 b
Sx1
S S
a0 = p (3.26)
and
3-12
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 net-
work 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 rec-
ognition problem. They are given in Eq. (3.28).
0.2 0 0 0.9
W = 0 1.2 0 b = 0 (3.28)
0 0 0.2 0.9
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 or-
ange 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 sec-
ond 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 el-
ement 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.
a 2 t + 1 = satlins 1.2a 2 t
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 out-
puts 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 (3.30)
1 1 1 1
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 in-
dicated 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 classifica-
tion problem, use the Neural Network Design Demonstration Hopfield Clas-
sification (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 pre-
sented 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
3
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 dis-
tance between stored prototype patterns and the input pattern. Second,
they perform a competition to determine which neuron represents the pro-
totype 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 net-
works 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 ex-
tend 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 distin-
guish between apples and oranges, based on three sensor measurements
(shape, texture and weight). Suppose that we want to distinguish between
bananas and pineapples:
1
p1 = 1 (Banana)
1
1
p 2 = 1 (Pineapple)
1
p1 = 1 ,p = 2
2
0.5 1
p = 1
0
3-16
Exercises
v. Calculate the network output for the Hamming network with the in-
put 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.
1 1 , b = 0
W =
1 1 0 3
i. The following input (initial condition) is applied to the network.
Find the network response (show the network output at each itera-
tion until the network converges).
p = 0.9
1
ii. Draw a sketch indicating what region of the input space will con-
verge to the same final output that you found in part i. (In other
words, for what other p vectors will the network converge to the
same final output?) Explain how you obtained your answer.
iii. What other prototypes will this network converge to, and what re-
gions of the input space correspond to each prototype (sketch the re-
gions). Explain how you obtained your answer.
p a W = 1 1
Rx1
W Sx1 1 1
SxR
n
Sx1
b = 2
1 b 0
R Sx1 S
- Exp (Wp
a = hardlims - + b)
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.
1 1
,
0 2
and to output a -1 when either of the following vectors are input to the net-
work:
1 0
.
1 2
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. Ver-
ify 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.
. 1 1
1 1
3-18
Exercises
iv. For the vector given below, calculate the net input, n, and the net-
work output, a, for the network you have designed. Does the net-
work produce a good output? Explain.
0.5
0.5
1 1 1
.
1 1 1
i. Find the weight matrices and bias vectors for the Hamming net-
work.
ii. Draw the network diagram.
iii. Apply the following input vector and calculate the total network re-
sponse (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
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 single-
layer perceptron network. This discussion will lead us into future chapters.
4-1
4 Perceptron Learning Rule
Learning Rules
As we begin our presentation of the perceptron learning rule, we want to
Learning Rule discuss learning rules in general. By learning rule we mean a procedure for
modifying the weights and biases of a network. (This procedure may also
4-2
Perceptron Architecture
Perceptron Architecture
Before we present the perceptron learning rule, lets expand our investiga-
tion 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
4 Perceptron Learning Rule
p a
Rx1
W Sx1
SxR
n
Sx1
1 b
Sx1
R S
a = hardlim (Wp + b)
w 1 1 w 1 2 w 1 R
w 2 1 w 2 2 w 2 R
W = . (4.3)
w S 1 w S 2 w S R
w i 1
w i 2
iw = . (4.4)
w i R
T
1w
T
W = 2w . (4.5)
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.6)
4-4
Perceptron Architecture
Recall that the hardlim transfer function (shown at left) is defined as:
a = hardlim (n)
a = hardlim n = 1 if n 0 (4.7)
0 otherwise.
Therefore, if the inner product of the ith row of the weight matrix with the
n = Wp + b 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 percep-
tron with two inputs.
Single-Neuron Perceptron
Lets consider a two-input perceptron with one neuron, as shown in Figure
4.2.
p1 w1,1
n a
p2
w1,2 b
1
a = hardlim (Wp + b)
a = hardlim n = hardlim Wp + b
T
= hardlim 1w p + b = hardlim w 1 1 p 1 + w 1 2 p 2 + b
(4.8)
Decision Boundary 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.10)
4-5
4 Perceptron Learning Rule
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 if p 1 = 0
w 1 2 1
. (4.12)
To find the p 1 intercept, set p 2 = 0 :
b 1
p 1 = ---------- = ------ = 1 if p 2 = 0
w 1 1 1
. (4.13)
The resulting decision boundary is illustrated in Figure 4.3.
To find out which side of the boundary corresponds to an output of 1, we
T
just need to test one point. For the input p = 2 0 , the network output
will be
a = hardlim 1w p + b = hardlim 1 1 2 1 = 1 .
T
(4.14)
0
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 Fig-
ure 4.3.
p2
a=1
w
1w Tp + b = 0 1 1
p1
a=0 1
4-6
Perceptron Architecture
We can also find the decision boundary graphically. The first step is to note
1 w that the boundary is always orthogonal to 1w , as illustrated in the adjacent
figures. The boundary is defined by
T
1w p+b = 0. (4.15)
w
1 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 de-
tail 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 Lets apply some of these concepts to the design of a perceptron network to
+2
implement a simple logic function: the AND gate. The input/target pairs for
the AND gate are
0 t = 0 p = 0 t = 0 p = 1 t = 0 p = 1 t = 1 .
p1 = 1 2 2 3 3 4 4
0 1 0 1
The figure to the left illustrates the problem graphically. It displays the in-
put 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 possi-
bilities. One choice is
1w
1w = 2 , (4.16)
AND 2
4-7
4 Perceptron Learning Rule
p + b = 2 2 1.5 + b = 3 + b = 0
T
1w b = 3 . (4.17)
0
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
a = hardlim 1w p 2 + b = hardlim 2 2 0 3
T
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
T
iw p + bi = 0 . (4.19)
{p 1, t 1} { p 2, t 2} {p Q, tQ} , (4.20)
4-8
Perceptron Learning Rule
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 = 1 2 2 3 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
1
2 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.
3 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.
p1 w1,1
n a
p2
w1,2
a = hardlim(Wp)
4-9
4 Perceptron Learning Rule
The adjacent figure shows the weight vectors that correspond to the allow-
able decision boundaries. (Recall that the weight vector is orthogonal to the
1
decision boundary.) We would like a learning rule that will find a weight
2 vector that points in one of these directions. Remember that the length of
the weight vector does not matter; only its direction is important.
We will now begin presenting the input vectors to the network. We begin
with p 1 :
a = hardlim 1w p 1 = hardlim 1.0 0.8 1
T
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
2 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.
1w
3
One approach would be to set 1w equal to p 1 . This is simple and would en-
sure 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 dia-
gram 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 ap-
ply the rule 1w = p every time one of these vectors is misclassified, the net-
works 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:
new old
If t = 1 and a = 0, then 1w = 1w +p. (4.23)
4-10
Perceptron Learning Rule
Applying this rule to our test problem results in new values for 1w :
new
= 1w
old
+ p1 = 1.0 + 1 = 2.0 . (4.24)
1w
0.8 2 1.2
1
2 w This operation is illustrated in the adjacent figure.
1
We now move on to the next input vector and will continue making changes
to the weights and cycling through the inputs until they are all classified
correctly.
3
The next input vector is p 2 . When it is presented to the network we find:
a = hardlim 1w p 2 = hardlim 2.0 1.2 1
T
2
= hardlim 0.4 = 1 . (4.25)
The target t 2 associated with p 2 is 0 and the output a is 1. A class 0 vector
was misclassified as a 1.
Since we would now like to move the weight vector 1w away from the input,
we can simply change the addition in Eq. (4.23) to subtraction:
new old
If t = 0 and a = 1, then 1w = 1w p. (4.26)
p 2 = 2.0 1 = 3.0 ,
new old
1w = 1w (4.27)
1 1.2 2 0.8
2
1
= hardlim 0.8 = 1 . (4.28)
The current 1w results in a decision boundary that misclassifies p 3 . This
is a situation for which we already have a rule, so 1w will be updated again,
according to Eq. (4.26):
new
= 1w
old
p3 = 3.0 0 = 3.0 . (4.29)
1w
0.8 1 0.2
4-11
4 Perceptron Learning Rule
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
1
the neuron, it will output the correct class for that input vector.
2
This brings us to our third and final rule: if it works, dont fix it.
1w
new old
If t = a, then 1w = 1w . (4.30)
3
Here are the three rules, which cover all possible combinations of output
and target values:
new old
If t = 1 and a = 0, then 1w = 1w + p.
If t = 0 and a = 1, then 1w
new
= 1w
old
p. (4.31)
new old
If t = a, then 1w = 1w .
e = t a. (4.32)
new old
If e = 1, then 1w = 1w +p.
If e = 1, then 1w
new
= 1w
old
p. (4.33)
new old
If e = 0, then 1w = 1w .
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:
new old old
1w = 1w + ep = 1w + 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:
new old
b = b +e. (4.35)
4-12
Perceptron Learning Rule
Perceptron Rule The perceptron rule can be written conveniently in matrix notation:
new old T
W = W + ep , (4.38)
and
new old
b = b +e. (4.39)
2 To test the perceptron learning rule, consider again the apple/orange rec-
+2
ognition problem of Chapter 3. The input/output prototype vectors will be
1 1
p1 = 1 t1 = 0 p2 = 1 t2 = 1 . (4.40)
1 1
(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:
The first step is to apply the first input vector, p 1 , to the network:
1
a = hardlim Wp 1 + b = hardlim 0.5 1 0.5 1 + 0.5
1
= hardlim 2.5 = 1 (4.42)
4-13
4 Perceptron Learning Rule
e = t1 a = 0 1 = 1 . (4.43)
1
a = hardlim (Wp 2 + b) = hardlim ( 0.5 0 0.5 1 + 0.5 )
1
e = t2 a = 1 0 = 1 (4.47)
new old T
W = W + ep = 0.5 0 0.5 + 1 1 1 1 = 0.5 1 0.5 (4.48)
new old
b = b + e = 0.5 + 1 = 0.5 (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
e = t1 a = 0 1 = 1 (4.51)
new old T
W = W + ep = 0.5 1 0.5 + 1 1 1 1 (4.52)
= 0.5 2 0.5
4-14
Proof of Convergence
new old
b = b + 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 vec-
tors.
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 ac-
complish the desired classification (assuming that such weights exist). In
this section we will present a proof of convergence for the perceptron learn-
ing rule for the single-neuron perceptron shown in Figure 4.5.
p1 w1,1
p2
p3 n a
w1,R b
pR
1
a = hardlim (1wTp + b)
The network is provided with the following examples of proper network be-
havior:
{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 nota-
tion. We will combine the weight matrix and the bias into a single vector:
4-15
4 Perceptron Learning Rule
x = 1w . (4.56)
b
We will also augment the input vectors with a 1, corresponding to the bias
input:
pq
zq = . (4.57)
1
The perceptron learning rule for a single-neuron perceptron (Eq. (4.34) and
Eq. (4.35)) can now be written
new old
x = x + ez . (4.59)
x k = x k 1 + z' k 1 , (4.60)
z 1 z 2 z Q z 1 z 2 z Q . (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 ,
T
(4.62)
and
x z q 0 if t q = 0 .
T
(4.63)
Proof
We are now ready to begin the proof of the perceptron convergence theo-
rem. 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):
If we take the inner product of the solution weight vector with the weight
vector at iteration k we obtain
x z' i .
T
(4.66)
Therefore
x x k k .
T
(4.67)
where
2 T
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
x x k k
T 2
2
xk -------------------------- ------------2- . (4.70)
x x
2
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 :
2 T
xk = x k x k
T
= x k 1 + z' k 1 x k 1 + z' k 1
(4.71)
T T
= 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.72)
4-17
4 Perceptron Learning Rule
since the weights would not be updated unless the previous input vector
had been misclassified. Now Eq. (4.71) can be simplified to
2 2 2
xk xk 1 + z' k 1 . (4.73)
2 2
We can repeat this process for x k 1 , x k 2 , etc., to obtain
+ + z' k 1 .
2 2 2
xk z' 0 (4.74)
2
If = max z' i , this upper bound can be simplified to
2
xk 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
x
2 2
2 k
k x k ------------2- or k ----------------- . (4.76)
x
2
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 in-
versely 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 bound-
ary) 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 per-
ceptron 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 im-
portant 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
T
1w p+b = 0. (4.77)
0 t = 0 p = 0 t = 1 p = 1 t = 1 p = 1 t = 0 .
p1 = 1 2 2 3 3 4 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
4 Perceptron Learning Rule
Summary of Results
Perceptron Architecture
Input Hard Limit Layer
p a
Rx1
W Sx1
SxR
n
Sx1
1 b
Sx1
R S
a = hardlim (Wp + b)
T
1w
T
W = 2w
T
Sw
a = hardlim Wp + b
T
a i = hardlim n i = hardlim iw p + b i
Decision Boundary
T
iw p + bi = 0 .
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.
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
4-21
4 Perceptron Learning Rule
Now we find the bias values for each perceptron by picking a point on the
decision boundary and satisfying Eq. (4.15).
T
1w p+b = 0
T
b = 1w p
We can now check our solution against the original points. Here we test the
T
first network on the input vector p = 2 2 .
T
a = hardlim 1w p + b
= hardlim 2 1 2 + 0
2
= hardlim 6
= 1
2+2
ans = We can use MATLAB to automate the testing process and to try new points.
4 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
0 t = 1 p = 1 t = 1 p = 0 t = 0 p = 2 t = 0
p1 = 1 2 2 3 3 4 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.
2w 1 2 + b 0 i
w 1 1 + b 0 ii 4
2w 1 2 + b 0 iii
2w 1 1 + b 0 iv
w1,1 w1,2
ii
iv
b b
iii i
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 b = 3.
4-23
4 Perceptron Learning Rule
2 p = 2 ,
class 1: p 1 = 1 p 2 = 1 , class 2: p3 = 4
1 2 1 0
class 3: p 5 = 1 p 6 = 2 , class 4: p 7 = 1 p 8 = 2 .
2 1 1 2
p a
2x1
W 2x1
2x2
n
2x1
1 b
2x1
2 2
a = hardlim (Wp + b)
4-24
Solved Problems
1
3
1
3
0 t = 0 ,
class 1: t 1 = 0 t 2 = 0 , class 2: t3 = 4
0 0 1 1
class 3: t 5 = 1 t 6 = 1 , class 4: t 7 = 1 t 8 = 1 .
0 0 1 1
4-25
4 Perceptron Learning Rule
1w = 3 and 2w = 1 .
1 2
Note that the lengths of the weight vectors is not important, only their di-
rections. 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):
b 1 = 1w p = 3 1 0 = 1 ,
T
b 2 = 2w p = 1 2 0 = 0 .
T
1
3
T
1w
W = = 3 1 and b = 1 ,
T 1 2 0
2w
4-26
Solved Problems
2 t = 0 p = 1 t = 1 p = 2 t = 0 p = 1 t = 1
p1 = 1 2 2 3 3 4 4
2 2 2 1
W0 = 0 0 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
4
= 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 percep-
tron rule will not result in any changes.
W2 = W1
b2 = b1
We now apply the third input vector.
4-27
4 Perceptron Learning Rule
a = hardlim W 2 p 3 + b 2
= hardlim 2 2 2 1 = hardlim 1 = 0
2
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 per-
ceptron 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
W5 = W4
b5 = b4
4-28
Solved Problems
a = hardlim W 5 p 2 + b 5
= hardlim 3 1 1 + 0 = hardlim 1 = 0
2
e = t2 a = 1 0 = 1
T
W 6 = W 5 + ep 2 = 3 1 + 1 1 2 = 2 3 4
b 6 = b 5 + e = 0 + 1 = 1.
a = hardlim W 6 p 3 + b 6 = hardlim 2 3 2 + 1 = 0 = t 3
2
a = hardlim W 6 p 4 + b 6 = hardlim 2 3 1 + 1 = 1 = t 4
1
a = hardlim W 6 p 1 + b 6 = hardlim 2 3 2 + 1 = 0 = t 1
2
a = hardlim W 6 p 2 + b 6 = hardlim 2 3 1 + 1 = 1 = t 2
2
W = 2 3 b = 1.
Now we can graph the training data and the decision boundary of the solu-
tion. 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 .
b 1 1
p 2 = ---------- = ------ = --- if p 1 = 0
w 1 2 3 3
.
4-29
4 Perceptron Learning Rule
b 1 1
p 1 = ---------- = ------ = --- if p 2 = 0
w 1 1 2 2
.
The resulting decision boundary is illustrated in Figure P4.6.
1 t = 0 p = 1 t = 0 p = 2 t = 0
p1 = 1 2 2 3 3
1 0 2 0 1 1
2 t = 0 p = 1 t = 1 p = 2 t = 1
p4 = 4 5 5 6 6
0 1 2 0 1 0
1 t = 1 p = 2 t = 1 .
p7 = 7 8 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
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
W 1 = W 0 + ep 1 = 1 0 + 1 1 1 = 0 1 ,
T
0 1 1 1 0
b 1 = b 0 + e = 1 + 1 = 0 .
1 1 0 4
The second iteration is
a = hardlim (W 1 p 2 + b 1 ) = hardlim ( 0 1 1 + 0 ) = 0 ,
1 0 2 0 0
e = t2 a = 0 0 = 0 ,
0 0 0
T
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
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
4 Perceptron Learning Rule
T
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
W8 = W7 = W6 = W5 = W4 = W3
b8 = b7 = b6 = b 5 = b 4 = b3
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
W 9 = W 8 + ep 1 = 2 0 + 0 1 1 = 2 0 ,
T
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
1
3
4-33
4 Perceptron Learning Rule
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 be-
havior. 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 prob-
lems. 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 adap-
tive 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 algo-
rithm is used to train a neural network to balance an in-
verted pendulum.
[Brog91] W. L. Brogan, Modern Control Theory, 3rd Ed., Englewood
Cliffs, NJ: Prentice-Hall, 1991.
A well-written book on the subject of linear systems. The 4
first half of the book is devoted to linear algebra. It also has
good sections on the solution of linear differential equa-
tions and the stability of linear and nonlinear systems. It
has many worked problems.
[McPi43] W. McCulloch and W. Pitts, A logical calculus of the ideas
immanent in nervous activity, Bulletin of Mathematical
Biophysics, Vol. 5, pp. 115133, 1943.
This article introduces the first mathematical model of a
neuron, in which a weighted sum of input signals is com-
pared to a threshold to determine whether or not the neu-
ron fires.
[MiPa69] M. Minsky and S. Papert, Perceptrons, Cambridge, MA:
MIT Press, 1969.
A landmark book that contains the first rigorous study de-
voted to determining what a perceptron network is capable
of learning. A formal treatment of the perceptron was need-
ed both to explain the perceptrons limitations and to indi-
cate directions for overcoming them. Unfortunately, the
book pessimistically predicted that the limitations of per-
ceptrons indicated that the field of neural networks was a
dead end. Although this was not true, it temporarily cooled
research and funding for research for several years.
[Rose58] F. Rosenblatt, The perceptron: A probabilistic model for
information storage and organization in the brain, Psycho-
logical Review, Vol. 65, pp. 386408, 1958.
This paper presents the first practical artificial neural net-
work the perceptron.
4-35
4 Perceptron Learning Rule
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 = 1 2 2 3 3 4 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 = 1 2 2 3 3 4 4
1 1 0 0
p5 = 2 p6 = 1 p7 = 0 p8 = 1
0 1 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
4 Perceptron Learning Rule
E4.4 Solve the classification problem in Exercise E4.2 by applying the percep-
tron 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 un-
solvable for a two-input/single-neuron perceptron.
1 t = 1 p = 1 t = 0 p = 1 t = 1 p = 1 t = 0
p1 = 1 2 2 3 3 4 4
1 1 1 1
Category I: 1 1 , Category II: 0 1
1 0 2 2
Category III: 2 2 , Category IV: 1 0
0 1 1 1
1
3
Perform one iteration of the perceptron learning rule with this vec-
tor. (Start with the weights you determined in part i.) Draw the new
decision boundaries.
0 1 0
.
0 0 1
4-38
Exercises
Category II consists of
1 0 2
.
1 2 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 = 1 2 2 3 3
1 0 1
W 0 = 1 0 , b 0 = 0.5 .
i. Plot the initial decision boundary, weight vector and input patterns.
Which patterns are correctly classified using the initial weight and
bias?
ii. Train the network with the perceptron rule. Present each input vec-
tor once, in the order shown.
iii. Plot the final decision boundary, and demonstrate graphically
which patterns are correctly classified.
iv. Will the perceptron rule (given enough iterations) always learn to
correctly classify the patterns in this training set, no matter what
initial weights we use? Explain.
4-39
4 Perceptron Learning Rule
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 = 1 2 2 3 3
0 2 2
W0 = 0 1 , b0 = 1 .
i. Sketch the initial decision boundary, and show the weight vector
and the three training input vectors, p 1 p 2 p 3 . Indicate the class of
each input vector, and show which ones are correctly classified by
the initial decision boundary.
ii. Present the input p 1 to the network, and perform one iteration of
the perceptron learning rule.
iii. Sketch the new decision boundary and weight vector, and again in-
dicate which of the three input vectors are correctly classified.
iv. Present the input p 2 to the network, and perform one more itera-
tion of the perceptron learning rule.
v. Sketch the new decision boundary and weight vector, and again in-
dicate which of the three input vectors are correctly classified.
vi. If you continued to use the perceptron learning rule, and presented
all of the patterns many times, would the network eventually learn
to correctly classify the patterns? Explain your answer. (This part
does not require any calculations.)
E4.10 The symmetric hard limit function is sometimes used in perceptron net-
works, instead of the hard limit function. Target values are then taken
a = hardlims (n) from the set [-1, 1] instead of [0, 1].
i. Write a simple expression that maps numbers in the ordered set [0,
1] into the ordered set [-1, 1]. Write the expression that performs
the inverse mapping.
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 func-
tion. 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 per-
ceptron, create a method for initializing a symmetric hard limit per-
ceptron so that the two neurons will always respond identically
when trained on identical data.
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 An-
imal Factory. The target values indicate whether the respective input vec-
2+2 tor was taken from a rabbit (0) or a bear (1). The first element of the input
ans = vector is the weight of the toy, and the second element is the ear length.
4
1 t = 0 p = 1 t = 0 p = 2 t = 0 p = 2 t = 0
p1 = 1 2 2 3 3 4 4
4 5 4 5
3 t = 1 p = 3 t = 1 p = 4 t = 1 p = 4 t = 1
p5 = 5 6 6 7 7 8 8
1 2 1 2
p3 = 2 .
2
i. Is the problem still linearly separable? Demonstrate your answer
graphically.
2+2
ans = ii. Use MATLAB to initialize and train a network to solve this prob-
4 lem. Explain your results.
iii. If p 3 is changed to
p3 = 2
1.5
4-41
4 Perceptron Learning Rule
4-42
Objectives
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 vec-
tors. 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 an-
alyzing 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 un-
derstanding of why neural networks work.
5-1
5 Signal and Weight Vector Spaces
n
These are vectors in , the standard n-dimensional Euclidean space. In
this chapter we will also be talking about more general vector spaces than
n
. These more general vectors will be represented with a script typeface,
as in x . We will show in this chapter how these general vectors can often
be represented by columns of numbers.
5-2
Linear Vector Spaces
2. x+y = y+x.
3. x + y + z = x + y + z .
To illustrate these conditions, lets investigate a few sample sets and deter-
mine whether or not they are vector spaces. First consider the standard
2
x+y two-dimensional Euclidean space, , shown in the upper left figure. This
is clearly a vector space, and all ten conditions are satisfied for the stan-
dard definitions of vector addition and scalar multiplication.
y x 2 2
What about subsets of ? What subsets of are also vector spaces (sub-
spaces)? Consider the boxed area ( X ) in the center left figure. Does it sat-
X isfy 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.
2
Are there any subsets of that are vector spaces? Consider the line ( X )
x2
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
x1 be satisfied.
X
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
5 Signal and Weight Vector Spaces
x = 2 + t + 4t 2
y = 1 + 5t . (5.2)
If you are used to thinking of vectors only as columns of numbers, these
may seem to be strange vectors indeed. However, recall that to be a vector
space, a set need only satisfy the ten conditions we presented. Are these
2
conditions satisfied for the set P ? If we add two polynomials of degree less
than or equal to 2, the result will also be a polynomial of degree less than
or equal to 2. Therefore condition 1 is satisfied. We can also multiply a poly-
nomial by a scalar without changing the order of the polynomial. Therefore
condition 6 is satisfied. It is not difficult to show that all ten conditions are
2
satisfied, showing that P is a vector space.
f(t) Consider the set C 0 1 of all continuous functions defined on the interval
[0, 1]. Two members of this set would be
1
x = sin t
t
y = e 2t . (5.3)
Another member of the set is shown in the figure to the left.
The sum of two continuous functions is also a continuous function, and a
scalar times a continuous function is a continuous function. The set C 0 1
is also a vector space. This set is different than the other vector spaces we
have discussed; it is infinite dimensional. We will define what we mean by
dimension later in this chapter.
Linear Independence
Now that we have defined what we mean by a vector space, we will inves-
tigate some of the properties of vectors. The first properties are linear de-
pendence 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 combi-
nation of the other vectors.
2 As an example of independence, consider the pattern recognition problem
+2
of Chapter 3. The two prototype patterns (orange and apple) were given by:
1 1
p1 = 1 , p2 = 1 . (5.5)
1 1
Let a 1 p 1 + a 2 p 2 = 0 , then
a1 + a2 0
a1 + a2 = 0 , (5.6)
a1 + a2 0
x 1 = 1 + t + t2 , x2 = 2 + 2t + t2 , x 3 = 1 + t . (5.7)
a1 x1 + a2 x2 + a3 x3 = 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.
The dimension of a vector space is determined by the minimum number of
vectors it takes to span the space. This leads to the definition of a basis set.
Basis Set A basis set for X is a set of linearly independent vectors that spans X. Any
basis set contains the minimum number of vectors required to span the
5-5
5 Signal and Weight Vector Spaces
u1 = 1 , u2 = t , u3 = t2 . (5.9)
Clearly any polynomial of degree two or less can be created by taking a lin-
ear combination of these three vectors. Note, however, that any three inde-
pendent 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) , pro-
vided that the following properties are satisfied:
1. (x,y) = (y,x) .
2. (x,a y 1 + b y 2) = a (x,y 1) + b (x,y 2) .
3. (x,x) 0 , where equality holds if and only if x is the zero vector.
The standard inner product for vectors in Rn is
x y = x1 y1 + x2 y2 + + xn yn ,
T
(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 fol-
lowing scalar function is man inner product (see Problem P5.6).
1
(x,y) = x t y t dt (5.12)
0
5-6
Norm
Norm
The next operation we need to define is the norm, which is based on the con-
cept of vector length.
Norm A scalar function x is called a norm if it satisfies the following properties:
1. x 0.
2. x = 0 if and only if x = 0 .
3. ax = a x for scalar a.
4. x+y x + y .
There are many functions that would satisfy these conditions. One common
norm is based on the inner product:
12
x = (x,x) . (5.13)
n
For Euclidean spaces, , this yields the norm with which we are most fa-
miliar:
5
12
x1 + x2 + + xn .
T 2 2 2
x = x x = (5.14)
(x,y)
cos = --------------- . (5.15)
x y
Orthogonality
Now that we have defined the inner product operation, we can introduce
the important concept of orthogonality.
Orthogonality Two vectors x y X are said to be orthogonal if (x,y) = 0 .
Orthogonality is an important concept in neural networks. We will see in
Chapter 7 that when the prototype vectors of a pattern recognition problem
are orthogonal and normalized, a linear associator neural network can be
trained, using the Hebb rule, to achieve perfect recognition.
In addition to orthogonal vectors, we can also have orthogonal spaces. A
vector x X is orthogonal to a subspace X 1 if x is orthogonal to every vec-
5-7
5 Signal and Weight Vector Spaces
Gram-Schmidt Orthogonalization
There is a relationship between orthogonality and independence. It is pos-
sible 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 vec-
tors we want to obtain n orthogonal vectors v 1 v 2 v n . The first orthog-
onal 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 por-
tion of y 2 that is in the direction of v 1 . This leads to the equation
v2 = y2 a v1 , (5.17)
or
(v 1,y 2)
-.
a = --------------- (5.19)
(v 1,v 1)
5-8
Vector Expansions
y1 = 2 , y2 = 1 . (5.21)
1 2
v1 = y1 = 2 . (5.22)
1
1
T 2 1
v1 y2 2
- v 1 = 1 --------------------- 2 = 1 1.6 = 0.6 .
v 2 = y 2 ----------
T
(5.23)
v1 v1 2 2 1 2 0.8 1.2
2 1
1
y2 v2
y2
y1, v1
av1
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 col-
umns of numbers. In this section we will show that general vectors in finite
5-9
5 Signal and Weight Vector Spaces
x = xi vi = x1 v1 + x2 v2 + + xn vn . (5.24)
i=1
(v j,x)
-.
x j = ------------- (5.27)
(v j,v j)
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.
(r i,v j) = 0 ij
(5.28)
= 1 i = j,
5-10
Vector Expansions
Reciprocal Basis Vectors 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 vec-
tor expansion), and the standard inner product is used
T
(r i,v j) = r i v j , (5.29)
where
B = v1 v2 vn , (5.31)
R = r1 r2 rn . (5.32)
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
By definition
(r 1,v 1) = 1 .
(5.36)
Therefore the first coefficient of the expansion is
x 1 = (r 1,x) , (5.37)
and in general
x j = (r j,x) . (5.38)
5-11
5 Signal and Weight Vector Spaces
v1 = 2 , v2 = 1 .
s s
(5.39)
1 2
0
s
x = 3 (5.40)
---
v2 2
in terms of the two basis vectors. (We are using the superscript s to indi-
cate that these columns of numbers represent expansions of the vectors in
s2 v1 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 vec-
s1 tors in terms of two different basis sets.)
The first step in the vector expansion is to find the reciprocal basis vectors.
2 1 2 1
1 --- --- --- ---
R = 2 1 3 3 3 3 .
T
= r1 = r2 = (5.41)
1 2 1 2 1 2
--- --- --- ---
3 3 3 3
0
x1 = r1 x = 2 1 1
v T s
--- --- 3 = ---
3 3 --- 2
2
0
x2 = r2 x = 1 2
v T s
--- --- 3 = 1 (5.42)
3 3 ---
2
2 1
--- --- 0 1
v T s 3 1 s 3 ---
x = R x = B x = 3 = 2 . (5.43)
1 2 ---
--- --- 2 1
3 3
So that
5-12
Vector Expansions
x = 1--- v 1 + 1 v 2 , (5.44)
2
v2
x
v1
v2
- v1/2
To experiment with the vector expansion process, use the Neural Network
Design Demonstration Reciprocal Basis (nnd5rb).
5-13
5 Signal and Weight Vector Spaces
Summary of Results
9. 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 = 0,
then the x i are linearly dependent.
5-14
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), pro-
vided that the following properties are satisfied.
1. (x,y) = (y,x) .
2. (x,a y 1 + b y 2) = a (x,y 1) + b (x,y 2) .
3. (x,x) 0 , where equality holds if and only if x is the zero vector.
Norm
A scalar function
1. x 0.
x is called a norm if it satisfies the following properties:
5
2. x = 0 if and only if x = 0 .
3. ax = a x for scalar a.
4. x+y x + y .
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 vec-
tors we will obtain n orthogonal vectors v 1 v 2 v n .
v1 = y1
5-15
5 Signal and Weight Vector Spaces
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
(v j,x)
x j = -------------
-
(v j,v j)
= 1 i = j
x j = (r j,x) .
B = v1 v2 vn ,
R = r1 r2 rn ,
T 1
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 bound-
ary for this network is given by Wp + b = 0 . Show that the decision
boundary is a vector space if b = 0 .
p a
Rx1 W 1x1
1xR n
1x1
1 b
R 1x1 1
- Exp (Wp
a = hardlims - + b)
5-17
5 Signal and Weight Vector Spaces
P5.3 Which of the following sets of vectors are independent? Find the
dimension of the vector space spanned by each set.
1 1 1
i. 1 0 2
1 1 1
ii. sin t cos t 2 cos t + ---
4
1 1 1
iii. 1 0 2
1 1 1
1 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 depen-
dent.
n
Another approach, when we have n vectors in , is to write the above
equation in matrix form:
1 1 1 a1 0
1 0 2 a2 = 0
1 1 1 a3 0
If the matrix in this equation has an inverse, then the solution will require
that all coefficients be zero; therefore the vectors are independent. If the
matrix is singular (has no inverse), then a nonzero set of coefficients will
work, and the vectors are dependent. The test, then, is to create a matrix
using the vectors as columns. If the determinant of the matrix is zero (sin-
gular matrix), then the vectors are dependent; otherwise they are indepen-
dent. Using the Laplace expansion [Brog91] on the first column, the 5
determinant of this matrix is
1 1 1
1 0 2 = 1 0 2 + 1 1 1 + 1 1 1 = 2+0+2 = 0
1 1 1 1 0 2
1 1 1
cos t + --- = ------- sin t + ------- cos t .
1 1
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 iden-
tically 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 depen-
dent if and only if the Gramian is zero.
5-19
5 Signal and Weight Vector Spaces
where
1 1 1
x1 = 1 x2 = 0 x3 = 2 .
1 1 1
1 1 1
Therefore
4 3 5
G = 3 3 3 = 4 3 3 + 3 3 5 + 5 3 5 = 48 18 30 = 0 .
3 7 37 3 3
5 3 7
1 1 1 0
2 1 1 0 1 2 = 0 .
1 1 1 0
1 1 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 = 40.
3 3
P5.4 Recall from Chapters 3 and 4 that one-layer perceptrons can only
be used to recognize patterns that are linearly separable (can be
separated by a linear boundary see Figure 3.3). If two patterns
are linearly separable, are they always linearly independent?
No, these are two unrelated concepts. Take the following simple example.
Consider the two input perceptron shown in Figure P5.2.
5-20
Solved Problems
p1 w11
n a
SxR
w12 b
p2
1
5
- Exp -(Wp + b)
a = hardlims
P5.5 Using the following basis vectors, find an orthogonal set using
Gram-Schmidt orthogonalization.
1 1 0
y1 = 1 y2 = 0 y3 = 1
1 0 0
Step 1.
1
v1 = y1 = 1
1
5-21
5 Signal and Weight Vector Spaces
Step 2.
1
1 1 1 0
T
v1 y2 1 0 1 1 13 23
v 2 = y 2 ----------
T
- v 1 = 0 -------------------------
- 1 = 0 1 3 = 13
v1 v1 1
0 1 0 13 1 3
1 1 1 1
1
Step 3.
T T
v1 y3 v2 y3
v 3 = y 3 ----------
T
- v 1 ----------
T
- v2
v1 v1 v2 v2
0 0
1 1 1 1 2 3 1 3 1 3 1
0 0 1 0 23
v 3 = 1 -------------------------- 1 ---------------------------------------------------------------- 1 3
0 1 1 2 3 1 3
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 inter-
1
val [-1, 1]. Show that (x,y) = x(t) y t dt is a valid inner product.
1
5-22
Solved Problems
1 1 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 prob-
lem (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. 5
v1 = y1 = 1 + t
Step 2.
(v 1,y 2)
v 2 = y 2 ---------------
- v1
(v 1,v 1)
where
1 1
3
1
3 1
1 + t
= --- 0 = --- .
8 8
1 + t dt = -----------------
2
(v 1,v 1) = -
3 3 3
1
1
Therefore
3
v2 = 1 t 4--------- 1 3
- 1 + t = --- --- t .
83 2 2
5-23
5 Signal and Weight Vector Spaces
T
P5.8 Expand x = 6 9 9 in terms of the following basis set.
1 1 1
v1 = 1 v2 = 2 v3 = 3
1 3 2
5 1 1
--- --- ---
3 3 3
1 1 1
= 1 1 2
1
B = 1 2 3 B --- --- ---
3 3 3
1 3 2
1 2 1
--- --- ---
3 3 3
53 1 3 1 3
r1 = 1 3 r2 = 1 3 r3 = 23 .
1 3 23 1 3
6
x1 = r1 x = 5 1 1
v T
--- ------ ------ 9 = 4
3 3 3
9
6
x 2 = r 2 x = -----1- -----1- 2
v T
--- 9 = 1
3 3 3
9
6
x 3 = r 3 x = -----1- 2 1
v T
--- ------ 9 = 1
3 3 3
9
,
and the expansion is written
5-24
Solved Problems
1 1 1
v v v
x = x1 v1 + x2 v2 + x3 v3 = 4 1 + 1 2 + 1 3 .
1 3 2
5 1 1
--- --- ---
3 3 3
6 4
x = B x = 1 1 2
v 1
--- --- --- 9 = 1 .
3 3 3
9 1
1 2 1
--- --- ---
3 3 3
v
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
5-25
5 Signal and Weight Vector Spaces
Epilogue
This chapter has presented a few of the basic concepts of vector spaces, ma-
terial 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 revis-
ited in almost every chapter that follows.
The next chapter will continue our investigation of the topics of linear al-
gebra most relevant to neural networks. There we will concentrate on lin-
ear transformations and matrices.
5-26
Further Reading
Further Reading
[Brog91] W. L. Brogan, Modern Control Theory, 3rd Ed., Englewood
Cliffs, NJ: Prentice-Hall, 1991.
This is a well-written book on the subject of linear systems.
The first half of the book is devoted to linear algebra. It also
has good sections on the solution of linear differential equa-
tions and the stability of linear and nonlinear systems. It
has many worked problems.
[Stra76] G. Strang, Linear Algebra and Its Applications, New York:
Academic Press, 1980.
Strang has written a good basic text on linear algebra.
Many applications of linear algebra are integrated into the
text.
5-27
5 Signal and Weight Vector Spaces
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.5 Consider a perceptron network, with the following weights and bias.
W = 1 0 1 , b = 0 .
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 sub-
sets 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 de-
2
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
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)
2+2
and (iv) using the MATLAB function rank.)
ans =
4
1 1 1
i. 2 0 2
3 1 1
iii. 1 + t 1t
1 1 3
iv. 2 0 4
2 0 4
1 1 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 intui-
tive sense.
1 1 1
p 1 = 1 orange p2 = 1 apple p = 1
1 1 1
E5.10 Using the following basis vectors, find an orthogonal set using Gram-
Schmidt orthogonalization. (Check your answer using MATLAB.)
2+2 1 1 1
ans = y1 = 0 y2 = 1 y3 = 1
4
0 0 1
E5.11 Consider the vector space of all piecewise continuous functions on the in-
terval [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
5 Signal and Weight Vector Spaces
(f,g) = f t g t dt .
0
1 1 1
1 1
1
-1 -1 -1
E5.12 Consider the vector space of all piece wise continuous functions on the in-
terval [0,1]. The set f 1 f 2 , which is defined in Figure E15.2, contains two
vectors from this vector space.
f2(t)
f1(t)
2
1 1
1 1
-1 -1
-
(f,g) = f t g t dt .
0
5-30
Exercises
g (t)
3
2 h (t)
1 1
1
1
-1
-2
-3
Figure E15.3 Vectors vectors g and h for Exercise E5.12 part ii.
ii. Expand the vectors g and h in Figure E15.3 in terms of the orthog-
onal 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 }
y = 2
u
{v 1 = 1 + t , v 2 = 1 t }
x = 1 v1 + 1 v2
The vectors v 1 and v2 can be expanded in terms of the basis vectors {s1, s 2}
as
v1 = 1 s1 1 s2
v2 = 1 s1 + 1 s2
5-31
5 Signal and Weight Vector Spaces
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 0t1 f2 t = 1 t 0t1
1 1
t t
1 1
(f,g) = f t g t dt .
0
h t = t 1 0t1
t
1
-1
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
i. Consider the following basis set for the vector space described
above: v 1 = 1 + 2j , v 2 = 2 + j . Using the Gram-Schmidt method,
find an orthogonal basis set.
ii. Using your orthogonal basis set from part i., find vector expansions
for u 1 = 1 j , u 2 = 1 + j , and x = 3 + j . This will allow you to write
x , u1 , and u2 as a columns of numbers x , u 1 and u 2 .
iii. We now want to represent the vector x 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 a new
u
column of numbers x .
iv. Show that the representations for x that you found in parts ii. and
u
iii. are equivalent (the two columns of numbers x and x both rep-
resent the same vector x ).
E5.17 Consider the vectors defined in Figure E15.6. The set s 1 s 2 is the stan-
dard basis set. The set u 1 u 2 is an alternate basis set. The vector x is a
vector that we wish to represent with respect to the two basis sets.
s2
u1
s1
u2
5-33
5 Signal and Weight Vector Spaces
iii. Using reciprocal basis vectors, write the expansion for x in terms of
the basis u 1 u 2 .
iv. Draw sketches, similar to Figure 5.2, that demonstrate that the ex-
pansions 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 defin-
ing 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 ex-
pansion), 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 rep-
resent the same vector x ).
E5.19 Suppose that we have three vectors: x y z X . We want to add some mul-
tiple 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 y = 1 z = 0.5
0 0.5 1
T
E5.20 Expand x = 1 2 2 in terms of the following basis set. (Verify your an-
swer using MATLAB.)
2+2
ans =
4 1 1 1
v1 = 1 v2 = 1 v3 = 1
0 2 0
5-34
Exercises
12
E5.21 Find the value of a that makes x a y a minimum. (Use x = (x,x) .)
Show that for this value of a the vector z = x a y is orthogonal to y and
that
2 2 2
x ay + ay = x .
(The vector ay is the projection of x on y.) Draw a diagram for the
case where x and y are two-dimensional. Explain how this concept
is related to Gram-Schmidt orthogonalization.
5-35
Objectives
Objectives
This chapter will continue the work of Chapter 5 in laying out the mathe-
matical foundations for our analysis of neural networks. In Chapter 5 we
reviewed vector spaces; in this chapter we investigate linear transforma-
tions 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 under-
standing of such key neural network topics as performance learning (in-
cluding the Widrow-Hoff rule and backpropagation) and Hopfield network
convergence.
6-1
6 Linear Transformations for Neural Networks
a t + 1 = satlin Wa t + b . (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
p
Sx1 W n(t + 1) a(t + 1) a(t)
SxS
Sx1 Sx1 D Sx1
1 b
Sx1
S S
Linear Transformations
We begin with some general definitions.
Transformation 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 .
6-2
Matrix Representations
Matrix Representations
As we mentioned at the beginning of this chapter, matrix multiplication is
x 1+x 2 an example of a linear transformation. We can also show that any linear
transformation between two finite-dimensional vector spaces can be repre-
x2 sented by a matrix (just as in the last chapter we showed that any general
vector in a finite-dimensional vector space can be represented by a column
of numbers). To show this we will use most of the concepts covered in the
x1 previous chapter.
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 . This means that for any two vectors x X and
yY
A(x 1 + x 2)
n m
A(x 1)
x = x i v i and y = y i u i . (6.2)
i=1 i=1
Ax = y (6.3)
can be written
A(ax )
= aA(x ) ax
n
m
A x j v j = yi ui . (6.4)
j=1 i=1
A(x ) x
Since A is a linear operator, Eq. (6.4) can be written
n m
xj A vj = yi ui . (6.5)
j=1 i=1
6-3
6 Linear Transformations for Neural Networks
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 m m
xj a ij u i = yi ui . (6.7)
j=1 i=1 i=1
ui a ij xj = yi ui . (6.8)
i=1 j=1 i=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 identi-
cally zero (see Eq. (5.4)), therefore
n
aij x j = yi . (6.10)
j=1
a 11 a 12 a 1n x 1 y1
a 21 a 22 a 2n x 2 y2 (6.11)
=
a m1 a m2 a mn x n ym
6-4
Matrix Representations
Keep in mind that the matrix representation is not unique (just as the rep-
resentation 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 advan-
tage in later chapters.
2 As an example of a matrix representation, consider the rotation transfor-
+2
mation. 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 do-
main 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
s2 A(x) things simple we will use the standard basis for both ( u i = v i = s i ), as
shown in the adjacent figure.
The first step is to transform the first basis vector and expand the resulting
x transformed vector in terms of the basis vectors. If we rotate s 1 counter-
clockwise by the angle we obtain
2
s1
A s 1 = cos s1 + 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 expan-
sion make up the first column of the matrix representation.
cos() A(s1) The next step is to transform the second basis vector. If we rotate s 2 coun-
terclockwise by the angle we obtain
sin()
2
as can be seen in the lower left figure. From this expansion we obtain the
second column of the matrix representation. The complete matrix repre-
s2 sentation is thus given by
A(s2) -sin()
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
6 Linear Transformations for Neural Networks
Change of Basis
We notice from the previous section that the matrix representation of a lin-
ear 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 = yi ui . (6.16)
i=1
So if
Ax = y (6.17)
a 11 a 12 a 1n x 1 y1
a 21 a 22 a 2n x 2 y2
=
a m1 a m2 a mn x n ym
, (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' i w i . (6.21)
i=1
a' m1 a' m2 a' mn x' n y' m
or
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 ele- 6
ment 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 1i w 1i
t 2i w 2i . (6.26)
ti = wi =
t ni w mi
6-7
6 Linear Transformations for Neural Networks
Bt = t1 t2 tn . (6.27)
Bw = w1 w2 wm . (6.29)
y = B w y' , (6.30)
which then demonstrates the relationships between the two different rep-
resentations for the vector y.
Now substitute Eq. (6.28) and Eq. (6.30) into Eq. (6.19):
A comparison of Eq. (6.32) and Eq. (6.23) yields the following operation for
Change of Basis a change of basis:
1
A' = B w AB t . (6.33)
This key result, which describes the relationship between any two matrix
Similarity Transform 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 rep-
resentation that reveals the key characteristics of the linear transforma-
tion it represents. This will be discussed in the next section.
2 As an example of changing basis sets, lets revisit the vector rotation exam-
+2
ple of the previous section. In that section a matrix representation was de-
veloped 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 do-
main and the range.)
t2 The first step is to expand t 1 and t 2 in terms of the standard basis set, as
s2 in Eq. (6.24) and Eq. (6.25). By inspection of the adjacent figure we find:
t1 t 1 = s 1 + 0.5 s 2 , (6.34)
s1 t2 = s1 + s2 . (6.35)
t1 = 1 t2 = 1 . (6.36)
0.5 1
Bt = t1 t2 = 1 1 , (6.37)
0.5 1
and, because we are using the same basis set for both the domain and the
range of the transformation,
Bw = Bt = 1 1 . (6.38)
0.5 1
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)
Take, for example, the case where = 30.
and
6-9
6 Linear Transformations for Neural Networks
To check that these matrices are correct, lets try a test vector
(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
How can we test to see if y' does correspond to y ? Both should be represen-
tations 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 re-
ciprocal basis vectors to transform from one representation to another (see
Eq. (5.43)). Using that concept we have
t2 y = A( x )
s2 1
t1 = x y' = B 1 y = 1 1 0.616 = 2 3 2 3 0.616 = 1.033 , (6.45)
0.5 1 0.933 1 3 2 3 0.933 0.416
s1 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.
6-10
Eigenvalues and Eigenvectors
Az = z (6.46)
s1 How can we compute the eigenvalues and eigenvectors? Suppose that a ba-
sis has been chosen for the n-dimensional vector space X . Then the matrix
representation for Eq. (6.46) can be written
Az = z , (6.47)
or
A I z = 0 . (6.48)
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)
or
2 2 2 2
2 cos + cos + sin = 2 cos + 1 = 0 . (6.52)
6-11
6 Linear Transformations for Neural Networks
A = 1 1 . (6.54)
0 2
1 1 = 0, (6.55)
0 2
or
2
+ 3 + 2 = + 1 + 2 = 0 , (6.56)
1 = 1 2 = 2 . (6.57)
To find the eigenvectors we must solve Eq. (6.48), which in this example be-
comes
1 1 z = 0 . (6.58)
0 2 0
We will solve this equation twice, once using 1 and once using 2 . Begin-
ning with 1 we have
0 1 z = 0 1 z 11 = 0 (6.59)
1
0 1 0 1 z 21 0
or
z 21 = 0 , no constraint on z 11 . (6.60)
6-12
Eigenvalues and Eigenvectors
z1 = 1 , (6.61)
0
1 1 z = 1 1 z 12 = 0 , (6.62)
2
00 0 0 z 22 0
or
z 22 = z 12 . (6.63)
z2 = 1 , (6.64)
1
or any scalar multiple.
To verify our results we consider the following:
Az 1 = 1 1 1 = 1 = 1 1 = 1 z 1 , (6.65)
0 2 0 0 0
Az 2 = 1 1 1 = 2 = 2 1 = 2 z 2 . (6.66)
0 2 1 2 1
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 eigenvec-
tors as the basis vectors. From Eq. (6.33) we have
A' = B AB = 1 1 1 1 1 1 = 1 0 .
1
(6.67)
0 1 0 2 0 1 0 2
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 Linear Transformations for Neural Networks
B = z1 z2 zn , (6.68)
1 0 0
1 0 2 0
B AB =
0 0 n
, (6.69)
where { 1 2 , n} are the eigenvalues of the matrix A.
This result will be very helpful as we analyze the performance of several
neural networks in later chapters.
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
6
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
6 Linear Transformations for Neural Networks
A I = 0
Diagonalization
B = z1 z2 zn ,
1 0 0
1 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?
p
Rx1 W
SxR n a
Sx1 Sx1
1 b
R Sx1 S
a = purelin (Wp + b)
a = A p = Wp + b .
In order for this transformation to be linear it must satisfy
1. A p1 + p2 = A p1 + A p2 ,
2. A ap = a A p .
Lets test condition 1 first.
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
6 Linear Transformations for Neural Networks
(a x,v) a (x,v)
A a x = --------------- v = --------------- v = a A x .
(v,v) (v,v)
s2
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
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 ex-
s1 pansion 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 s1 = 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 ma-
trix. Next we transform s 2 :
s2 2
A s 2 = s1 = a i2 s i = a 12 s 1 + a 22 s 2 = 1 s 1 + 0 s 2
i=1
(as shown in the second figure on the left), which gives us the second col-
A(s2) = -s1 umn of the matrix. The final result is
0 1 .
1 0
T
Lets test our result by transforming the vector x = 1 1 :
Ax = 0 1 1 = 1 .
1 0 1 1
6-19
6 Linear Transformations for Neural Networks
s2 x
s1
A(x )
P6.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
conjugation operator (i.e., A x = x ).
i. Find the matrix of the transformation A relative to the basis
set given above.
ii. Find the eigenvalues and eigenvectors of the transforma-
tion.
iii. Find the matrix representation for A relative to the eigen-
vectors as the basis vectors.
i. To find the matrix of the transformation, transform each of the basis
vectors (by finding their conjugate):
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
6-20
Solved Problems
A I = 1 2
= 1 = 1 + 1 = 0 .
1
A I z = 1 z = 0 .
1 0
1 1 z = 1 1 z 11 = 0 ,
1
1 1 1 1 z 21 0
or
z 11 = z 21 .
z1 = 1 ,
1
1 1 z = 1 1 z 12 = 0 ,
1
11 1 1 z 22 0
or
z 12 = z 22 .
Therefore the second eigenvector is
z2 = 1 ,
1
z1 = 1 v1 + 1 v2 = 1 + j + 1 j = 2 ,
6-21
6 Linear Transformations for Neural Networks
z 2 = 1 v1 + 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 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.5 0.5 1 0 1 1 0 1 0 2
A = 2 2 .
1 3
A I = 2 2 2
= 5 + 4 = 1 4 = 0 ,
1 3
A I z = 2 2 z = 0 .
1 3 0
For = 1 = 1
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 .
z1 = 2 ,
1
2 2 z = 2 2 z 12 = 0 ,
1
1 1 1 1 z 22 0
or
z 12 = z 22 .
z2 = 1 ,
1
where
B = z1 z2 = 2 1 .
1 1
Therefore we have
6-23
6 Linear Transformations for Neural Networks
1 1
--- ---
A' = 3 3 2 2 2 1 = 1 0 = 1 0 .
1 2 1 3 1 1 0 4 0 2
--- ---
3 3
3 2
P6.6 Consider a transformation A :R R whose matrix representation
relative to the standard basis sets is
A = 3 1 0 .
0 0 1
Find the matrix for this transformation relative to the basis sets:
2 0 0
T = 0 1 2 W = 1 0 .
0 2
1 0 3
2 0 0
Bt = 0 1 2 Bw = 1 0 .
0 2
1 0 3
1 0 2 0 0 6 1 2
3 1 0
A' = 1 0 1 2 = 1 3 .
0 --- 0 0 1 --- 0 ---
2 1 0 3 2 2
Therefore this is the matrix of the transformation with respect to the basis
sets T and W .
6-24
Solved Problems
A v1 = v1 + 2 v2 ,
A v2 = v1 + v2 .
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
w1 = 1 w2 = 1 .
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 1 5 1
--- --- --- ---
A' = 2 2 1 1 1 1 = 2 2 .
1 1 2 1 1 1 1 1
--- --- --- ---
2 2 2 2
6-25
6 Linear Transformations for Neural Networks
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 . Consid-
er 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 transforma-
tion.
i. The first step is to transform each of the basis vectors:
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
1 0
3
D I = 0 2 = = 0 .
0 0
Therefore all three eigenvalues are zero. To find the eigenvectors we need
to solve
1 0 0
D I z = 0 2 z = 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
z2 = z3 = 0 .
1
z = 0 .
0
2 2
P6.9 Consider a transformation A :R R . Two examples of trans-
formed vectors are given in Figure P6.4. Find the matrix represen-
tation of this transformation relative to the standard basis set.
x1
x2
s2
A(x 1)
s1
A(x 2)
A 2 = 1 , A 1 = 2 .
2 0 1 1
A 2 1 = 1 2 .
2 1 0 1
6-27
6 Linear Transformations for Neural Networks
So that
1 1 3 5
1 --- --- --- ---
A = 1 2 2 1 = 1 2 4 4 = 4 4 .
0 1 2 1 0 1 1 1 1 1
--- --- --- ---
2 2 2 2
6-28
Epilogue
Epilogue
In this chapter we have reviewed those properties of linear transforma-
tions and matrices that are most important to our study of neural net-
works. 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
6 Linear Transformations for Neural Networks
Further Reading
[Brog91] W. L. Brogan, Modern Control Theory, 3rd Ed., Englewood
Cliffs, NJ: Prentice-Hall, 1991.
This is a well-written book on the subject of linear systems.
The first half of the book is devoted to linear algebra. It also
has good sections on the solution of linear differential equa-
tions and the stability of linear and nonlinear systems. It
has many worked problems.
[Stra76] G. Strang, Linear Algebra and Its Applications, New York:
Academic Press, 1980.
Strang has written a good basic text on linear algebra.
Many applications of linear algebra are integrated into the
text.
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.
v2
A(v1)
s2 v1
s1
A(v2)
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 multi-
plication by 1 + j (i.e., A x = 1 + j x ).
i. Find the matrix of the transformation A relative to the basis set
given above.
ii. Find the eigenvalues and eigenvectors of the transformation.
iii. Find the matrix representation for A relative to the eigenvectors as
the basis vectors.
2+2
ans = iv. Check your answers to parts (ii) and (iii) using MATLAB.
4
6-31
6 Linear Transformations for Neural Networks
2 3
E6.5 Consider a transformation A :P P , from the space of second-order poly-
nomials to the space of third-order polynomials, which is defined by the fol-
lowing:
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 poly-
2
nomials have the form f t = a 0 + a 1 t + a 2 t . Now consider the transforma-
tion 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 D relative to the basis set V .
ii. Find the eigenvalues and eigenvectors of the transformation. Show
the eigenvectors as columns of numbers and as functions of t .
iii. Find the matrix of the transformation relative to the eigenvectors as
basis vectors.
2t
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 D relative to the basis set V ,
using Eq. (6.6).
2t
ii. Verify the operation of the matrix on the function 2e .
iii. Find the eigenvalues and eigenvectors of the transformation. Show
the eigenvectors as columns of numbers (with respect to the basis
set V ) and as functions of t .
6-32
Exercises
E6.9 Consider the set of all 2x2 matrices. This set is a vector space, which we will
call X (yes, matrices can be vectors). If M is an element of this vector space,
T
define the transformation A :X X , such that A M = M + M . Consider
the following basis set for the vector space X.
v1 = 1 0 , v2 = 0 1 , v3 = 0 0 , v4 = 0 0
0 0 0 0 1 0 0 1
12
01
1 2
E6.10 Consider a transformation A :P P , from the space of first degree poly-
nomials into the space of second degree polynomials. The transformation is
defined as follows
A a + bt = at + b--- t 2
2
2 1
(e.g., A 2 + 6t = 2t + 3t ). One basis set for P is U = 1 t . One basis for
2 2
P is V = 1 t t .
i. Find the matrix representation of the transformation A relative to
the basis sets U and V , using Eq. (6.6).
ii. Verify the operation of the matrix on the polynomial 6 + 8t . (Verify
that the matrix multiplication produces the same result as the
transformation.)
6-33
6 Linear Transformations for Neural Networks
E6.11 Let D be the differentiation operator ( D f = df dt ), and use the basis set
5t 5t
u 1 u 2 = e te
E6.12 A certain linear transformation has the following eigenvalues and eigen-
vectors (represented in terms of the standard basis set):
1 = 1 , z = 1 = 2
z1 = 1 2 2
2 2
2 2
E6.13 Consider a transformation A : . In the figure below, we show a set
of basis vectors V = v 1 v 2 and the transformed basis vectors.
A(v1) v1 v2
A(v2)
6-34
Exercises
2 3
E6.14 Consider the vector spaces P and P of second-order and third-order poly-
nomials. 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 2
E6.15 A certain linear transformation A : has a matrix representation
relative to the standard basis set of
A = 1 2 .
3 4
1 = 1 z1 = 1 2 = 2 z2 = 1 .
1 2
6-35
6 Linear Transformations for Neural Networks
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 transforma-
tion 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 x
s2
y =A(x )
s1
v2
2
E6.18 Consider the following basis set for :
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 2
ii. Consider a transformation A : . The matrix representation
2
for A relative to the standard basis in is
A = 0 1 .
2 3
Find the expansion of Av 1 in terms of the basis set V . (Use the re-
ciprocal 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
Objectives 7-1
Theory and Examples 7-2
Linear Associator 7-3
The Hebb Rule 7-4
Performance Analysis 7-5
Pseudoinverse Rule 7-7
Application 7-10
Variations of Hebbian Learning 7-12
Summary of Results 7-14
Solved Problems 7-16
Epilogue 7-29
Further Reading 7-30
Exercises 7-31
Objectives
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
7 Supervised Hebbian Learning
7-2
Linear Associator
Linear Associator
Hebbs learning law can be used in combination with a variety of neural
network architectures. We will use a very simple architecture for our initial
presentation of Hebbian learning. In this way we can concentrate on the
learning law rather than the architecture. The network we will use is the
Linear Associator linear associator, which is shown in Figure 7.1. (This network was intro-
duced independently by James Anderson [Ande72] and Teuvo Kohonen
[Koho72].)
p n a
Rx1
W Sx1 Sx1
SxR
R S
a = purelin (Wp)
a = Wp , (7.1)
or
R
ai = w ij p j . (7.2)
j=1
{p 1, t 1} {p 2 , t 2} {p Q, t Q} . (7.3)
7-3
7 Supervised Hebbian Learning
where p jq is the jth element of the qth input vector p q ; a iq is the ith ele-
ment of the network output when the qth input vector is presented to the
network; and is a positive constant, called the learning rate. This equa-
tion 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
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 in-
crease 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 unsu-
pervised Hebb rule in Chapter 13.) For the supervised Hebb rule we substi-
tute 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 do-
ing. The resulting equation is
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:
new old T
W = W + tq pq . (7.7)
7-4
The Hebb Rule
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
+ + tQ pQ = tq pq .
T T T T
W = t1 p1 + t2 p2 (7.8)
q=1
T
p1
T
W = t 1 t 2 t Q p 2 = TP ,
T
(7.9)
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 associa-
tor. First consider the case where the p q vectors are orthonormal (orthog-
onal and unit length). If p k is input to the network, then the network
output can be computed
Q Q
T
tq pq pk .
T
a = Wp k = t q p q p k = (7.11)
q=1 q=1
= 0 q k. (7.12)
Therefore Eq. (7.11) can be rewritten
a = Wp k = t k . (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
7 Supervised Hebbian Learning
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
tq pq pk .
T
a = Wp k = t k + (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 As an example, suppose that the prototype input/output vectors are
+2
0.5 0.5
0.5 t = 1 0.5 1
p1 = 1 p2 = t2 = . (7.15)
0.5 1 0.5 1
0.5 0.5
W = TP =
T 1 1 0.5 0.5 0.5 0.5 = 1 0 0 1 . (7.16)
1 1 0.5 0.5 0.5 0.5 0 1 1 0
0.5
Wp 1 = 1 0 0 1 0.5 = 1 , (7.17)
0 1 1 0 0.5 1
0.5
and
0.5
Wp 2 = 1 0 0 1 0.5 = 1 . (7.18)
0 1 1 0 0.5 1
0.5
7-6
Pseudoinverse Rule
Now lets revisit the apple and orange recognition problem described in
2
+2 Chapter 3. Recall that the prototype inputs were
1 1
p 1 = 1 orange p2 = 1 apple . (7.19)
1 1
(Note that they are not orthogonal.) If we normalize these inputs and
choose as desired outputs -1 and 1, we obtain
0.5774 0.5774
1
p = 0.5774 t 1 = 1 p 2 = 0.5774 t 2 = 1 . (7.20)
0.5774 0.5774
0.5774
Wp 1 = 0 1.1548 0 0.5774 = 0.6668 , (7.22)
0.5774
7
0.5774
Wp 2 = 0 1.1548 0 0.5774 = 0.6668 . (7.23)
0.5774
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 pro-
duces 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 q = 1 2 Q . (7.24)
7-7
7 Supervised Hebbian Learning
2
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 orthogo-
nal 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)
where
T = t1 t2 tQ P = p1 p2 pQ . (7.27)
where
E = T WP , (7.29)
and
eij .
2 2
E = (7.30)
i j
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
It has been shown [Albe72] that the weight matrix that minimizes Eq.
Pseudoinverse Rule (7.25) is given by the pseudoinverse rule:
+
W = TP , (7.32)
+
where P is the Moore-Penrose pseudoinverse. The pseudoinverse of a real
matrix P is the unique matrix that satisfies
+
PP P = P,
+ + +
P PP = P ,
T
(7.33)
+ +
P P = P P ,
+ + T
PP = PP .
+ T 1 T
P = P P P . (7.34)
2 To test the pseudoinverse rule (Eq. (7.32)), consider again the apple and or-
+2
ange recognition problem. Recall that the input/output prototype vectors
are
1 1
1
p = 1 t1 = 1 p2 = 1 t2 = 1 . (7.35)
1 1
(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 , (7.36)
1 1
7-9
7 Supervised Hebbian Learning
1
Wp 1 = 0 1 0 1 = 1 (7.39)
1
1
Wp 2 = 0 1 0 1 = 1 (7.40)
1
The network outputs exactly match the desired outputs. Compare this re-
sult 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
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 memo-
Autoassociative Memory ry. 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 pat-
p1,t1 p2,t2 p3,t3 terns 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 vec-
tors, 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
T T T
W = p1 p1 + p2 p2 + p3 p3 . (7.42)
p n a
30x1
W 30x1 30x1
30x30
30 30
a = hardlims (Wp)
7-11
7 Supervised Hebbian Learning
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:
new old T
W = W + 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:
new old T old old T
W = W + t q p q W = 1 W + t q p q , (7.45)
7-12
Variations of Hebbian Learning
law quickly forgets old inputs and remembers only the most recent pat-
terns. This keeps the weight matrix from growing without bound.
The idea of filtering the weight changes and of having an adjustable learn-
ing 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 impor-
tant learning rule:
new old T
W = W + t q a q p q . (7.46)
This is sometimes known as the delta rule, since it uses the difference be-
tween desired and actual output. It is also known as the Widrow-Hoff algo-
rithm, 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 Chap-
ter 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:
new old T
W = W + 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 re-
quire knowledge of the desired output, is actually a more direct interpreta-
tion of Hebbs postulate than is the supervised form discussed in this
chapter.
7-13
7 Supervised Hebbian Learning
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 fir-
ing B, is increased.
Linear Associator
Inputs Linear Layer
p n a
Rx1
W Sx1 Sx1
SxR
R S
a = purelin (Wp)
W = t1 p1 + t2 p2 + + tQ pQ
T T T
T
p1
T
W = t 1 t 2 t Q p 2 = TP
T
T
pQ
Pseudoinverse Rule
+
W = TP
7-14
Summary of Results
+ T 1 T
P = P P P .
Delta Rule
(See Chapter 10)
new old T
W = W + t q a q p q
Unsupervised Hebb
(See Chapter 13)
new old T
W = W + a q p q
7-15
7 Supervised Hebbian Learning
Solved Problems
P7.1 Consider the linear associator shown in Figure P7.1.
p n a
4x1
W 2x1 2x1
2x4
4 2
a = purelin (Wp)
1 1
1 t = 1 1 1
p1 = 1 p2 = t2 = .
1 1 1 1
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. The first step is to create the P and T matrices of Eq. (7.10):
1 1
P = 1
1 , T = 1 1 .
1 1 1 1
1 1
7-16
Solved Problems
h
W = TP =
T 1 1 1 1 1 1 = 2 0 0 2 .
1 1 1 1 1 1 0 2 2 0
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):
+ T 1 T
P = P P P .
1
1 1
1
P = 1 1 1 1 1 1
+ 1 1 1 1 = 4 0 1 1 1 1
1 1 1 1 1 1
1 1 1 1 0 4 1 1 1 1
1 1
1 1 1 1 1
--- 0 --- --- --- ---
= 4 1 1 1 1 = 4 4 4 4
1 1 1 1 1 1 1 1 1
0 --- --- --- --- ---
4 4 4 4 4
1 1 1 1 1 1
--- --- --- --- --- 0 0 ---
p
W = TP = 1 1+4 4 4 4 = 2 2 .
1 1 1 1 1 1 1 1
--- --- --- --- 0 --- --- 0
4 4 4 4 2 2
1
h
W p1 = 2 0 0 2 1 = 4 t
1
0 2 2 0 1 4
1
7-17
7 Supervised Hebbian Learning
1 1 1
--- 0 0 ---
W p1 = 2 2 1 = 1 = t
p
1
1 1 1 1
0 --- --- 0
2 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 equa-
tion can be written
h T
W p1 = t1 p1 p1 ,
T
but the p 1 vector is not normalized, so p 1 p 1 1 . Therefore the output of
the network will not be t 1 .
The pseudoinverse rule, on the other hand, is guaranteed to minimize
2
2
t q Wp q ,
q=1
7-18
Solved Problems
1
1
p1 p2 = 1 1 1 1 1 1 1 = 0 .
T
1
1
1
Therefore they are orthogonal. (Although they are not normalized since
T 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
1 1
P = T = 1
1 .
1 1
1 1
1 1
1 1 2 0 2 0 2 0
1 1 0 2 0 2 0 2
W = TP = 1
1 1 1 1 1 1 1 = 2 0 2 0 2 0 .
T
1 1 1 1 1 1 1 1 0 2 0 2 0 2
1 1 2 0 2 0 2 0
1 1 0 2 0 2 0 2
7-19
7 Supervised Hebbian Learning
2 0 2 0 2 0 1
0 2 0 2 0 2 1
2 0 2 0 2 0 1
a = hardlims Wp t = hardlims
0 2 0 2 0 2 1
2 0 2 0 2 0 1
0 2 0 2 0 2 1
2 1
6 1
2 1 = p .
a = hardlims = 2
6 1
2 1
6 1
1 1 1 1
1 1 1 1
1 1 1 1
p1 = 1 p2 = 1 p3 = 1 pt = 1
1 1 1 1
1 1 1 1
1 1 1 1
7-20
Solved Problems
This problem is a little tedious to work out by hand, so lets use MATLAB.
2+2 First we create the prototype vectors.
ans =
4
p1=[ 1 1 -1 -1 1 1 1]';
p2=[ 1 1 1 -1 1 -1 1]';
p3=[-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';
ah'
ans =
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'; 7
wp=P*pseu;
ap=hardlims(wp*pt);
ap'
ans =
-1 1 -1 1 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 pro-
duces the correct response.
Try other test inputs to see if there are additional cases where the pseudo-
inverse rule produces better results than the Hebb rule.
7-21
7 Supervised Hebbian Learning
1 1 1 1
p1 = 1
p2 = 1 p3 = 1 pt = 1 .
1 1 1 1
1 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 de-
sired outputs to be:
t1 = 1 t2 = 1 t3 = 1 .
1 1 1
(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.
p n a
4x1
W 2x1 2x1
2x4
4 2
a = hardlims (Wp)
7-22
Solved Problems
1 1 1 1
W = TP = 1 1 1 3 1 1 1
T
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.
1
a = hardlims Wp t = hardlims 3 1 1 1 1
1 3 1 1 1
1
= hardlims 2 = 1 p 1 .
2 1
So the response of the network indicates that the test input pattern is clos-
est 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 de-
signed 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 ma-
7
trix?
i. Suppose the prototype vectors are:
p 1 p 2 p Q .
Since this is an autoassociator, these are both the input vectors and the de-
sired 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
pq pq ,
T T
W = TP =
q=1
7-23
7 Supervised Hebbian Learning
from Eq. (7.8). Now, if we apply one of the prototype vectors as input to the
network we obtain
Q Q
T
pq pq pk .
T
a = Wp k = p q p q p k =
q=1 q=1
a = pk R .
Wp k = Rp k ,
z 1 z 2 z R Q .
7-24
Solved Problems
P7.6 The networks we have used so far in this chapter have not includ-
ed a bias vector. Consider the problem of designing a perceptron
network (Figure P7.3) to recognize the following patterns:
p1 = 1 p2 = 2 .
1 2
p
2x1
W
1x2
n a
1x1 1x1
1 b
2 1x1 1
- Exp (Wp
a = hardlims - + b)
Wp + b = 0 .
Wp = 0 ,
which is a line that must pass through the origin. Now consider the two
Wp = 0 vectors, p 1 and p 2 , which are given in this problem. They are shown graph-
ically in the figure to the left, along with an arbitrary decision boundary
p2 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.
p1 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
7 Supervised Hebbian Learning
1 2
p' 1 = 1 p' 2 = 2 .
1 1
t1 = 1 t2 = 1 ,
so that
1 2
P = 1 2 , T = 1 1 .
1 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
p2
Wp + b = 0
p1
P7.7 In all of our pattern recognition examples thus far, we have repre-
sented patterns as vectors by using 1 and -1 to represent dark
and light pixels (picture elements), respectively. What if we were
to use 1 and 0 instead? How should the Hebb rule be changed?
First, lets introduce some notation to distinguish the two different repre-
sentations (usually referred to as the bipolar {-1, 1} representation and the
binary {0, 1} representation). The bipolar representation of the prototype
input/output vectors will be denoted
{p 1, t 1} {p 2, t 2} {p Q, t Q} ,
1 1
p' q = --- p q + --- 1 p q = 2p' q 1 ,
2 2
7-27
7 Supervised Hebbian Learning
effective response as a bipolar network (as in Figure 7.2), then the net in-
put, n , should be the same for both networks:
W'p' + b = Wp .
p'
Rx1 W'
SxR n a
Sx1 Sx1
1 b
R Sx1 S
a = hardlim (Wp'+ b)
W' = 2W b = W1 ,
7-28
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 con-
tinues 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 to-
gether 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
7 Supervised Hebbian Learning
Further Reading
[Albe72] A. Albert, Regression and the Moore-Penrose Pseudoin-
verse, 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 inter-
active memory, Mathematical Biosciences, vol. 14, pp.
197220, 1972.
Anderson proposed a linear associator model for associa-
tive memory. The model was trained, using a generaliza-
tion 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] D. O. Hebb, The Organization of Behavior, New York:
Wiley, 1949.
The main premise of this seminal book is that behavior can
be explained by the action of neurons. In it, Hebb proposes
one of the first learning laws, which postulated a mecha-
nism for learning at the cellular level.
[Koho72] T. Kohonen, Correlation matrix memories, IEEE Trans-
actions on Computers, vol. 21, pp. 353359, 1972.
Kohonen proposed a correlation matrix model for associa-
tive memory. The model was trained, using the outer prod-
uct rule (also known as the Hebb rule), to learn an
association between input and output vectors. The mathe-
matical structure of the network was emphasized. Ander-
son published a closely related paper at the same time
[Ande72], although the two researchers were working inde-
pendently.
7-30
Exercises
Exercises
E7.1 Consider the prototype patterns given to the left.
E7.3 Use the Hebb rule to determine the weight matrix for a perceptron network
(shown in Figure E7.1) to recognize the patterns shown to the left.
p1 p2
Inputs Sym. Hard Limit Layer
p n a
6x1
W 1x1 1x1
1x6
6 1
a = hardlims (Wp)
E7.4 In Problem P7.7 we demonstrated how networks can be trained using the
Hebb rule when the prototype vectors are given in binary (as opposed to bi-
polar) form. Repeat Exercise E7.1 using the binary representation for the
prototype vectors. Show that the response of this binary network is equiv-
alent to the response of the original bipolar network.
7-31
7 Supervised Hebbian Learning
where Q is the number of prototype vectors. (Hint: show that the prototype
vectors continue to be eigenvectors of the new weight matrix.)
1 t = 1 p = 1 t = 1 p = 0 t = 1 .
p1 = 1 2 2 3 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 = 4 t = 2 t =
p1 = 1 26 p2 = 2 26 p3 = 3 26
4 2 2
iv. Find and sketch the decision boundary for the network with the
pseudo-inverse rule weights.
v. Compare (discuss) the decision boundaries and weights for each of
the methods (Hebb and pseudo-inverse).
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 1
E7.9 Suppose that we have the following three reference patterns and their tar-
gets.
3 t = 6 t = 6 t =
p1 = 1 75 p2 = 2 75 p3 = 3 75
6 3 3
1 t = 1 t =
p1 = 1 1 p2 = 2 1
1 1
i. Use the Hebb rule to determine the weight matrix for the percep-
tron 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
7 Supervised Hebbian Learning
a
1x1
p n
2x1
W 1x1
1x2
2 1
a = hardlims(Wp)
7-34
Objectives
Objectives
This chapter lays the foundation for a type of neural network training tech-
nique 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 perfor-
mance 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 exist-
ence of minima and maxima of the performance surface. Chapter 9 will fol-
low this up with a discussion of procedures to locate the minima or maxima.
8-1
8 Performance Surfaces and Optimum Points
Taylor Series
Let us say that the performance index that we want to minimize is repre-
sented 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
Taylor Series Expansion derivatives exist. Then it can be represented by its Taylor series expansion
about some nominal point x :
d
F x = F x + F x x x
dx x = x
2
1 d
x x +
2
+ --- 2 F x
2 dx (8.1)
x = x
n
1 d
x x +
n
+ ----- n F x
n! d x
x = x
8-2
Taylor Series
F x = cos x . (8.2)
1 2
F x = cos x = cos 0 sin 0 x 0 --- cos 0 x 0
2
1
+ --- sin 0 x 0 +
3
6
1 2 1 4
= 1 --- x + ------ x +
2 24 (8.3)
The zeroth-order approximation of F x (using only the zeroth power of x )
is
F x F0 x = 1 . (8.4)
1 2
F x F 2 x = 1 --- x . (8.5)
2
(Note that in this case the first-order approximation is the same as the ze-
roth-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 . (8.6)
2 24
F0 x
1
F4 x
0.5
-0.5
Fx
-1 F2 x
-1.5
-6 -4 -2 0 2 4 6
8-3
8 Performance Surfaces and Optimum Points
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 approxima-
tion 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 be-
havior. 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 pos-
sible 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. Consid-
er 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
F x = F x + Fx x x + F x x x
x1 x = x 1 1 x2 x = x 2 2
2
1
++ x x + --- 2 F x x x
2
Fx
xn x = x n n 2 x x = x 1 1
1
2
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 ma-
trix form, as in:
F x = F x + F x x x
T
x = x
1
+ --- x x 2F x x x +
T
2 x = x (8.9)
Gradient where F x is the gradient, and is defined as
8-4
Directional Derivatives
T
F x =
Fx F x Fx , (8.10)
x1 x2 xn
2 2 2
F x Fx Fx
x1
2 x 1 x 2 x 1 x n
2 2 2
Fx F x Fx .
2F x = x 2 x 1 x2
2 x 2 x n (8.11)
2 2 2
Fx Fx F x
x n x 1 x n x 2 xn
2
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
The ith element of the gradient, F x x i , is the first derivative of the per-
formance 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 in-
dex F along the x i axis. What if we want to know the derivative of the func-
Directional Derivative
tion 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
8
computed from
T
p F x
---------------------- . (8.12)
p
8-5
8 Performance Surfaces and Optimum Points
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
x1 2x 1
F x = = = 1 . (8.15)
x = x 4x 2 2
F x
x2 x = x
x = x
1
T
2 1
p F x 2 0
---------------------- = ------------------------ = ------- = 0 . (8.16)
p 5
2
1
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 di-
rection 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 maxi-
mum. 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 direc-
tions. 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 con-
tour line).
To experiment with directional derivatives, use the MATLAB Neural Net-
work Design Demonstration Directional Derivatives (nnd8dd).
8-6
Minima
2.2 6
2.0
1
1.6
4
0.8
x2 0 0.0
2
0
-1 2
1 2
0 1
x2 0
-1 x1
-1
-2 -2
-2 -1 0 1 2 -2
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 .
8
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 some-
times 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 sca-
lar 0 exists, such that F x F x + x for all x such that x 0 .
8-7
8 Performance Surfaces and Optimum Points
No matter which direction we move away from a weak minimum, the func-
tion cannot decrease, although there may be some directions in which the
function does not change.
2 As an example of local and global minimum points, consider the following
+2
scalar function:
4 2 1
F x = 3x 7x --- x + 6 . (8.17)
2
This function is displayed in Figure 8.3. Notice that it has two strong min-
imum 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-dimen-
sional example of a weak minimum later.
8
4 2 1
F x = 3x 7x --- x + 6
2
6
2 Local Minimum
Global Minimum
0
-2 -1 0 1 2
4
F x = x 2 x 1 + 8x 1 x 2 x 1 + x 2 + 3 . (8.18)
Contour Plot 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
Saddle Point is called a saddle point because of the shape of the surface in the neighbor-
hood 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
Necessary Conditions for Optimality
12
0
4
0
-1 2
1 2
0 1
0
-1
-1
-2 -2
-2 -1 0 1 2 -2
2 2 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
1
6
4
0
0
-1 2
1 2
0 1
0
-1
-1
-2
-2 -1 0 1 2 -2 -2
8-9
8 Performance Surfaces and Optimum Points
F x = F x + x = F x + F x
T
x
x = x
(8.20)
1 T
+ --- x 2F x x + ,
2 x = x
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 neg-
ligible and we can approximate the function as
F x + x F x + F x
T
x . (8.22)
x = x
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
T
F x x 0 . (8.23)
x = x
F x x F x F x x F x .
T
(8.25)
x = x
F x = 0. (8.27)
x = x
8-10
Necessary Conditions for Optimality
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 + . (8.28)
2 x = x
For this to be true for arbitrary x 0 requires that the Hessian matrix be
Positive Definite Matrix positive definite. (By definition, a matrix A is positive definite if
T
z Az 0 (8.30)
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 def-
inite. If all eigenvalues are nonnegative, then the matrix is positive
semidefinite.)
Sufficient Condition A positive definite Hessian matrix is a second-order, sufficient condition for
a strong minimum to exist. It is not a necessary condition. A minimum can
still be strong if the second-order term of the Taylor series is zero, but the
third-order term is positive. Therefore the second-order, necessary condi-
tion for a strong minimum is that the Hessian matrix be positive semi-def-
inite.
2 To illustrate these conditions, consider the following function of two vari-
+2
ables:
4 2
F x = x1 + x2 . (8.32)
3
F x = 4x 1 = 0 . (8.33)
2x 2
8-11
8 Performance Surfaces and Optimum Points
2
2F x x=0
= 12x 1 0 = 0 0 . (8.34)
0 2 0 2
x=0
Quadratic Functions
We will find throughout this text that one type of performance index is uni-
versal the quadratic function. This is true because there are many appli-
cations in which the quadratic function appears, but also because many
functions can be approximated by quadratic functions in small neighbor-
hoods, especially near local minimum points. For this reason we want to
spend a little time investigating the characteristics of the quadratic func-
tion.
Quadratic Function The general form of a quadratic function is
1 T T
F x = --- x Ax + d x + c , (8.35)
2
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 prop-
erties of the gradient:
T T
h x = x h = h , (8.36)
8-12
Quadratic Functions
T T
x Qx = Qx + Q x = 2Qx (for symmetric Q) . (8.37)
F x = Ax + d , (8.38)
2F x = A . (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).
1 T
F x = --- x Ax . (8.40)
2
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)
1 0 0
T 0 2 0
A' = B AB = =
0 0 n
, (8.43)
8-13
8 Performance Surfaces and Optimum Points
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 T
p 2F x p p Ap
---------------------------
2
-.
- = -------------
2
(8.45)
p p
Now define
p = Bc , (8.46)
i ci
2
T T T T T
p Ap c B BB Bc c c
-------------
2
- = ---------------------------------------
T T
- = i------------------
- = -----------
T
=1
n
-. (8.47)
p c B Bc c c
ci
2
i=1
This result tells us several useful things. First, note that this second deriv-
ative is just a weighted average of the eigenvalues. Therefore it can never
be larger than the largest eigenvalue, or smaller than the smallest eigen-
value. In other words,
T
p Ap
2
- max .
min ------------- (8.48)
p
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 T T
c = B p = B z max = 0 0 0 1 0 0 , (8.50)
8-14
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 orthonor-
mal.
If we now substitute z max for p in Eq. (8.47) we obtain
n
i ci
2
T
z max Az max
---------------------------
2
i=1
- = max .
- = ------------------
n
(8.51)
z max
ci
2
i=1
1 T
F x = x 1 + x 2 = --- x 2 0 x .
2 2
(8.52)
2 0 2
2F x = 2 0 , 1 = 2 , z 1 = 1 , 2 = 2 , z 2 = 0 . (8.53)
0 2 0 1
8-15
8 Performance Surfaces and Optimum Points
2
0
0
-1 2
1 2
0 1
0
-1
-1
-2 -2
-2 -1 0 1 2 -2
1 T
F x = x 1 + x 1 x 2 + x 2 = --- x 2 1 x
2 2
(8.54)
2 12
2F x = 2 1 , 1 = 1 , z 1 = 1 , 2 = 3 , z 2 = 1 . (8.55)
1 2 1 1
(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 di-
rection 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
0
1
0
-1 2
1 2
0 1
0
-1
-1
-2
-2 -1 0 1 2 -2 -2
1 2 3 1 2 1 T
F x = --- x 1 --- x 1 x 2 --- x 2 = --- x 0.5 1.5 x . (8.56)
4 2 4 2 1.5 0.5
x = 0 , (8.58)
0
is no longer a strong minimum point, since the Hessian matrix is not posi-
tive definite. Since the eigenvalues are of opposite sign, we know that the
Hessian is indefinite (see [Brog91]). The stationary point is therefore a sad-
dle point. It is a minimum of the function along the first eigenvector (posi-
tive eigenvalue), but it is a maximum of the function along the second
eigenvector (negative eigenvalue).
8-17
8 Performance Surfaces and Optimum Points
0
-4
-8
-1 2
1 2
0 1
0
-1
-1
-2
-2 -1 0 1 2 -2 -2
1 2 1 2 1 T
F x = --- x 1 x 1 x 2 + --- x 2 = --- x 1 1 x . (8.59)
2 2 2 1 1
2F x = 1 1 , = 2 , z = 1 , = 0 , z = 1 . (8.60)
1 1 2 2
1 1 1 1
x1 = x2 , (8.61)
8-18
Quadratic Functions
0
1
0
-1 2
1 2
0 1
0
-1
-1
-2
-2 -1 0 1 2 -2 -2
x = A d .
1
(8.62)
8-19
8 Performance Surfaces and Optimum Points
Summary of Results
Taylor Series
F x = F x + F x x x
T
x = x
1
+ --- x x 2F x x x +
T
2 x = x
Gradient
T
F x =
F x Fx Fx
x1 x2 xn
Hessian Matrix
2 2 2
Fx F x Fx
x1
2 x 1 x 2 x 1 x n
2 2 2
F x Fx Fx
2F x = x 2 x 1 x2
2 x 2 x n
2 2 2
F x F x Fx
x n x 1 x n x 2 2
xn
Directional Derivatives
First Directional Derivative
T
p F x
----------------------
p
8-20
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 sca-
lar 0 exists, such that F x F x + x for all x such that x 0 .
F x = 0 (Stationary Points)
x = x
Second-Order Condition
Quadratic Functions
1 T T
F x = --- x Ax + d x + c
2
Gradient 8
F x = Ax + d
Hessian
2F x = A
Directional Derivatives
T
p Ap
min -------------
2
- max
p
8-21
8 Performance Surfaces and Optimum Points
Solved Problems
P8.1 In Figure 8.1 we illustrated 3 approximations to the cosine func-
tion about the point x = 0 . Repeat that procedure about the point
x = 2 .
The function we want to approximate is
F x = cos x .
2
F x = cos x = cos --- sin --- x --- --- cos --- x ---
1
2 2 2 2 2 2
3
+ --- sin --- x --- +
1
6 2 2
3 5
= x --- + --- x --- --------- x --- +
1 1
2 6 2 120 2
F x F0 x = 0 .
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
3
F x F 3 x = x --- + --- x --- .
1
2 6 2
8-22
Solved Problems
1.5
F1 x
1
0.5
F0 x
0
-0.5
-1 Fx F3 x
-1.5
-6 -4 -2 0 2 4 6
P8.2 Recall the function that is displayed in Figure 8.4, on page 8-9. We
know that this function has two strong minima. Find the second-
order Taylor series expansions for this function about the two min-
ima.
The equation for this function is
4
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 gra-
dient and the Hessian for F x . For the gradient we have
F x 3
x1 4 x 2 x 1 + 8x 2 1
F x = = ,
3
4 x 2 x 1 + 8x 1 + 1
F x
x2
2 2
Fx F x
x1
2 x 1 x 2
2F x =
2 2
F x Fx
x 2 x 1 x2
2
2 2
12 x 2 x 1 12 x 2 x 1 + 8
=
2 2
12 x 2 x 1 + 8 12 x 2 x 1
8-23
8 Performance Surfaces and Optimum Points
1 T
One strong minimum occurs at x = 0.42 0.42 , and the other at
2 T
x = 0.55 0.55 . If we perform the second-order Taylor series expansion
of F x about these two points we obtain:
1 1 T 1 1 1 T 1
F x = F x + F x x x + --- x x 2F x x x
x=x 1
2 x = x1
T
1 8.42 0.42 x 0.42 .
= 2.93 + --- x 0.42
2 0.42 0.42 8.42 0.42
1 T
F x = 4.49 3.7128 3.7128 x + --- x 8.42 0.42 x .
1
2 0.42 8.42
2
Repeating this process for x results in
1 T
F x = 7.41 11.781 11.781 x + --- x 14.71 6.71 x .
2
2 6.71 14.71
The original function and the two approximations are plotted in the follow-
ing figures.
Check the Taylor series expansions at other points using the Neural Net-
work Design Demonstration Vector Taylor Series (nnd8ts2).
12
0
4
0
-1 2
1 2
0 1
0
-1
-1
-2 -2 -2
-2 -1 0 1 2
8-24
Solved Problems
12
0
4
0
-1 2
1 2
0 1
0
-1
-1
-2
-2 -1 0 1 2 -2 -2
1
Figure P8.3 Function F x for Problem P8.2
2
12
0
4
0
-1 2
1 2
0 1
0
-1
-1
-2
-2 -1 0 1 2 -2 -2
2
Figure P8.4 Function F x for Problem P8.2
P8.3 For the function F x given below, find the equation for the line
T
that is tangent to the contour line at x = 0 0 .
2 2 2
F x = 2 + x1 + 5 1 x1 x2
To solve this problem we can use the directional derivative. What is the de-
rivative of F x along a line that is tangent to a contour line? Since the con-
tour 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 equa-
tion for the tangent to the contour line by setting the directional derivative
equal to zero.
First we need to find the gradient:
8-25
8 Performance Surfaces and Optimum Points
2 2
2 2 + x 1 + 10 1 x 1 x 2 1 6 + 12x 1 + 10x 2
F x = = .
2 3
10 1 x 1 x 2 2x 2 20x 2 + 20x 1 x 2 + 20x 2
T
If we evaluate this at x = 0 0 , we obtain
F x = 6 .
0
Now recall that the equation for the derivative of F x in the direction of a
vector p is
T
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 numer-
ator of the directional derivative in the direction of x to zero:
x F x = 0 ,
T
x 6 = 0 , or x 1 = 0 .
T
12
0
4
0
-1 2
1 2
0 1
0
-1
-1
-2 -2 -2
-2 -1 0 1 2
8-26
Solved Problems
4 2 3 2
F x = x --- x 2x + 2x + 4 .
3
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
d2 d2 d2
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
8 Performance Surfaces and Optimum Points
4 2 3 2
F(x) = x --- x 2x + 2x + 4
6 3
0
-2 -1 0 1 2
P8.5 Look back to the function of Problem P8.2. This function has three
stationary points:
2 2
12 x 2 x 1 12 x 2 x 1 + 8
2F x = .
2 2
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 guaran-
tees 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 nega-
tive, the Hessian is indefinite, which would signal a saddle point.
1
If we evaluate the Hessian at x , we find
2F x =
1 8.42 0.42 .
0.42 8.42
1 = 8.84 , 2 = 8.0 ,
1
therefore x must be a strong minimum point.
8-28
Solved Problems
2
If we evaluate the Hessian at x , we find
2F x = 0.87 7.13 .
2
7.13 0.87
1 = 6.26 , 2 = 8.0 ,
2
therefore x must be a saddle point. In one direction the curvature is neg-
ative, and in another direction the curvature is positive. The negative cur-
vature 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
If we evaluate the Hessian at x , we find
3
2F x = 14.7 6.71 .
6.71 14.7
1 = 21.42 , 2 = 8.0 ,
3
therefore x must be a strong minimum point.
Check these results using the Neural Network Design Demonstration Vector
Taylor Series (nnd8ts2).
P8.6 Lets apply the concepts in this chapter to a neural network prob-
lem. Consider the linear network shown in Figure P8.7. Suppose
that the desired inputs/outputs for the network are
p 1 = 2 t 1 = 0.5 p 2 = 1 t 2 = 0 .
8-29
8 Performance Surfaces and Optimum Points
w n a
p
b
1
a = purelin (wp + b)
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 eigenvec-
tors and eigenvalues of the Hessian matrix and use them to sketch the con-
tour plot of the function.
Begin by writing F x as an explicit function of the parameter vector x :
2 2
F x = e1 + e2 ,
where
e 1 = t 1 wp 1 + b e 2 = t 2 wp 2 + b .
where
p1 1
e = t x = t Gx .
p2 1
8-30
Solved Problems
1 T T
F x = --- x Ax + d x + c ,
2
we can see that the performance index for this linear network is a quadrat-
ic function, with
T T T
c = t t , d = 2 G t , and A = 2G G .
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 T T
For
p1 1 2 1 and t = 0.5
G = =
p2 1 1 1 0
we have
1
1 T
x = G G G t = 5 1 1 = 0.167 .
T
1 2 0.5 0.167
2F x = A = 2G G = 10 2 .
T
2 4
To sketch the contour plot we need the eigenvectors and eigenvalues of the
Hessian. For this case we find
1 , = 3.4 z = 0.3 .
1 = 10.6 z 1 = 2 2
0.3 1
Therefore we know that x is a strong minimum. Also, since the first eigen-
value 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
8 Performance Surfaces and Optimum Points
3
0
0
-1 2
1 2
0 1
0
-1
-1
-2 -2 -2
-2 -1 0 1 2
P8.7 There are quadratic functions that do not have stationary points.
This problem illustrates one such case. Consider the following
function:
1 T
F x = 1 1 x + --- x 1 1 x .
2 1 1
2F x = A = 1 1 . (8.63)
1 1
1 1 .
1 = 0 z 1 = , 2 = 2 z 2 =
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 cur-
vature 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 = 1 1 x .
F lin x = 1 ,
1
which means that the linear term is increasing most rapidly in the direc-
tion of this gradient. Since the quadratic term has no curvature in this di-
rection, 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 2
1 2
0 1
0
-1
-1
-2 -2 -2
-2 -1 0 1 2
x = A d ,
1
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
8 Performance Surfaces and Optimum Points
Epilogue
Performance learning is one of the most important classes of neural net-
work learning rules. With performance learning, network parameters are
adjusted to optimize network performance. In this chapter we have intro-
duced tools that we will need to understand performance learning rules. Af-
ter reading this chapter and solving the exercises, you should be able to:
i. Perform a Taylor series expansion and use it to approximate a func-
tion.
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, includ-
ing 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 suc-
ceeding chapters, we will apply these algorithms to the training of neural
networks.
8-34
Further Reading
Further Reading
[Brog91] W. L. Brogan, Modern Control Theory, 3rd Ed., Englewood
Cliffs, NJ: Prentice-Hall, 1991.
This is a well-written book on the subject of linear systems.
The first half of the book is devoted to linear algebra. It also
has good sections on the solution of linear differential equa-
tions and the stability of linear and nonlinear systems. It
has many worked problems.
[Gill81] P. E. Gill, W. Murray, and M. H. Wright, Practical Optimi-
zation, New York: Academic Press, 1981.
As the title implies, this text emphasizes the practical im-
plementation of optimization algorithms. It provides moti-
vation for the optimization methods, as well as details of
implementation that affect algorithm performance.
[Himm72] D. M. Himmelblau, Applied Nonlinear Programming, New
York: McGraw-Hill, 1972.
This is a comprehensive text on nonlinear optimization. It
covers both constrained and unconstrained optimization
problems. The text is very complete, with many examples
worked out in detail.
[Scal85] L. E. Scales, Introduction to Non-Linear Optimization, New
York: Springer-Verlag, 1985.
A very readable text describing the major optimization al-
gorithms, this text emphasizes methods of optimization
rather than existence theorems and proofs of convergence.
Algorithms are presented with intuitive explanations,
along with illustrative figures and examples. Pseudo-code
is presented for most algorithms.
8
8-35
8 Performance Surfaces and Optimum Points
Exercises
E8.1 Consider the following scalar function:
1
F x = -------------------------- .
3 3 1
x --- x ---
4 2
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 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 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
2 1 2
x. F x = 2x 1 2x 1 x 2 + --- x 2 + x 1 + x 2
2
4 1 2
F x = x --- x + 1 ,
2
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 = iv. Plot the function and the approximations using MATLAB.
4
8-37
8 Performance Surfaces and Optimum Points
1 T
F x = --- x 1 3 x + 4 4 x + 2 .
2 3 1
iv. Is your answer to part iii. consistent with your contour plot of part
ii.? Explain.
1 T
F x = --- x 3 2 x + 4 4 x + 2 .
2 2 0
2 1 4
F x = 1 + x 1 + x 2 + --- x .
4 1
3 2 3
F x = --- x + 2x 1 x 2 + x 2 + 4x 1 + 4x 2 .
2 1
8-38
Exercises
F x = x 1 x 2 x 1 + 2x 2 .
E8.13 Recall the function in Problem P8.7. For that function there was no station-
ary point. It is possible to modify the function, by changing only the d vec-
tor, so that a stationary point will exist. Find a new nonzero d vector that
will create a weak minimum.
8-39
Objectives
9 Performance Optimization
Objectives 9-1
Theory and Examples 9-2
Steepest Descent 9-2
Stable Learning Rates 9-6
Minimizing Along a Line 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 net-
works.
9-1
9 Performance Optimization
xk + 1 = xk + k pk , (9.1)
or
x k = x k + 1 x k = k p k , (9.2)
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 possibili-
ties. 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.3)
9-2
Steepest Descent
g k F x . (9.5)
x = xk
We will select an k that is small, but greater than zero. This implies:
T
gk pk 0 . (9.7)
Descent Direction 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 direc-
tion vector. It will be most negative when the direction vector is the nega-
tive 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 . (9.9)
Steepest Descent Using this in the iteration of Eq. (9.1) produces the method of steepest de-
scent:
xk + 1 = xk k gk . (9.10)
For steepest descent there are two general methods for determining the
Learning Rate 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.11)
9-3
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 dis-
cuss the choice of k in more detail in the following examples.
2 Lets apply the steepest descent algorithm to the following function,
+2
2 2
F x = x 1 + 25x 2 , (9.12)
x 0 = 0.5 . (9.13)
0.5
Fx
x1 2x 1
F x = = . (9.14)
50x 2
Fx
x2
g 0 = F x = 1 . (9.15)
x = x0 25
Assume that we use a fixed learning rate of = 0.01 . The first iteration of
the steepest descent algorithm would be
9-4
Steepest Descent
0.5
-0.5
-1
-1 -0.5 0 0.5 1
Note that the steepest descent trajectory, for small learning rate, follows a
path that is always orthogonal to the contour lines. This is because the gra-
dient is orthogonal to the contour lines. (See the discussion on page 8-6.)
How would a change in the learning rate change the performance of the al-
gorithm? If we increase the learning rate to = 0.035 , we obtain the tra-
jectory illustrated in Figure 9.2. Note that the trajectory now oscillates. If
we make the learning rate too large the algorithm will become unstable;
the oscillations will increase instead of decaying.
1
0.5
-0.5
-1
-1 -0.5 0 0.5 1
We would like to make the learning rate large, since then we will be taking
large steps and would expect to converge faster. However, as we can see
from this example, if we make the learning rate too large the algorithm will
become unstable. Is there some way to predict the maximum allowable
learning rate? This is not possible for arbitrary functions, but for quadratic
functions we can set an upper limit.
9-5
9 Performance Optimization
1 T T
F x = --- x Ax + d x + c . (9.18)
2
F x = Ax + d . (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)
or
x k + 1 = I A x k d . (9.21)
I A z i = z i Az i = z i i z i = 1 i z i . (9.22)
1 i 1 . (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
---- . (9.24)
i
Since this must be true for all the eigenvalues of the Hessian matrix we
have
2
----------- . (9.25)
max
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 lo-
cation. This will cause the steps to increase in size at each iteration.
2 Lets apply this result to our previous example. The Hessian matrix for that
+2
quadratic function is
A = 2 0 . (9.26)
0 50
1 = 50 z = 0 .
1 = 2 z 1 = 2 2 (9.27)
0 1
2 2
----------- = ------ = 0.04 . (9.28)
max 50
0.5 0.5
0 0
-0.5 -0.5
-1 -1
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
This example has illustrated several points. The learning rate is limited by
the largest eigenvalue (second derivative) of the Hessian matrix. The algo-
rithm tends to converge most quickly in the direction of the eigenvector cor-
responding to this largest eigenvalue, and we dont want to overshoot the
minimum point by too far in that direction. (Note that in our examples the
initial step is almost parallel to the x 2 axis, which is z 2 .) However, the al-
gorithm will tend to converge most slowly in the direction of the eigenvec-
9-7
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 eigenval-
ues, the steepest descent algorithm will converge slowly.
To experiment with steepest descent on this quadratic function, use the Neu-
ral Network Design Demonstration Steepest Descent for a Quadratic
(nnd9sdq).
F xk + k pk . (9.29)
To do this for arbitrary functions requires a line search, which we will dis-
cuss in Chapter 12. For quadratic functions it is possible to perform the lin-
ear 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 . (9.30)
d k x = xk k x = xk k
A k 2F x . (9.32)
x = xk
1 T
F x = --- x 2 1 x , (9.33)
2 1 2
9-8
Steepest Descent
x0 = 0.8 . (9.34)
0.25
2x 1 + x 2
F x = . (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 = 1.35 . (9.36)
x = x0 0.3
From Eq. (9.31), the learning rate for the first iteration will be
1.35
1.35 0.3
0.3
0 = ---------------------------------------------------------------- = 0.413 . (9.37)
2 1 1.35
1.35 0.3
1 2 0.3
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 orthog-
onal 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 T d
F xk + k pk = F x k + 1 = F x x + k pk
d k d k x = xk + 1 d k k
(9.39)
T T
= F x pk = gk + 1 pk .
x = xk + 1
9-9
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 direc-
tion 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
1
0.5
x2
-0.5
-1
-1 -0.5 0 0.5 1
x1
Newtons Method
The derivation of the steepest descent algorithm was based on the first-or-
der Taylor series expansion (Eq. (9.4)). Newtons method is based on the
second-order Taylor series:
T 1 T
F x k + 1 = F x k + x k F x k + g k x k + --- x k A k x k . (9.40)
2
9-10
Newtons Method
g k + A k x k = 0 . (9.41)
F x
x1 2x 1
F x = = , 2F x = 2 0 . (9.45)
50x 2 0 50
F x
x2
x 0 = 0.5 , (9.46)
0.5
This method will always find the minimum of a quadratic function in one
step. This is because Newtons method is designed to approximate a func-
tion as quadratic and then locate the stationary point of the quadratic ap-
proximation. 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 gener-
ally 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 0.5 1
4
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:
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
2 2
1 1
0 0
-1 -1
-2 -2
-2 -1 0 1 2 -2 -1 0 1 2
T
Figure 9.6 One Iteration of Newtons Method from x 0 = 1.5 0
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. Clear-
ly Newtons method cannot distinguish between a local minimum and a glo-
bal 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 2
1 1
0 0
-1 -1
-2 -2
-2 -1 0 1 2 -2 -1 0 1 2
T
Figure 9.7 One Iteration of Newtons Method from x 0 = 1.5 0
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 ma-
9-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 2
1 1
0 0
-1 -1
-2 -2
-2 -1 0 1 2 -2 -1 0 1 2
T
Figure 9.8 One Iteration of Newtons Method from x 0 = 0.75 0.75
In each of the cases we have looked at so far the stationary point of the qua-
dratic 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 sad-
dle point, however, the saddle point is located very close to the local mini-
mum 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 al-
gorithm converged to the saddle point.
2 2
1 1
0 0
-1 -1
-2 -2
-2 -1 0 1 2 -2 -1 0 1 2
T
Figure 9.9 One Iteration of Newtons Method from x 0 = 1.15 0.75
9-14
Conjugate Gradient
Conjugate Gradient
Quadratic Termination Newtons method has a property called quadratic termination, which
means that it minimizes a quadratic function exactly in a finite number of
iterations. Unfortunately, it requires calculation and storage of the second
derivatives. When the number of parameters, n , is large, it may be imprac-
tical to compute all of the second derivatives. (Note that the gradient has
2
n elements, while the Hessian has n elements.) This is especially true
with neural networks, where practical applications can require several
hundred to many thousand weights. For these cases we would like to have
methods that require only first derivatives but still have quadratic termi-
nation.
Recall the performance of the steepest descent algorithm, with linear
searches at each iteration. The search directions at consecutive iterations
were orthogonal (see Figure 9.4). For quadratic functions with elliptical
9-15
9 Performance Optimization
k j. (9.52)
T
p k Ap j = 0
where the last equality holds because the eigenvectors of a symmetric ma-
trix are mutually orthogonal. Therefore the eigenvectors are both conju-
gate 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 deriva-
tives.
It can be shown (see [Scal85] or [Gill81]) that if we make a sequence of ex-
act 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
F x = Ax + d , (9.54)
2F x = A . (9.55)
9-16
Conjugate Gradient
g k = g k + 1 g k = Ax k + 1 + d Ax k + d = A x k , (9.56)
x k = x k + 1 x k = k p k , (9.57)
T T T
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 succes-
sive 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 vec-
tor 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 de-
scent direction:
p0 = g0 . (9.59)
pk = gk + k pk 1 . (9.60)
9-17
9 Performance Optimization
1 T
F x = --- x 2 1 x , (9.64)
2 1 2
x0 = 0.8 . (9.65)
0.25
2x 1 + x 2
F x = . (9.66)
x 1 + 2x 2
As with steepest descent, the first search direction is the negative of the
gradient:
= 1.35 .
T
p 0 = g 0 = F x (9.67)
x = x0 0.3
9-18
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 . (9.68)
2 1 1.35
1.35 0.3
1 2 0.3
0.11
T 0.11 0.5
g1 g1 0.5 0.2621
1 = ----------
T
- = -------------------------------------------- = ---------------- = 0.137 , (9.71)
g0 g0 1.35
1.9125
1.35 0.3
0.3
using the method of Fletcher and Reeves (Eq. (9.62)). The second search di-
rection is then computed from Eq. (9.60):
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 . (9.73)
0.325
2 1 0.295
0.295 0.459
1 2 0.459
9-19
9 Performance Optimization
0.5
-0.5
-1
-1 -0.5 0 0.5 1
9-20
Summary of Results
Summary of Results
or
x k = x k + 1 x k = k p k
Where g k F x
x = xk
Newtons Method 9
1
xk + 1 = xk Ak gk
Where A k 2F x
x = xk
9-21
9 Performance Optimization
p0 = g0
pk = gk + k pk 1
T T T
g k 1 g k gk gk g k 1 g k
k = --------------------------
T
- or k = ----------------------
T
- or k = ----------------------
T
-
g k 1 p k 1 gk 1 gk 1 gk 1 gk 1
Where g k F x and g k = g k + 1 g k .
x = xk
9-22
Solved Problems
Solved Problems
P9.1 We want to find the minimum of the following function:
2 2
F x = 5x 1 6x 1 x 2 + 5x 2 + 4x 1 + 4x 2 .
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 stan-
dard form (see Eq. (8.35)):
1 T 1 T
F x = --- x Ax + d x + c = --- x 10 6 x + 4 4 x .
T
2 2 6 10
2F x = A = 10 6 .
6 10
1 = 4 , z 1 = 1 , 2 = 16 , z 2 = 1 .
1 1
F x = Ax + d = 10 6 x + 4 = 0 .
6 10 4 0
Therefore
9-23
9 Performance Optimization
1
x = 10 6 4 = 1 .
6 10 4 1
The contours will be elliptical, centered at x , with long axis in the direc-
tion 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 0
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 Hes-
sian matrix:
2
----------- .
max
2
------ = 0.125 .
16
9-24
Solved Problems
0 0
-1 -1
-2 -2
-3 -3
-3 -2 -1 0 -3 -2 -1 0
P9.2 Consider again the quadratic function of Problem P9.1. Take two
steps of the steepest descent algorithm, minimizing along a line at
each step. Use the following initial condition:
T
x0 = 0 2 .
F x = Ax + d = 10 6 x + 4 .
6 10 4
g 0 = F x 0 = Ax 0 + d = 10 6 0 + 4 = 16 .
6 10 2 4 16
p 0 = g 0 = 16 .
16
To minimize along a line, for a quadratic function, we can use Eq. (9.31):
16
T 16 16
g0 p0 16 512
0 = ---------------
T
- = -------------------------------------------------------- = ------------ = 0.0625 .
p 0 Ap 0 10 6 16
8192
16 16
6 10 16
9-25
9 Performance Optimization
x1 = x0 0 g0 = 0 0.0625 16 = 1 .
2 16 1
g 1 = F x 1 = Ax 1 + d = 10 6 1 + 4 = 0 .
6 10 1 4 0
-1
-2
-3
-3 -2 -1 0
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 di-
rection is an eigenvector, the steepest descent algorithm will always locate
the minimum in one iteration. What would this imply about the eigenval-
ues of the Hessian matrix?
p 1 = 2 t 1 = 0.5 p 2 = 1 t 2 = 0
9-26
Solved Problems
w n a
p
b
1
a = purelin (wp + b)
1 T T
F x = --- x Ax + d x + c ,
2
where
d = 2 G t = 2 2 1 0.5 = 2 ,
T
1 1 0 1
A = 2G G = 10 2 .
T
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
x 1 = x 0 g 0 = 1 0.05 10 = 0.5 .
1 5 0.75
The remaining iterations are displayed in Figure P9.5. The algorithm con-
T
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 .
-1
-2
-2 -1 0 1 2
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 algo-
rithm until convergence was achieved. In Chapter 10 we will introduce an
adaptive algorithm, based on steepest descent, for training linear net-
works. 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
The first step is to find the gradient and the Hessian matrix. The gradient
is given by
F x
x1 2 2
x 1 x 1 + 2x 2 + 4 2x 1 1
F x = = e ,
4x 2
F x
x2
2 2
Fx Fx
x1
2 x 1 x 2
2F x =
2 2
Fx Fx
x 2 x 1 x2
2
2
2 2
x 1 x 1 + 2x 2 + 4 4x 1 4x 1 + 3 2x 1 1 4x 2
= e
2
2x 1 1 4x 2 16x 2 + 4
6
g 0 = F x = 0.163 10 ,
x = x0 6
1.302 10
and
7 7
A 0 = 2F x = 0.049 10 0.130 10 .
x = x0 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
1
7 7 6
g 0 = 1 0.049 10 0.130 10 0.163 10 0.971
1
x1 = x0 A0 =
2 7 7 6 1.886
0.130 10 1.107 10 1.302 10
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
x 1 x 1 + 2x 2 + 4 = --- x Ax + d x + c = --- x 2 0 x + 1 0 x + 4 .
2 2 T
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 1 = 0.5 .
1
0 4 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 approxi-
T
mated by a quadratic function in the neighborhood of x 0 = 1 2 .
For this problem Newtons method will converge to the true minimum
point, but it will take many iterations. The trajectory for Newtons method
is illustrated in Figure P9.6.
-1
-2
-2 -1 0 1 2
9-30
Solved Problems
1 T
F x = --- x 1 1 x .
2 1 1
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
F x = Ax + d = 1 1 x
1 1
2F x = A = 1 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 learn-
ing 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
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. Steep-
est descent converges to a minimum point (weak minimum), while New-
tons 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.
0.5
-0.5
-1
-1 -0.5 0 0.5 1
Figure P9.7 Steepest Descent Trajectory for Problem P9.5 with = 0.1
Fx 2 2
x1 3x 1 + x 2 2x 1 x 2
F x = = ,
2
Fx x 1 2x 1 x 2
x2
9-32
Solved Problems
2
6x 1 2x 2 1 4x 1 x 2
2F x = .
2
1 4x 1 x 2 2x 1
g 0 = F x = 2 ,
x = x0 1
A 0 = 2F x = 4 3 .
x = x0 3 2
1 3 2 1 1.1176
T 1 T
F x = F x 0 + x 0 F x 0 + g 0 x 0 + --- x 0 A 0 x 0 .
2
1 T
F x 2 + 1 4 x + --- x 4 3 x .
2 3 2
9-33
9 Performance Optimization
1 1
0 0
-1 -1
-2 -2
-2 -1 0 1 2 -2 -1 0 1 2
T
Figure P9.8 One Iteration of Newtons Method from x 0 = 1 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
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
10
T 10 5
g0 p0 5 125
0 = ---------------
T
- = ----------------------------------------------------- = ------------ = 0.0962 .
p 0 Ap 0 10 2 10
1300
10 5
2 4 5
x 1 = x 0 + 0 p 0 = 1 + 0.0962 10 = 0.038 .
1 5 0.519
Now we need to find the second search direction from Eq. (9.60). This re-
quires the gradient at x 1 :
g 1 = F x = 10 2 0.038 + 2 = 0.577 .
x = x1 2 4 0.519 1 1.154
0.577
T 10.577 3.846
g 0 g 1 1.154 1.665
1 = --------------
T
= ----------------------------------------------------------------- = ------------- = 0.0133 ,
g0 g0 10
125
10 5
5
using the method of Polak and Ribire (Eq. (9.63)). (The other two methods
for computing 1 will produce the same results for a quadratic function.
You may want to try them.) The second search direction is then computed
from Eq. (9.60):
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
9-35
9 Performance Optimization
-1
-2
-2 -1 0 1 2
aj pj = 0,
j=0
aj pj a j pk Apj
T T T
pk A = = a k p k Ap k = 0 ,
j=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 calcu-
lation 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 de-
scent is that training times are generally longer than for other algorithms.
This is especially true when the eigenvalues of the Hessian matrix, for qua-
dratic functions, have a wide range of magnitudes.
Newtons method is generally much faster than steepest descent. For qua-
dratic functions it will locate a stationary point in one iteration. One disad-
vantage 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 stan-
dard algorithm.
The conjugate gradient algorithm is something of a compromise between
steepest descent and Newtons method. It will locate the minimum of a qua-
dratic function in a finite number of iterations, but it does not require cal-
culation 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 ap-
proximate steepest descent algorithm, Widrow-Hoff learning, can be used
to train linear networks. In Chapter 11 we generalize Widrow-Hoff learn-
ing to train multilayer networks. In Chapter 12 the conjugate gradient al-
gorithm, and a variation of Newtons method, are used to speed up the
training of multilayer networks.
9-37
9 Performance Optimization
Further Reading
[Batt92] R. Battiti, First and Second Order Methods for Learning:
Between Steepest Descent and Newtons Method, Neural
Computation, Vol. 4, No. 2, pp. 141-166, 1992.
This article reviews the latest developments in uncon-
strained optimization using first and second derivatives.
The techniques discussed are those that are most suitable
for neural network applications.
[Brog91] W. L. Brogan, Modern Control Theory, 3rd Ed., Englewood
Cliffs, NJ: Prentice-Hall, 1991.
This is a well-written book on the subject of linear systems.
The first half of the book is devoted to linear algebra. It also
has good sections on the solution of linear differential equa-
tions and the stability of linear and nonlinear systems. It
has many worked problems.
[Gill81] P. E. Gill, W. Murray and M. H. Wright, Practical Optimi-
zation, New York: Academic Press, 1981.
As the title implies, this text emphasizes the practical im-
plementation of optimization algorithms. It provides moti-
vation for the optimization methods, as well as details of
implementation that affect algorithm performance.
[Himm72] D. M. Himmelblau, Applied Nonlinear Programming, New
York: McGraw-Hill, 1972.
This is a comprehensive text on nonlinear optimization. It
covers both constrained and unconstrained optimization
problems. The text is very complete, with many examples
worked out in detail.
[Scal85] L. E. Scales, Introduction to Non-Linear Optimization, New
York: Springer-Verlag, 1985.
A very readable text describing the major optimization al-
gorithms, this text emphasizes methods of optimization
rather than existence theorems and proofs of convergence.
Algorithms are presented with intuitive explanations,
along with illustrative figures and examples. Pseudo-code
is presented for most algorithms.
9-38
Exercises
Exercises
E9.1 In Problem P9.1 we found the maximum stable learning rate for the steep-
est 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?
1 T
F x = --- x 6 2 x + 1 1 x .
2 2 6
2 2
F x = x 1 + 2x 2 ,
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
E9.4 For the functions given in Exercise E8.3 perform two iterations of the
2+2
steepest descent algorithm with linear minimization, starting from the ini-
T
ans = tial guess x 0 = 1 1 . Write MATLAB M-files to check your answer.
4
1 T
F x = --- x 3 2 x + 4 4 x
2 2 0
ii. Is this point a minimum point? Does it satisfy the first and second
order conditions?
iii. Perform one iteration of Newton's method from the initial guess
T
x 0 = 0.5 0 .
9-40
Exercises
1 T
F x = --- x 7 9 x + 16 8 x
2 9 17
iii. Did you reach the minimum of the function after the Newton step of
part (ii)? Explain.
iv. From the initial guess in part ii, trace the path of steepest descent,
with very small learning rate, on your contour plot from part (i). Ex-
plain how you determined the path. Will steepest descent eventual-
ly converge to the same result you found in part (ii)? Explain.
2 1 4
F x = 1 + x 1 + x 2 + --- x .
4 1
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
Theory and Examples 10-2
ADALINE Network 10-2
Single ADALINE 10-3
Mean Square Error 10-4
LMS Algorithm 10-7
Analysis of Convergence 10-9
Adaptive Filtering 10-13
Adaptive Noise Cancellation 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 learn-
ing, in which a network is trained to optimize its performance. In this chap-
ter 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 im-
portant 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 algo-
rithm for multilayer networks, which is presented in Chapter 11
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
p a
Rx1 W Sx1
SxR n
Sx1
1 b
Sx1
R S
a = purelin (Wp + b)
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 T
a i = purelin n i = purelin iw p + b i = iw p + b i , (10.2)
w i 1
w i 2
iw =
w i R
. (10.3)
Single ADALINE
To simplify our discussion, lets consider a single ADALINE with two in-
puts. The diagram for this network is shown in Figure 10.2.
The output of the network is given by
T T
a = purelin n = purelin 1w p + b = 1w p + b
(10.4)
T
= 1w p + b = w 1 1 p 1 + w 1 2 p 2 + b .
10-3
10 Widrow-Hoff Learning
p1 w1,1
n a
p2
w1,2 b
1
a = purelin (Wp + b)
p2
a<0 a>0
-b/w1,2
1w
1 w Tp + b = 0
p1
-b/w1,1
10-4
Mean Square Error
{p 1, t 1} { p 2, t 2} {p Q, tQ} , (10.5)
The LMS algorithm will adjust the weights and biases of the ADALINE in
order to minimize the mean square error, where the error is the difference
between the target output and the network output. In this section we want
to discuss this performance index. We will consider first the single-neuron
case.
To simply our development, we will lump all of the parameters we are
adjusting, including the bias, into one vector:
x = 1w . (10.6)
b
z = p . (10.7)
1
T
a = 1w p + b , (10.8)
can be written as
T
a = x z. (10.9)
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 ex-
pectation, which becomes a time-average for deterministic signals. See
[WiSt85].) We can expand this expression as follows:
2
F x = E t 2tx T z + x T zz x
T 10
2 T
= E t 2x T E tz + x T E zz x . (10.11)
10-5
10 Widrow-Hoff Learning
where
2 T
c = E t , h = E tz and R = E zz . (10.13)
Here the vector h gives the cross-correlation between the input vector and
Correlation Matrix 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:
T 1 T
F x = c + d x + --- x Ax . (10.14)
2
We can see that the mean square error performance index for the ADA-
LINE 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 glo-
bal 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
F x = c + d x + --- x Ax = d + Ax = 2h + 2Rx .
T 1 T
(10.16)
2
2h + 2Rx = 0 . (10.17)
10-6
LMS Algorithm
x = R h .
1
(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 vec-
tors determine whether or not a unique solution exists.
LMS Algorithm
Now that we have analyzed our performance index, the next step is to de-
sign 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 algo-
rithm, 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
F x = t k a k = e k ,
2 2
(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 es-
timate of the form:
2
F x = e k . (10.20)
Stochastic Gradient This is sometimes referred to as the stochastic gradient. When this is used
in a gradient descent algorithm, it is referred to as on-line or incremental
learning, since the weights are updated as each input is presented to the
network.
2
The first R elements of e k are derivatives with respect to the network
weights, while the R + 1 st element is the derivative with respect to the bi-
as. Thus we have
2
2 e k e k
e k j = --------------- = 2e k ------------- for j = 1 2 R , (10.21)
w 1 j w 1 j
and
2
2 e k e k
e k R + 1 = --------------- = 2e k ------------- . (10.22)
b b
10-7
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 :
e k t k a 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 . (10.24)
w 1 j
e k
------------- = 1 . (10.25)
b
Note that p j k and 1 are the elements of the input vector z , so the gradi-
ent 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 algo-
rithm. From Eq. (9.10) the steepest descent algorithm, with constant learn-
ing rate, is
x k + 1 = x k F x . (10.27)
x = xk
If we substitute F x , from Eq. (10.26), for F x we find
x k + 1 = x k + 2e k z k , (10.28)
or
1w k + 1 = 1w k + 2e k p k , (10.29)
and
b k + 1 = b k + 2e k . (10.30)
10-8
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 algo-
rithm.
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 up-
date 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 . (10.32)
LMS Algorithm The LMS algorithm can be written conveniently in matrix notation:
T
W k + 1 = W k + 2e k p k , (10.33)
and
b k + 1 = b k + 2e k . (10.34)
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
This is the minimum mean square error E ek solution, as we saw in Eq.
(10.18).
Recall the LMS algorithm (Eq. (10.28)):
x k + 1 = x k + 2e k z k . (10.36)
10-9
10 Widrow-Hoff Learning
E x k + 1 = E x k + 2E e k z k . (10.37)
Since x k is independent of z k :
E x k + 1 = E x k + 2 h RE x k . (10.40)
E x k + 1 = I 2R E x k + 2h . (10.41)
1 2 i 1 . (10.42)
or
0 1 max . (10.44)
E x ss = I 2R E x ss + 2h , (10.45)
or
E x ss = R h = x .
1
(10.46)
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 To test the ADALINE network and the LMS algorithm consider again the
+2
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
1 1
p1 = 1 t1 = 1 p2 = 1 t2 = 1 . (10.48)
1 1
If we assume that the input vectors are generated randomly with equal
probability, we can compute the input correlation matrix:
T 1 T 1 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 . (10.49)
2 2
1 1 1 0 1
1 1
----------- = ------- = 0.5 . (10.51)
max 2.0
10-11
10 Widrow-Hoff Learning
1
a 0 = W 0 p 0 = W 0 p 1 = 0 0 0 1 = 0 , (10.52)
1
and
e 0 = t 0 a 0 = t1 a 0 = 1 0 = 1 . (10.53)
According to plan, we will next present the apple, p 2 , and its target of 1:
1
a 1 = W 1 p 1 = W 1 p 2 = 0.4 0.4 0.4 1 = 0.4 , (10.55)
1
1
a 2 = W 2 p 2 = W 2 p 1 = 0.16 0.96 0.16 1 = 0.64 . (10.58)
1
10-12
Adaptive Filtering
The error is
W = 0 1 0 . (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 deci-
sion boundary that we designed in Chapter 3 for the apple/orange problem.
This boundary falls halfway between the two reference patterns. The per-
ceptron rule did not produce such a boundary. This is because the percep-
tron rule stops as soon as the patterns are correctly classified, even though
some patterns may be close to the boundaries. The LMS algorithm mini-
mizes the mean square error. Therefore it tries to move the decision bound-
aries 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 fil-
tering, where it is still used extensively. In this section we will demonstrate
an adaptive filtering example.
In order to use the ADALINE network as an adaptive filter, we need to in-
Tapped Delay Line troduce 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 cur-
rent time and at delays of from 1 to R 1 time steps.
10-13
10 Widrow-Hoff Learning
D
p2(k) = y(k - 1)
D
pR(k) = y(k - R + 1)
a k = purelin Wp + b = w 1 i y k i + 1 + b . (10.62)
i=1
Inputs ADALINE
y(k)
w1,1
D
w1,2
n(k) a(k)
D
SxR
b
1
D w1,R
10-14
Adaptive Filtering
If you are familiar with digital signal processing, you will recognize the net-
work 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.
Noise Path
Filter
Graduate
Student
v a
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 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 two-
input filter can attenuate and phase-shift the noise v in the desired way.
The filter is shown in Figure 10.7.
Inputs ADALINE
v(k) w1,1
n(k) a(k)
D w1,2
SxR
In our case the input vector is given by the current and previous values of
the noise source:
z k = vk , (10.64)
v k 1
while the target is the sum of the current signal and filtered noise:
t k = s k + mk . (10.65)
2
R = Ev k E v k v k 1 , (10.66)
2
E v k 1 v k E v k 1
10-16
Adaptive Filtering
and
h = E s k + m k v k . (10.67)
E s k + m k v k 1
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
and the filtered noise that contaminates the EEG is the noise source atten-
uated by a factor of 10 and shifted in phase by 2 :
2k
m k = 0.12 sin --------- + --- . (10.69)
3 2
2 2
E v k 1 = E v k = 0.72 , (10.71)
3
2 k 1
1.2 sin --------- 1.2 sin -----------------------
1 2k
E v k v k 1 = ---
3 3 3
k=1
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.74)
10-17
10 Widrow-Hoff Learning
Here the first term on the right is zero because s k and v k are indepen-
dent and zero mean. The second term is also zero:
3
2k
0.12 sin --------- + --- 1.2 sin --------- = 0
1 2k
E m k v k = --- (10.75)
3 3 2 3
k=1
E s k + m k v k 1 = E s k v k 1
+ E m k v 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 eval-
uated as follows:
3
2k 2 k 1
0.12 sin --------- + --- 1.2 sin -----------------------
1
E m k v k 1 = ---
3 3 2 3
k=1
= 0.0624 . (10.77)
Thus, h is
h = 0 . (10.78)
0.0624
The minimum mean square error solution for the weights is given by Eq.
(10.18):
1
x = R h = 0.72 0.36 0 = 0.0578 .
1
(10.79)
0.36 0.72 0.0624 0.1156
Now, what kind of error will we have at the minimum solution? To find this
error recall Eq. (10.12):
T T
F x = c 2x h + x Rx . (10.80)
2 2
= E s k + 2E s k m k + E m k . (10.81)
10-18
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 1 0.2
2 2 3
E s k = ------- s ds = ---------------s = 0.0133 . (10.82)
0.4 3 0.4 0.2
0.2
so that
Substituting x , h and R into Eq. (10.80), we find that the minimum mean
square error is
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 0
-1
-2
-2 -1 0 1 2
w 1 1
10-19
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
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
-1
-2
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
Time
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 Cancel-
lation (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 junc-
tion 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 de-
vice. 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.
+
Transmission
Line
-
Adaptive Adaptive
Phone Hybrid Hybrid Phone
Filter Filter
-
Transmission
Line +
10-21
10 Widrow-Hoff Learning
Summary of Results
ADALINE
Input Linear Neuron
p a
Rx1 W Sx1
SxR n
Sx1
1 b
Sx1
R S
a = purelin (Wp + b)
Where x = 1w and z = p .
b 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
D
p2(k) = y(k - 1)
D
pR(k) = y(k - R + 1)
y(k)
w1,1
D
w1,2
n(k) a(k)
D
SxR
b
1
D w1,R
10-23
10 Widrow-Hoff Learning
Solved Problems
P10.1 Consider the ADALINE filter in Figure P10.1.
Inputs ADALINE
y(k)
w1,1
D w1,2 n(k) a(k)
SxR
D w1,3
w 1 1 = 2 w 1 2 = 1 w 1 3 = 3 ,
y k = 0 0 0 5 4 0 0 0
where y 0 = 5 , y 1 = 4 , etc.
i. What is the filter output just prior to k = 0 ?
ii. What is the filter output from k = 0 to k = 5 ?
iii. How long does y 0 contribute to the output?
i. Just prior to k = 0 three zeros have entered the filter, and the output is
zero.
ii. At k = 0 the digit 5 has entered the filter, and it will be multiplied by
w 1 1 , which has the value 2, so that a 0 = 10 . This can be viewed as the
matrix operation:
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
4
a 1 = Wp 1 = 2 1 3 5 = 13
0
0
a 2 = Wp 2 = 2 1 3 4 = 19
5
0 0
a 3 = Wp 3 = 2 1 3 0 = 12 , a 4 = Wp 4 = 2 1 3 0 = 0 .
4 0
T
Category II: p3 = 2 2 .
10-25
10 Widrow-Hoff Learning
T
Category IV: p3 = 1 0 .
p3
I p1 II
p2
b = 3 , w 1 1 = 1 , w 1 2 = 1 ,
10-26
Solved Problems
p1
p3
p2
1 t = 1 , p = 1 t = 1 .
p1 = 1 2 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. Re-
call from Eq. (10.11) that the performance index can be written as
T T
F x = c 2x h + x Rx .
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
10-27
10 Widrow-Hoff Learning
T T T
R = E zz = p 1 p 1 0.5 + p 2 p 2 0.5
= 0.5 1 1 1 + 1 1 1 = 1 0
1 1 0 1
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 2
= 1 2w 1 2 + w 1 1 + w 1 2
0 1 1 1
w 1 2 1
-1
-2
-3 -2 -1 0 1 2 3
w 1 1
10-28
Solved Problems
P10.4 Consider the system of Problem P10.3 again. Train the network us-
ing 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
W 1 = W 0 + 2e 0 p 0 = 0 0 + 2 --- 1 1 1 = 1
T 1 1
4 --- --- .
2 2
1w
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
--- --- = 0 ,
2 2 1
e 1 = t 1 a 1 = 1 0 = 1 ,
W 2 = W 1 + 2e 1 p 1 = 1
T 1 1- 1
1w
--- --- + 2 --
4 1 1 = 0 1 .
2 2
a>0
The decision boundary associated with these weights is shown to the left.
a<0 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?)
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 algo-
rithm?
The LMS convergence is determined by the learning rate , which should
2+2
not exceed the reciprocal of the largest eigenvalue of R . We can determine
ans = this limit by finding these eigenvalues using MATLAB.
4
10-29
10 Widrow-Hoff Learning
D=
1 0
0 1
The diagonal terms of matrix D give the eigenvalues, 1 and 1, while the col-
umns 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 .
10-30
Solved Problems
Inputs ADALINE
t(k) = y(k)
y(k) D w1,1
n(k) a(k)
+
D w1,2
SxR
- e(k)
z k = pk = yk 1 .
yk 2
Now consider the performance index. Recall from Eq. (10.12) that
T T
F x = c 2x h + x Rx .
2
T
R = E zz = E y k 1 y k 1 y k 2
2
y k 1 y k 2 y k 2
Cy 0 Cy 1 3 1
= =
Cy 1 Cy 0 1 3
Cy 1
h = E t z = E y k y k 1 = = 1 .
y k y k 2 Cy 2 1
10-31
10 Widrow-Hoff Learning
1
x = R h =
1 3 1 1 = 3 8 1 8 1 = 1 2 .
1 3 1 4 8 3 8 1 1 2
2
F x = A = 2R = 6 2 .
2 6
6 2 2
= 12 + 32 = 8 4 .
A I =
2 6
Thus,
1 = 4 2 = 8 .
A I v = 0 .
For 1 = 4 ,
2 2 v = 0 v1 = 1 ,
1
2 2 1
and for 2 = 8 ,
2 2 v = 0 v2 = 1 .
2
2 2 1
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 small-
est magnitude. The ellipses will be centered at x . The contour plot is
shown in Figure P10.6.
10-32
Solved Problems
w 1 2 0
-1
-2
-2 -1 0 1 2
w 1 1
2 max = 2 8 = 0.25 .
0.5
w 1 2 0
x2
-0.5
-1
-1 -0.5 0 0.5 1
w 1x1 1
10-33
10 Widrow-Hoff Learning
Noise Path
Filter
v a
Adaptive
Filter
Airplane Engine
Noise Source
10-34
Solved Problems
class 1: p 1 = 1 p 2 = 1 , class 2: p 3 = 2 p 4 = 2 ,
1 2 1 0
1 p = 2 .
class 3: p 5 = 1 p 6 = 2 , class 4: p7 = 8
2 1 1 2
1
3
1 t = 1 p = 1 t = 1 p = 2 t = 1
p1 = 1 2 2 3 3
1 1 2 1 1 1
2 t = 1 p = 1 t = 1 p = 2 t = 1
p4 = 4 5 5 6 6
0 1 2 1 1 1
1 t = 1 p = 2 t = 1
p7 = 7 8 8
1 1 2 1
10-35
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
b 1 = b 0 + 2e 0 = 1 + 2 0.04 3 = 0.76 .
1 3 0.76
a 1 = purelin (W 1 p 1 + b 1 )
= purelin 0.76 0.24 1 + 0.76 = 1.04
0.24 0.76 2 0.76 2.04
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
1
3
Patterns
T G F
Targets 60 0 -60
10-37
10 Widrow-Hoff Learning
p a
16 x 1
W 1x1
1 x 16
n
1x1
1 b
1x1
16 1
a = purelin (Wp + b)
Figure P10.12 Adaptive Pattern Classifier
(Widrow and Hoff built their own machine to realize this ADALINE. Ac-
cording 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 pub-
lished 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).
4
x 10 Convergence of Error
2.5
0.5
0
0 10 20 30 40 50 60 70 80 90 100
Time Steps
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 percep-
tron 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 percep-
tron 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 cover-
age of dynamic networks, which are widely used for filtering, prediction
and control.)
In addition to its importance as a practical solution to many adaptive fil-
tering problems, the LMS algorithm is also important because it is the fore-
runner 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 er-
ror. 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: Founda-
tions of Research, Cambridge, MA: MIT Press, 1989.
Neurocomputing is a fundamental reference book. It con-
tains 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 Sig-
nal Processing, Reston VA: Reston, 1984
[WiHo60] B. Widrow, M. E. Hoff, Adaptive switching circuits, 1960
IRE WESCON Convention Record, New York: IRE Part 4,
pp. 96104.
This seminal paper describes an adaptive perceptron-like
network that can learn quickly and accurately. The authors
assumed that the system had inputs, a desired output clas-
sification for each input, and that the system could calcu-
late 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].
[WiSt 85] B. Widrow and S. D. Stearns, Adaptive Signal Processing,
Englewood Cliffs, NJ: Prentice-Hall, 1985.
This informative book describes the theory and application
of adaptive signal processing. The authors include a review
of the mathematical background that is needed, give de-
tails on their adaptive algorithms, and then discuss practi-
cal information about many applications.
[WiWi 88] B. Widrow and R. Winter, Neural nets for adaptive filter-
ing and adaptive pattern recognition, IEEE Computer
Magazine, March 1988, pp. 2539.
This is a particularly readable paper that summarizes ap-
plications of adaptive multilayer neural networks. The net-
works are applied to system modeling, statistical
prediction, echo cancellation, inverse modeling and pattern 10
recognition.
10-41
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 ,
y k = 0 0 0 1 1 2 0 0 .
Inputs ADALINE
y(k)
w1,1
D w1,2 n(k) a(k)
SxR
D w1,3
Class I Class II
10-42
Exercises
E10.3 Suppose that we have the following two reference patterns and their tar-
gets:
1 t = 1 , p = 1 t = 1 .
p1 = 1 2 2
1 1
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 = 1 2 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 = iii. Write a MATLAB M-file to implement the LMS algorithm for this
4 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 = ii. Write a MATLAB M-file to implement the LMS algorithm for this
4 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 Widrow-Hoff Learning
1 1
.
1 2
Category II consists of
0
4 .
1 1
E10.7 Suppose that we have the following three reference patterns and their tar-
gets:
3 t = 6 t = 6 t =
p1 = 1 75 , p2 = 2 75 , p3 = 3 75 .
6 3 3
10-44
Exercises
iv. Sketch the trajectory of the LMS algorithm on your contour plot. As-
sume 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 tar-
gets:
1 t = 2 t =
p1 = 1 1 , p2 = 2 1 .
2 1
4 t = 5 , p = 2 t = 2 , p = 4 t = 9 .
p1 = 1 2 2 3 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
T
rate of = 0.1 . Start from the initial weights
x0 = 0 0 .
10
10-45
10 Widrow-Hoff Learning
2 t = 1 , p = 4 t = 1 , p = 4 t = 1 .
p1 = 1 2 2 3 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.
1 t = 1 p = 2 t = 1 p = 0 t = 1 p = 1 t = 1
p1 = 1 2 2 3 3 4 4
2 1 1 0
E10.12 Suppose that we have the following three reference patterns and their tar-
gets:
2 t = 4 t = 2 t =
p1 = 1 26 , p2 = 2 26 , p3 = 3 26 .
4 2 2
10-46
Exercises
Inputs ADALINE
t(k) = y(k)
y(k) D w1,1
n(k) a(k)
+
D w1,2
SxR
- e(k)
Cy n = E y k y k + n .
10-47
10 Widrow-Hoff Learning
y k = sin ------ .
k
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 = vi. Write a MATLAB M-file to implement the LMS algorithm for this
4 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 op-
timal 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 Neu-
ral Network Design Demonstration Linear Pattern Classification (nnd10lc).)
10-48
Objectives
11 Backpropagation
Objectives 11-1
Theory and Examples 11-2
Multilayer Perceptrons 11-2
Pattern Classification 11-3
Function Approximation 11-4
The Backpropagation Algorithm 11-7
Performance Index 11-8
Chain Rule 11-9
Backpropagating the Sensitivities 11-11
Summary 11-13
Example 11-14
Batch vs. Incremental Training 11-17
Using Backpropagation 11-18
Choice of Network Architecture 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 algo-
rithm of Chapter 10. This generalization, called backpropagation, can be
used to train multilayer networks. As with the LMS learning law, back-
propagation 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 lin-
ear 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 demonstra-
tion of how to use the chain rule.
11-1
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 per-
ceptron in Figure 11.1. Note that we have simply cascaded three percep-
tron 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 net-
work. Each layer may have a different number of neurons, and even a dif-
ferent 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 2 3
RS S S . (11.1)
11-2
Multilayer Perceptrons
1 1 1
pR n1S 1 a1S 1 n2S 2 a2S 2 n3S 3 a3S 3
w 1 1
S ,R f1
w 2S 2 , S 1
f2
w 3S 3, S 2
f3
b1S 1 b2S 2 b3S 3
1 1 1
Pattern Classification
2 To illustrate the capabilities of the multilayer perceptron for pattern clas-
+2
sification, consider the classic exclusive-or (XOR) problem. The input/tar-
get pairs for the XOR gate are
0 t = 0 p = 0 t = 1 p = 1 t = 1 p = 1 t = 0 .
p1 = 1 2 2 3 3 4 4
p2 p4 0 1 0 1
This problem, which is illustrated graphically in the figure to the left, was
p p used by Minsky and Papert in 1969 to demonstrate the limitations of the
1 3
single-layer perceptron. Because the two categories are not linearly sepa-
rable, 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
11-3
11 Backpropagation
AND operation. The decision boundaries for each first-layer neuron are
shown in Figure 11.2.
1 w1
2w1
2 n11 a11
p1
2
1 n21 a21
1
-1
-1 n2
1 a2
1
1 -1.5
p2
-1 1
1.5
1
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 appropri-
ate output signal. The following example will illustrate the flexibility of the
multilayer perceptron for implementing functions.
11-4
Multilayer Perceptrons
Consider the two-layer, 1-2-1 network shown in Figure 11.4. For this exam-
2
+2 ple the transfer function for the first layer is log-sigmoid and the transfer
function for the second layer is linear. In other words,
1 -
f n = ---------------
1 2
n
and f n = n . (11.2)
1+e
2 2 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-sig-
moid 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 follow-
ing discussion.
The centers of the steps occur where the net input to a neuron in the first
layer is zero:
1
b1 10
n 1 = w 1 1 p + b 1 = 0 p = ---------
- = --------- = 1 ,
1 1 1
1
(11.3)
w 1 1 10
11-5
11 Backpropagation
1
b2 10
n 2 = w 2 1 p + b 2 = 0 p = ---------
- = ------ = 1 .
1 1 1
1
(11.4)
w 2 1 10
2
a 1
-1
-2 -1 0 1 2
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 (out-
put) 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 MAT-
LAB Neural Network Design Demonstration Network Function (nnd11nf).
11-6
The Backpropagation Algorithm
3 3
1 2
b2 w 1 1
2 2
1 1
0 0
-1 -1
-2 -1 0 1 2 -2 -1 0 1 2
(a) (b)
3 3
2 2
w 1 2 b
2 2
1 1
0 0
-1 -1
-2 -1 0 1 2 -2 -1 0 1 2
(c) (d)
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.8)
11-7
11 Backpropagation
p a1 a2 a3
Rx1
W1 S1 x 1
W2 S2 x 1
W3 S3 x 1
n1 n2 n3
S1 x R
S1 x 1
f1 S2 x S1
S2 x 1
f2 S3 x S2
S3 x 1
f3
1 b1 1 b2 1 b3
S1 x 1 S2 x 1 S3 x 1
R S1 S2 S3
Performance Index
The backpropagation algorithm for multilayer networks is a generalization
of the LMS algorithm of Chapter 10, and both algorithms use the same per-
formance 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 x is the vector of network weights and biases (as in Chapter 10). If
the network has multiple outputs this generalizes to
T 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
The Backpropagation Algorithm
F -
w i j k + 1 = w i j k ----------
m m
m
, (11.13)
w i j
F
b i k + 1 = b i k --------m- ,
m m
(11.14)
b i
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 mul-
tilayer 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 lay-
ers, 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
---------------------- = ------------ --------------- . (11.15)
dw dn dw
2 For example, if
+2
n 2w
f n = e and n = 2w , so that f n w = e , (11.16)
then
f n w -
d--------------------- df n dn w
= ------------ --------------- = e 2 .
n
(11.17)
dw dn dw
We will use this concept to find the derivatives in Eq. (11.13) and Eq.
(11.14):
m
n i
F F- ----------
----------
- = -------- m- , (11.18)
m m
w i j n i w i j
m
F F n i
--------- = --------m- --------m- . (11.19)
m
b i n i b i
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:
m1
S
w i j a j
m m m1 m
ni = + bi . (11.20)
j=1
Therefore
m m
n i 1 n i
----------
m
- = am
j , --------m- = 1 . (11.21)
w i j b i
If we now define
F
s i --------m- ,
m
(11.22)
n i
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
----------
m
- = sm m1
i aj , (11.23)
w i j
F
--------m- = s m
i . (11.24)
b i
m m m
b i k + 1 = b i k s i . (11.26)
m m m m1 T
W k + 1 = W k s a , (11.27)
m m m
b k + 1 = b k s , (11.28)
where
11-10
The Backpropagation Algorithm
F
--------m-
n 1
F
F ---------
s --------m- =
m m
n 2 . (11.29)
n
F
---------
m
-
n m
S
(Note the close relationship between this algorithm and the LMS algorithm
of Eq. (10.33) and Eq. (10.34)).
Next we want to find an expression for this matrix. Consider the i, j ele-
ment of the matrix:
11-11
11 Backpropagation
m
S
w i l a l + b i
m+1 m m+1
m+1 m
n i l = 1 m + 1 a j
--------------
- = --------------------------------------------------------
- = w i j --------
m
-
m m
n j n j n j
m m
m + 1 f n j + 1m m
= w i j ------------------
m
- = wm
i j f n j ,
(11.31)
n j
where
m m
m m f n j
f n j = ------------------
m
-. (11.32)
n j
where
m m
f n1 0 0
m m
F n = 0 f n2 0
m m
. (11.34)
m m
0 0 f nSm
We can now write out the recurrence relation for the sensitivity by using
the chain rule in matrix form:
n m + 1 F
T
F F
m n m W m + 1 T ---------------
s
m
= --------
- = ---------------
- ---------------
- = F -
n n
m m m+1 m+1
n n
= F (n ) W
m m m+1 T m+1 (11.35)
s .
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 M1 2 1
s s s s . (11.36)
11-12
The Backpropagation Algorithm
tj aj
2
T
a
F t a t a
= --------M- = ------------------------------------ - = 2 t i a i --------Mi- .
- = -------------------------------
M j=1
si M M
(11.37)
n i n i n i n i
Now, since
M M M
a a f n i
- = f n M
M
--------Mi- = --------iM- = -------------------
M i , (11.38)
n i n i n i
we can write
M M M
si = 2 ti ai f ni . (11.39)
= 2F (n ) t a .
M M M
s (11.40)
Summary
Lets summarize the backpropagation algorithm. The first step is to propa-
gate the input forward through the network:
0
a = p, (11.41)
m+1 m+1 m+1 m m+1
a = f W a +b for m = 0 1 M 1 , (11.42)
M
a = a . (11.43)
The next step is to propagate the sensitivities backward through the net-
work:
= 2F (n ) t a ,
M M M
s (11.44)
11-13
11 Backpropagation
= F (n ) W
m m m m+1 T m+1
s s , for m = M 1 2 1 . (11.45)
Finally, the weights and biases are updated using the approximate steep-
est descent rule:
m m m m1 T
W k + 1 = W k s a , (11.46)
m m m
b k + 1 = b k s . (11.47)
Example
2 To illustrate the backpropagation algorithm, lets choose a network and ap-
+2
ply 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
g p = 1 + sin --- p for 2 p 2 . (11.48)
4
To obtain our training set we will evaluate this function at several values
of p .
11-14
Example
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.
2.5
1.5
2
a 1
0.5
0.5
1
2 1.5 1 0.5 0 0.5 1 1.5 2
a = f W a + b = logsig 0.27 1 + 0.48 = logsig 0.75
1 1 1 0 1
1
------------------
0.75
-
= 1 + e = 0.321 .
1
-------------------
0.368
0.54
1+e
11-15
11 Backpropagation
0.368
2
e = t a = 1 + sin --- p a = 1 + sin --- 1 0.446 = 1.261 .
4 4
n
1 d ---------------
1 -
= -----------------------2 = 1 ---------------
e 1 1
f n = - ---------------
- = 1 a1 a1 .
d n 1 + e n 1 + e
n 1+e
n
1+e
n
f n = d n = 1 .
2
dn
1 1
1 a1 a1
s = F (n ) W s =
1 1 1 2 T 2 0 0.09
1 1
2.522
0 1 a 2 a 2 0.17
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
Batch vs. Incremental Training
2 2 2 1 T
W 1 = W 0 s a = 0.09 0.17 0.1 2.522 0.321 0.368
= 0.171 0.0772 ,
2 2 2
b 1 = b 0 s = 0.48 0.1 2.522 = 0.732 ,
1 0 T
W 1 = W 0 s a = 0.27 0.1 0.0495 1 = 0.265 ,
1 1
11
11-17
11 Backpropagation
Q Q
1 1
F x = ---- t q a q t q a q = ---- t q a q t q a q . (11.50)
T T
Q
q=1 Q
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
Q
m1 T
W k + 1 = W k ---- sq aq
m m m
, (11.51)
Q
q=1
Q
b k + 1 = b k ---- sq .
m m m
(11.52)
Q
q=1
Using Backpropagation
In this section we will present some issues relating to the practical imple-
mentation of backpropagation. We will discuss the choice of network archi-
tecture, and problems with network convergence and generalization. (We
will discuss implementation issues again in Chapter 12, which investigates
procedures for improving the algorithm.)
11-18
Using Backpropagation
For this first example we will use a 1-3-1 network, where the transfer func-
tion for the first layer is log-sigmoid and the transfer function for the sec-
ond 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-sig-
moid 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 re-
sponses are shown by the blue lines.
3 3
i = 1 i = 2
2 2
1 1
0 0
-1 -1
-2 -1 0 1 2 -2 -1 0 1 2
3 3
i = 4 i = 8
2 2
1 1
0 0
-1 -1
-2 -1 0 1 2 -2 -1 0 1 2
11-19
11 Backpropagation
1
this chapter, the response of this network is a superposition of S sigmoid
functions.
Figure 11.11 illustrates the network response as the number of neurons in
the first layer (hidden layer) is increased. Unless there are at least five neu-
rons in the hidden layer the network cannot accurately represent g p .
3 3
1-2-1 1-3-1
2 2
1 1
0 0
-1 -1
-2 -1 0 1 2 -2 -1 0 1 2
3 3
1-4-1 1-5-1
2 2
1 1
0 0
-1 -1
-2 -1 0 1 2 -2 -1 0 1 2
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
To approximate this function we will use a 1-3-1 network, where the trans-
fer 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 solu-
tion, 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 repre-
sented. The numbers simply indicate an ordering.)
2 5
1 3
2
4
0
0
-1
-2 -1 0 1 2
11-21
11 Backpropagation
5
1 3
4
0
0
1
-1
-2 -1 0 1 2
Generalization
In most cases the multilayer network is trained with a finite number of ex-
amples of proper network behavior:
{p 1, t 1} { p 2, t 2} {p Q, tQ} . (11.56)
g p = 1 + sin --- p , (11.57)
4
11-22
Using Backpropagation
been trained on this data. The black line represents g p , the blue line rep-
resents the network response, and the + symbols indicate the training set.
3
-1
-2 -1 0 1 2
-1
-2 -1 0 1 2
The 1-9-1 network has too much flexibility for this problem; it has a total
of 28 adjustable parameters (18 weights and 10 biases), and yet there are
only 11 data points in the training set. The 1-2-1 network has only 7 param-
11-23
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 mod-
eling problems, we want to use the simplest network that can adequately
represent the training set. Dont use a bigger network when a smaller net-
work 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 Second Layer Third Layer
p a1 a2 a3
Rx1
W1 S1 x 1
W2 S2 x 1
W3 S3 x 1
n1 n2 n3
S1 x R
S1 x 1
f 1 S2 x S1
S2 x 1
f 2 S3 x S2
S3 x 1
f 3
1 b1 1 b2 1 b3
S1 x 1 S2 x 1 S3 x 1
R S1 S2 S3
Backpropagation Algorithm
Performance Index
T T
Fx= Ee e = Et a t a
Sensitivity
F
--------m-
n 1
F
F --------m-
s --------m- =
m
n 2
n
F
---------
m
-
n S m
11
11-25
11 Backpropagation
Forward Propagation
0
a = p,
m+1 m+1 m+1 m m+1
a = f W a +b for m = 0 1 M 1 ,
M
a = a .
Backward Propagation
= 2F (n ) t a ,
M M M
s
= F (n ) W
m m m m+1 T m+1
s s , for m = M 1 2 1 ,
where
f n 1
m m
0 0
m
F n =
m
m m 0 f n2 0
,
f n S m
m m
0 0
m m
m m f n j
f n j = ------------------
m
-.
n j
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 hor-
izontal lines.
Class I
Class II
1 1
p1 = 1 and p 2 = 1 ,
1 1
1 1
1 1
p 3 = 1 and p 4 = 1 .
1 1
1 1
Wp 1 + b 0 , Wp 2 + b 0 , Wp 3 + b 0 , Wp 4 + b 0 .
11-27
11 Backpropagation
1
1 =
w 1 1 w 1 2 w 1 3 w 1 4 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 .
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 ,
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 ,
p1 2
n11 a11
p2
2 n21 a21
2
1
-1
p3 2 n12 a12 2 1
1
p4 2 -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 vec-
tor in the same way. Both of the neurons in the first layer perform AND op-
erations. 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.
9
10
11
1 T
W = 1 1 1 1 1 1 1 1 1 1 1 ,
1 1 1 1 1 1 1 1 1 1 1
11-29
11 Backpropagation
1 T
b = 2 3 0.5 0.5 1.75 2.25 3.25 3.75 6.25 5.75 4.75 .
1 1 1 1 0 0 0 0 0 0 0 3
W = 0 0 0 0 1 1 0 0 1 0 1 , b = 3 .
2 T
0 0 0 0 1 0 0 1 1 1 0 3
0 0 0 0 0 0 1 1 1 0 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 combin-
ing the boundaries 5, 6, 9 and 11 from layer 1. This can be seen by looking
2
at row 2 of W .
2
3
1
11-30
Solved Problems
p a1 a2 a3
2x1
W1 11 x 1
W2 4x1
W3 1x1
11 x 2
n1 4 x 11
n2 1x4
n3
11 x 1 4x1 1x1
1 b 1 1 b 2 1 b 3
11 x 1 4x1 1x1
2 11 4 1
3 3 2 3 3 2 1 3 2 1 3 2 3
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 M1 2 1
W = W W W W ,
11-31
11 Backpropagation
W b + + b .
M M1 2 1 M M1 3 2 M
b = W W W b + W W
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 .
Fy0 .
y0
yK
,
y0
rk y k .
y 0
y k + 1 y k y k + 1
r k + 1 = y k + 1 = ---------------------- ------------- = ---------------------- r k .
y 0 y k y 0 y k
----------------------
yk + 1 f y k
= -------------------- = f y k .
y k y k
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
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 1 2 2
w = 1 , b = 1 , w = 2 , b = 1 .
( p = 1 , t = 1 ) .
2
i. Find the squared error e as an explicit function of all
weights and biases.
2 1
ii. Using part (i) find e w at the initial weights and biases.
iii. Repeat part (ii) using backpropagation and compare results.
w1 n1 a1 w2 n2 a2
p
b1 b2
1 1
a 1 = logsig (w 1 p + b 1) a 2 = purelin (w 2 a 1 + b 2)
11-33
11 Backpropagation
2 2 2 1
2
e = t a = t w ---------------------------------------------------------
- + b 2 .
2
1 + exp w p + b
1 1
e
2
e 2 1
------------
1
= 2e --------1- = 2e w -----------------------------------------------------------2- exp w p + b p
1 1
w w 1 + exp w p + b 1 1
1 1
a = ---------------------------------------------------------
- = --------------------------------------------------------- = 0.8808
1
1 + exp w p + b
1 1 1 + exp 1 1 + 1
2 2 1 2
a = w a + b = 2 0.8808 + 1 = 0.7616
2
e = t a = 1 0.7616 = 1.7616
e
2
2 1
------------
1
= 2e w -----------------------------------------------------------2- exp w p + b p
1 1
w 1 + exp w p + b 1 1
1
= 2 1.7616 2 ----------------------------------------------------------2- exp 1 1 + 1 1
1 + exp 1 1 + 1
iii. To backpropagate the sensitivities we use Eq. (11.44) and Eq. (11.45):
s = 2F (n ) t a = 2 1 1 0.7616 = 3.5232 ,
2 2 2
s = F (n ) W s = a 1 a 2 s
1 1 1 2 T 2 1 1 2
11-34
Solved Problems
P11.6 Earlier in this chapter we showed that if the neuron transfer func-
tion is log-sigmoid,
1
a = f n = ---------------
n
-,
1+e
d -----------------
e e -
n n n n n n
df n e e - n n e + e
------------------------
f n = ------------ = n = e e + -----------------
-
dn d n e + e n n
e + e
n 2 n
e +e
n
n n 2
e e
= 1 -------------------------2 = 1 a .
2
n n
e + e
P11.7 For the network shown in Figure P11.9 the initial weights and bi-
ases are chosen to be
1 1 2 2
w 0 = 1 , b 0 = 1 , w 0 = 2 , b 0 = 1 .
( p = 1 , t = 1 ) .
11-35
11 Backpropagation
w1 n1 a1 w2 n2 a2
p
b1 b2
1 1
a 1 = tansig (w 1 p + b 1) a 2 = tansig (w 2 a 1 + b 2)
2 2 1 2
n = w a + b = 2 0.964 + 1 = 0.928
2 2
exp n exp n exp 0.928 exp 0.928
a = tansig n = ------------------------------------------------
- = -----------------------------------------------------------------
2 2
2
exp n + exp n
2 exp 0.928 + exp 0.928
= 0.7297
2
e = t a = 1 0.7297 = 1.7297
Now we backpropagate the sensitivities using Eq. (11.44) and Eq. (11.45).
s = 2F (n ) t a = 2 1 a e = 2 1 0.7297 1.7297
2 2 2 2 2 2
= 1.6175
s = F (n ) W s = 1 a w s = 1 0.964 2 1.6175
1 1 1 2 T 2 1 2 2 2 2
= 0.2285
Finally, the weights and biases are updated using Eq. (11.46) and Eq.
(11.47):
2 2 2 1 T
w 1 = w 0 s a = 2 1 1.6175 0.964 = 0.4407 ,
11-36
Solved Problems
1 1 1 0 T
w 1 = w 0 s a = 1 1 0.2285 1 = 0.7715 ,
2 2 2
b 1 = b 0 s = 1 1 1.6175 = 2.6175 ,
1 1 1
b 1 = b 0 s = 1 1 0.2285 = 0.7715 .
W2,1
p
a1 a2
W1 S1 x 1
W2 S2 x 1
Rx1 n1 n2
S1 x R
S1 x 1
f1 S2 x S1
S2 x 1
f2
1 b1 1 b2
S1 x 1 S2 x 1
R S1 S2
The backpropagation equations for the sensitivities will not change from
those for a standard two-layer network. The sensitivities are the deriva-
tives 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-37
11 Backpropagation
n i
m
F F
----------
m
- = --------
m
- ----------
m
- = sm m1
i aj ,
w i j n i w i j
m
F F n
--------m- = --------m- --------im- = s m
i .
b i n i b i
1 1 2 2
Therefore the update equations for W , b , W and b do not change. We
2 1
do need an additional equation for W :
n i
2
n i
2
F F
------------
- = -------
- 2 1 = s i 2 1- .
------------
- 2
------------
2 1 2
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
1
S R
2 1
w i j p j + bi .
2 2 1 2
ni = w i j a j +
j=1 j=1
Therefore
n i
2
F
------------
- = p j and ------------- = s 2i p j .
2 1 2 1
w i j w i j
m m m m1 T
W k + 1 = W k s a , m = 1 2 ,
m m m
b k + 1 = b k s , m = 1 2 .
2 1 2 1 2 0 T 2 1 2 T
W k + 1 = W k s a = W 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.
11-38
Solved Problems
w2 a(k)
n(k) a(k + 1)
D
w1
p(k)
a(0)
For our weight updates we will use the steepest descent algorithm:
F x .
w i =
wi
a k
t k a k = 2 t k a k ------------- .
2
Fx =
wi wi w i
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 + 1 - a k
---------------------- = a k + w 2 ------------- .
w 2 w 2
11
11-39
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
a 1 = w1 p 0 + w2 a 0 = w1 p 0 .
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
F x a 1
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 .
s = 2F (n ) t a = 2 I t a = 2e ,
1 1 1
1 1 1 0 T 1 T 1 T
W k + 1 = W k s a = W k 2e p = W k + 2ep
1 1 1 1 1
b k + 1 = b k s = b k 2e = b k + 2e .
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, mul-
tilayer 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 cal-
culated. 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 com-
pute the derivatives in the hidden layers.
One of the major problems with backpropagation has been the long train-
ing 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 al-
gorithm. In Chapter 12 we will discuss the reasons for the slow conver-
gence 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 proce-
dures 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 multi-
layer networks are provided in Chapter 23 (function approximation), Chap-
ter 24 (probability estimation) and Chapter 25 (pattern recognition).
11-41
11 Backpropagation
Further Reading
[HoSt89] K. M. Hornik, M. Stinchcombe and H. White, Multilayer
feedforward networks are universal approximators, Neu-
ral Networks, vol. 2, no. 5, pp. 359366, 1989.
This paper proves that multilayer feedforward networks
with arbitrary squashing functions can approximate any
Borel integrable function from one finite dimensional space
to another finite dimensional space.
[LeCu85] Y. Le Cun, Une procedure dapprentissage pour reseau a
seuil assymetrique, Cognitiva, vol. 85, pp. 599604, 1985.
Yann Le Cun discovered the backpropagation algorithm at
about the same time as Parker and Rumelhart, Hinton and
Williams. This paper describes his algorithm.
[Park85] D. B. Parker, Learning-logic: Casting the cortex of the hu-
man 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 Rumel-
hart, Hinton and Williams. This report describes his algo-
rithm.
[RuHi86] D. E. Rumelhart, G. E. Hinton and R. J. Williams, Learn-
ing representations by back-propagating errors, Nature,
vol. 323, pp. 533536, 1986.
This paper contains the most widely publicized description
of the backpropagation algorithm.
[RuMc86] D. E. Rumelhart and J. L. McClelland, eds., Parallel Dis-
tributed 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 resur-
gence of interest in the neural networks field during the
1980s. Among other topics, it presents the backpropagation
algorithm for training multilayer neural networks.
[Werbo74] P. J. Werbos, Beyond regression: New tools for prediction
and analysis in the behavioral sciences, Ph.D. Thesis,
Harvard University, Cambridge, MA, 1974.
This Ph.D. thesis contains what appears to be the first de-
scription of the backpropagation algorithm (although that
11-42
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 net-
work diagram in abbreviated notation and show the weight matrices and
bias vectors.
i. ii.
iii. iv.
E11.2 Choose the weights and biases for the 1-2-1 network shown in Figure 11.4
so that the network response passes through the points indicated by the
blue circles in Figure E11.2.
Use the MATLAB Neural Network Design Demonstration Two-Layer Net-
work Function (nnd11nf) to check your result.
11-44
Exercises
4 4
3 i. 3 ii.
2 2
t 1 t 1
0 0
1 1
2 2
2 1 0 1 2 2 1 0 1 2
p p
4 4
3 iii. 3 iv.
2 2
t 1 t 1
0 0
1 1
2 2
2 1 0 1 2 2 1 0 1 2
p p
E11.3 Find a single-layer network that has the same input/output characteristic
as the network in Figure E11.3.
n 11 a 11
-2
p1
-1 1 n 21 a 21
1
-0.5
1 n 12 a 12 1 0.5
p2
3 1
-0.5
1
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
i. Find the squared error e as an explicit function of all weights and
biases.
2 1
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 de-
scribed in the text.
E11.6 For the network shown in Figure E11.4 the initial weights and biases are
chosen to be
1 1 2 2
w 0 = 1 , b 0 = 2 , w 0 = 1 , b 0 = 1 .
1
f n = n , f n = --- ,
1 2 2
n
p = 1 t = 1 .
w1 n1 a1 w2 n2 a2
p f1 f2
b1 b2
1 1
a 1 = f 1(w 1 p + b 1) a 2 = f 2 (w 2 a 1 + b 2)
11-46
Exercises
1 1
1
w 1,1 n1 a1
S w21,1
b11 n11 a2
p
1 S
1
n2 a12 1
b1
1
w 2,1
S 2
w 1,2 1
b12
1
1 1 1 2 2 1 2
a = purelin(W p + b ) a = purelin(W a + b )
Figure E11.5 Two-Layer Network for Exercise E11.7
1
W 0 = 1 , W2 0 = 1 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 1
iii. Compute the derivative e w 1 1 using the results of part ii.
(Very little calculation is required here.)
E11.8 For the network shown in Figure E11.6 the neuron transfer function is
1 2
f n = n ,
1 t = 8 .
p =
1 2
11-47
11 Backpropagation
Inputs Layer 1
1 n 11 a 11
p1
-1
f1
1
1
1 n 12 a 12
p2
1 f1
1
1
E11.9 We want to train the network in Figure E11.7 using the standard back-
propagation algorithm (approximate steepest descent).
p1 w1,1
n a
S f(n) = n2
p2 w1,2 b
1
2
a = (Wp + b)
Figure E11.7 Square Law Neuron
The following input and target are given:
1 t=
p = 0
1
W 0 = 1 1 , b 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 func-
2
tion of the hidden layer is f n = n .)
Inputs Square
- Title
Law 1 Layer
- Linear
- TitleLayer
2-
p a1 a2
2x1 W1 2x1 W2 1x1
2x2 n1 1x2 n2
2x1 1x1
1 b1 1 b2
2x1 1x1
- Exp 1 -1p+b1)
a1 = square(W - Exp 2 2-a1+b2)
a2 = purelin(W
W 0 = 1 1 , W 0 = 2 1 , b 0 = 1 , b 0 = 1 .
1 2 1 2
1 0 1
1 t=
p = 2
1
11-49
11 Backpropagation
w1 n1 a1 w2 n2 a2
p
SxR
SxR
b1 b2
1 1
a1 = (w1p+b1) 3 a2 = (w2a1+b2) 2
p 1 = 1 t 1 = 0 ,
E11.12 Consider the multilayer perceptron network in Figure E11.10. (The trans-
3
fer function of the hidden layer is f n = n .)
p1 1
a1 2
a2
2x1
W 2x1
W 1x1
2x2
n1 1x2
n
2
2x1 1x1
1 b 1
1 b 2
1
2 2x1 S 1x1 1
1 1 1 2 2 1 2
a = cube(W p + b ) a = W a +b
Figure E11.10 Cubic Law Neural Network
11-50
Exercises
W 0 = 1 1 , b 0 = 1 , W 0 = 1 1 , b 0 = 1 .
1 1 2 2
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 in-
put at layer m would be computed as
m m m m1 m
n = W a +b ,
m
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.)
1 1
n1 a1
2 S 2
p -1 n2 a2
1 S
1
1
n2 a12
S 3
1
-1
1
1
11-51
11 Backpropagation
2 2 2
a a a
2
, 1
, 1
.
n n1 n2
2
a
ii. Use the results of i. and the chain rule to find
.
p
Your answers to both parts should be numerical.
E11.15 Consider the network shown in Figure E11.12, where the inputs to the neu-
ron involve both the original inputs and their product. This is a type of
higher-order network.
p1 w1
w1,2 n a
S
p2 w2 b
1
a = logsig(w1 p1 + w2 p2 + w1,2 p1 p2 + b)
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 con-
nection from the input directly to the second layer. Derive the backpropa-
gation algorithm for this network.
11-52
Exercises
w 2,1
w1 n 1 a 1
w2 n2 a2
p f1 f2
b 1 b2
1 1
a 1 = f 1(w 1 p + b 1) a 2 = f 2 (w 2 a 1 + w 2,1 p + b 2)
w i j
m+1 m+1 m m+1 m+1 m+1 m m+1
n = W a +b or ni = aj + bi .
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
S
= w i j a j b i
m+1 m+1 m m+1
ni .
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 bi-
M
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 Backpropagation
M
a
q = ---------i- .
i
a
M
a
1
a
2
a
3
a
p f1 f2 f
3
f
M
E11.21 With the standard backpropagation algorithm, we want to compute the de-
rivative
F-
------ .
w
F F n
------- = ------ ------- .
w n w
Suppose that we want to use Newton's method. We would need to find the
second derivative
2
F
--------2- .
w
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 .
Fy0 .
y0
We developed a procedure for computing this gradient using the chain rule.
The procedure involved a recursive equation for the term
y k ,
rk
y 0
which evolved forward in time. The gradient can also be computed in a dif-
ferent way by evolving the term
2
qk e K
yk
p(k) 1
n(k) a(k)
S
a(k-1) w
D
a(k) = p(k) + w a(k-1)
Figure E11.15 Recurrent Network
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 de-
scent, 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 .
g p = 1 + sin --- p for 2 p 2 .
2
1 1
Use S = 2 and S = 10 . Experiment with several different values for the
learning rate , and use several different initial conditions. Discuss the
convergence properties of the algorithm as the learning rate changes.
11-56
Objectives
12 Variations on
Backpropagation
Objectives 12-1
Theory and Examples 12-2
Drawbacks of Backpropagation 12-3
Performance Surface Example 12-3
Convergence Example 12-7
Heuristic Modifications to Backpropagation 12-9
Momentum 12-9
Variable Learning Rate 12-12
Numerical Optimization Techniques 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 fast-
er 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
12-2
Drawbacks of Backpropagation
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 learn-
ing 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 qua-
dratic function is constant, therefore the curvature of the function in a giv-
en direction does not change, and the function contours are elliptical.
SDBP is a generalization of the LMS algorithm. Like LMS, it is also an ap-
proximate steepest descent algorithm for minimizing the mean squared er-
ror. In fact, SDBP is equivalent to the LMS algorithm when used on a
single-layer linear network. (See Problem P11.10.) When applied to multi-
layer networks, however, the characteristics of SDBP are quite different.
This has to do with the differences between the mean squared error perfor-
mance 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 sur-
face 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.
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 1 1 1
w 1 1 = 10 , w 2 1 = 10 , b 1 = 5 , b 2 = 5 , (12.1)
2 2 2
w 1 1 = 1 , w 1 2 = 1 , b = 1 . (12.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
2
a 0.5
0.25
0
-2 -1 0 1 2
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 mini-
1 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 appropri-
ate 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 net-
work. 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 par-
2
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 per-
formance of backpropagation on this surface.
15
10
10
5
2
w 1 1 5
0
0 -5
0 -5
5 0
2
w 1 1 5 1
10
10
w 1 1
-5 15 15
-5 0 5 10 15
1
w 1 1
1 2
Figure 12.3 Squared Error Surface Versus w 1 1 and w 1 1
1 1
Figure 12.4 illustrates the squared error when w 1 1 and b 1 are being ad-
justed, 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 algo-
rithm 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 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
1
b -5 1
1
0.5
0
-15 -10
0 20
10
1 10 0
w 1 1 20 -10 b
1
-20 1
-25 30 -30
-10 0 10 20 30
1
w 1 1
1 1
Figure 12.4 Squared Error Surface Versus w 1 1 and b 1
1 1
Figure 12.5 illustrates the squared error when b 1 and b 2 are being adjust-
ed, while the other parameters are set to their optimal values. The mini-
1 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 so-
lution 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 be-
cause 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 perfor-
mance 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 re-
gions as we move far away from the optimum point.
Typically we choose the initial weights and biases to be small random val-
ues. 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. (An-
other 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
10
1.4
0.7
2
b1 0
0
-5 -10
-5 -10
0 -5
1
b1 0 1
5 b
5 2
-10 10 10
-10 -5 0 5 10
1
b 1
1 1
Figure 12.5 Squared Error Surface Versus b 1 and b 2
Convergence Example
Now that we have examined the performance surface, lets investigate the
performance of SDBP. For this section we will use a variation of the stan-
Batching dard 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 pos-
sible 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 sur-
face, 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 mini-
mum point. The trajectory is trapped in a valley and diverges from the op-
timal 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 rea-
son 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 b
2 5
w 1 1
a
-5
-5 0 5 10 15
1
w 1 1
2 6
a b
1.5
4
2
0.5
0 0 2 4
0 0 1 2 3
10 10 10 10 10 10 10
Iteration Number Iteration Number
12-8
Heuristic Modifications of Backpropagation
1.5
Squared Error
10
1
2
w 5
1 1
0.5
0 0 1 2 3
10 10 10 10
Iteration Number
-5
-5 0 5 10 15
1
w 1 1
Momentum
The first method we will discuss is the use of momentum. This is a modifi-
cation 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 investi-
gate a simple example to illustrate the smoothing effect. Consider the fol-
lowing first-order filter:
12-9
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 in-
put to the filter was taken to be the sine wave:
w k = 1 + sin --------- ,
2k
(12.6)
16
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 aver-
age filter input, although as is increased the filter output is slower to re-
spond.
2 2
1.5 1.5
1 1
0.5 0.5
0 0
0 50 100 150 200 0 50 100 150 200
a) = 0.9 b) = 0.98
m m m1 T
W k = s a , (12.7)
m m
b k = s . (12.8)
12-10
Heuristic Modifications of Backpropagation
Momentum When the momentum filter is added to the parameter changes, we obtain
the following equations for the momentum modification to backpropaga-
MOBP tion (MOBP):
m m m m1 T
W k = W k 1 1 s a , (12.9)
m m m
b k = b k 1 1 s . (12.10)
1.5
Squared Error
10
2 5
w 1 1
0.5
0
0 0 1 2 3
10 10 10 10
Iteration Number
-5
-5 0 5 10 15
1
w 1 1
12-11
12 Variations on Backpropagation
12-12
Heuristic Modifications of Backpropagation
15
10
2
w 1 1 5
-5
-5 0 5 10 15
1
w 1 1
1.5 60
Squared Error Learning Rate
1 40
0.5 20
0 0 1 2 3
0 0 1 2 3
10 10 10 10 10 10 10 10
Iteration Number Iteration Number
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 Su-
perSAB 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 con-
cave 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 conver-
gence for some problems. However, there are two main drawbacks to these
methods. The first is that the modifications require that several parame-
ters 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 al-
gorithm is sensitive to changes in these parameters. The choice of param-
eters is also problem dependent. The second drawback to these
modifications to SDBP is that they can sometimes fail to converge on prob-
lems for which SDBP will eventually find a solution. Both of these draw-
backs tend to occur more often when using the more complex algorithms.
To experiment with VLBP, use the MATLAB Neural Network Design Dem-
onstration Variable Learning Rate Backpropagation (nnd12vl).
Conjugate Gradient
In Chapter 9 we presented three numerical optimization techniques: steep-
est 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 cal-
culated. 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 qua-
dratic function in a finite number of iterations.) In this section we will de-
scribe how the conjugate gradient algorithm can be used to train
12-14
Numerical Optimization Techniques
p0 = g0 , (12.12)
where
g k F x . (12.13)
x = xk
xk + 1 = xk + k pk . (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 T T
g k 1 g k gk gk g k 1 g k
k = --------------------------
T
- or k = ----------------------
T
- or k = ----------------------
T
-. (12.16)
g k 1 p k 1 gk 1 gk 1 gk 1 gk 1
12-15
12 Variations on Backpropagation
F x0 . (12.17)
F x 0 + p 0 . (12.18)
F(x)
8
4
2
x
a1 b1
a2 b2
a3 b3
a4 b4
a5 b5
12-16
Numerical Optimization Techniques
F(x) F(x)
a c b a c d b
(a) Interval is not reduced. (b) Minimum must occur
between c and b.
12-17
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 in-
terval 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 qua-
dratic 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 qua-
dratic, therefore the algorithm would not normally converge in n itera-
tions. 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 meth-
od.
Lets now apply the conjugate gradient algorithm to the function approxi-
mation 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 algo-
rithms 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
Numerical Optimization Techniques
15
12
10
2
w 1 1 5
-5
-5 0 5 10 15
1
w 1 1
1.5
Squared Error
10
2
w 1 1 5
0.5
0
0 0 1 2
10 10 10
Iteration Number
-5
-5 0 5 10 15
1
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 oth-
er 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 perfor-
mance 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
1
xk + 1 = xk Ak gk , (12.19)
where A k 2F x and g k F x .
x = xk x = xk
vi x
2 T
Fx = = v x v x , (12.20)
i=1
where
v 1 x v 1 x v 1 x
- ---------------- ---------------
--------------- -
x 1 x 2 x n
v 2 x v 2 x v 2 x
- ---------------- ---------------
--------------- -
Jx = x 1 x 2 x n
v N x v N x v N x
---------------- ---------------- ----------------
x 1 x 2 x n
. (12.23)
Jacobian Matrix is the Jacobian matrix.
Next we want to find the Hessian matrix. The k j element of the Hessian
matrix would be
N 2
2
Fx v i x v i x vi x
2F x = ----------------- = 2 - --------------- + v i x -----------------
-------------- x k x j
k j . (12.24)
x k x j x k x j
i=1
where
12-20
Numerical Optimization Techniques
Sx = vi x 2vi x . (12.26)
i=1
If we then substitute Eq. (12.27) and Eq. (12.22) into Eq. (12.19), we obtain
Gauss-Newton the Gauss-Newton method:
T 1 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)
Note that the advantage of Gauss-Newton over the standard Newtons
method is that it does not require calculation of second derivatives.
T
One problem with the Gauss-Newton method is that the matrix H = J J
may not be invertible. This can be overcome by using the following modifi-
cation to the approximate Hessian matrix:
G = H + I . (12.29)
To see how this matrix can be made invertible, suppose that the eigenval-
ues 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)
T 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 ap-
proaches 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 , (12.33)
k 2 k
tq aq
T
Fx = tq aq
q=1
M
Q Q S N
e j q vi
T 2 2
= eq eq = = ,
q=1 q = 1j = 1 i=1 (12.34)
where e j q is the j th element of the error for the q th input/target pair.
Eq. (12.34) is equivalent to the performance index, Eq. (12.20), for which
Levenberg-Marquardt was designed. Therefore it should be a straightfor-
ward matter to adapt the algorithm for network training. It turns out that
this is true in concept, but it does require some care in working out the de-
tails.
Jacobian Calculation
The key step in the Levenberg-Marquardt algorithm is the computation of
the Jacobian matrix. To perform this computation we will use a variation
of the backpropagation algorithm. Recall that in the standard backpropa-
gation procedure we compute the derivatives of the squared errors, with re-
spect to the weights and biases of the network. To create the Jacobian
matrix we need to compute the derivatives of the errors, instead of the de-
rivatives of the squared errors.
It is a simple matter conceptually to modify the backpropagation algorithm
to compute the elements of the Jacobian matrix. Unfortunately, although
12-22
Numerical Optimization Techniques
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 sec-
tion 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 , (12.35)
S 1 S Q
T
x = x 1 x 2 x n = w 11 1 w 11 2 w 11 1
b1 b
1
1
2
w 1 1 b
M
M
, (12.36)
S R S S
and n = S R + 1 + S S + 1 + + S S
M 1 2 1 M M1
N = QS + 1 .
Therefore, if we make these substitutions into Eq. (12.23), the Jacobian
matrix for multilayer network training can be written
e 1 1 e 1 1 e 1 1 e 1 1
------------
1 1
- --------------
- ------------ 1
-
- -----------
1
w 1 1 w 1 2 w S 1 R b 1
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 = . (12.37)
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
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
12-23
12 Variations on Backpropagation
For the elements of the Jacobian matrix that are needed for the Levenberg-
Marquardt algorithm we need to calculate terms like
v e k q
J h l = -------h = ----------- . (12.39)
x l x l
where the first term on the right-hand side was defined as the sensitivity:
m F
s i --------m- . (12.41)
n i
m v h e k q
s i h ----------
m
- = -----------
m
, (12.42)
n i q n i q
M
where, from Eq. (12.35), h = q 1 S + k .
Now we can compute elements of the Jacobian by
m m
v e k q e k q n i q m n i q m m1
J h l = -------h = ----------- = ----------- ----------
- = s i h ----------
- = s i h a j q , (12.43)
x l w i j
m m
n i q w i j
m m
w i j
or if x l is a bias,
m m
v e k q e k q n i q m n i q m
J h l = -------h = ----------- = ----------- ----------
- = s i h ----------
- = s i h . (12.44)
x l b i
m m
n i q b i
m
b i
m
12-24
Numerical Optimization Techniques
M M
M v h e k q t k q a k q a k q
s i h = ----------
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
= .
0 for i k
(12.45)
Therefore when the input p q has been applied to the network and the cor-
M
responding network output a q has been computed, the Levenberg-Mar-
quardt backpropagation is initialized with
S q = F n q ,
M M M
(12.46)
m+1 T m+1
S q = F (n q ) W
m m m
S q . (12.47)
The total Marquardt sensitivity matrices for each layer are then created by
augmenting the matrices computed for each input:
m m m m
S = S 1 S 2 S Q . (12.48)
Note that for each input that is presented to the network we will backprop-
M
agate S sensitivity vectors. This is because we are computing the deriva-
tives 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.
12-25
12 Variations on Backpropagation
10
2
w 1 1 5
-5
-5 0 5 10 15
1
w 1 1
12-26
Numerical Optimization Techniques
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 itera-
tions than any of the methods we have discussed so far. Of course this al-
gorithm also requires more computation per iteration than any of the other
algorithms, since it involves a matrix inversion. Even given the large num-
ber of computations, however, the LMBP algorithm appears to be the fast-
est neural network training algorithm for moderate numbers of network
parameters [HaMe94].
15
1.5
Squared Error
10
2
w 1 1 5
0.5
0
0 0 1 2
10 10 10
Iteration Number
-5
-5 0 5 10 15
1
w 1 1
12-27
12 Variations on Backpropagation
Summary of Results
12-28
Summary of Results
F(x)
8
4
2
x
a1 b1
a2 b2
a3 b3
a4 b4
a5 b5
12-29
12 Variations on Backpropagation
T
x = x 1 x 2 x n = w 11 1 w 11 2 w 11 1
b1 b
1
1
2
w 1 1 b
M
M
S R S S
M 1 2 1 M M1
N = QS and n = S R + 1 + S S + 1 + + S 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
m m
v e k q e k q n i q m n i q m m1
J h l = -------h = ----------- = ----------- ----------
- = s i h ----------
- = s i h a j q for weight x l
x l w i j
m m
n i q w i j
m
w i j
m
m m
v e k q e k q n i q m n i q m
J h l = -------h = ----------- = ----------- ----------
- = s i h ----------
- = s i h for bias x l
x l b i
m m
n i q b i
m
b i
m
m v h e k q M
s i h ----------
m
- = -----------
m
(Marquardt Sensitivity) where h = q 1 S + k
n i q n i q
S q = F n q
M MM
S q = F (n q ) W
m m m m+1 T m+1
S q
m m m m
S = S 1 S 2 S Q
12-30
Summary of Results
Levenberg-Marquardt Iterations
1. Present all inputs to the network and compute the corresponding net-
work 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).
12-31
12 Variations on Backpropagation
Solved Problems
P12.1 We want to train the network shown in Figure P12.1 on the train-
ing set
p 1 = 3 t 1 = 0.5 , p 2 = 2 t 2 = 1 ,
w 0 = 0.4 , b 0 = 0.15 .
w n a
p
b
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
The direction of the initial step is the negative of the gradient. For the
weight this will be
sp = 0.0925 3 = 0.2774 .
s = 0.0925 = 0.0925 .
12-32
Solved Problems
0.2774 .
0.0925
Now lets consider the initial direction for the batch mode algorithm. In this
case the gradient is found by adding together the individual gradients
found from the two sets of input/target pairs. For this we need to apply the
second input to the network and perform the forward and backpropagation
steps:
1
a = logsig wp + b = ---------------------------------------------------------------- = 0.7211
1 + exp 0.4 2 + 0.15
e = t a = 1 0.7211 = 0.2789
s = 2f n e = 2a 1 a e = 2 0.7211 1 0.7211 0.2789 = 0.1122 .
The direction of the step is the negative of the gradient. For the weight this
will be
sp = 0.1122 2 = 0.2243 .
s = 0.1122 = 0.1122 .
0.2243 .
0.1122
If we now add the results from the two input/target pairs we find the direc-
tion of the first step of the batch mode SDBP to be
1 0.2774 1
--- + 0.2243 = --- 0.0531 = 0.0265 .
2 0.0925 0.1122 2 0.2047 0.1023
The results are illustrated in Figure P12.2. The blue circle indicates the ini-
tial guess. The two blue arrows represent the directions of the partial gra-
dients 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 indi-
vidual 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 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 net-
work, the trajectory is stochastic, which makes the algorithm somewhat
less likely to be trapped in a local minimum. It may also take longer to con-
verge than the batch mode algorithm.
4
1.5
0.5
b 0
0
-4 -2
-2 -4
0 -2
0
b 2
2 w
4 4 -4
-4 -2 0 2 4
x k = F x k = g k ,
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
F x = Ax + d .
12-34
Solved Problems
If we now insert this expression into our expression for the steepest descent
12
algorithm with momentum we obtain
x k = x k 1 1 Ax k + d .
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 .
xk 1
x k = .
xk
x k + 1 = 0 I x k + 0 = Wx k + v .
I 1 + I 1 A 1 d
W = 0 I where T = 1 + I 1 A .
I T
w w
Wz
w w w
= z , or 0 I z1 = w z1 .
I T z w w
z2
2
12-35
12 Variations on Backpropagation
w w w w t w w w
z 2 = z 1 and z 1 + z 2 = z 2 .
w t w w w w 2 t w w
-----w- z 2 + z 2 = z 2 or + z 2 = 0 .
t w
Therefore for each eigenvalue of T there will be two eigenvalues of
W that are roots of the quadratic equation
w 2 t w
+ = 0 .
t t 2
w 4
= -------------------------------------- .
2
t 2 t 2
w 4
= ----------- + ----------------------- = .
4 4
t 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 eigen-
values are complex.
w
In order for to be complex we must have
t 2 t
4 0 or 2 .
t
Lets now consider the eigenvalues of T . These eigenvalues can be ex-
pressed 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
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 eigen-
values 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 add-
ed 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 fast-
er 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 Variations on Backpropagation
0.5
-0.5
-1
-1 -0.5 0 0.5 1
x 0 = 0.5 ,
0.5
1 T 1
F x 0 = --- x 0 2 0 x 0 = --- 0.5 0.5 2 0 0.5 = 6.5 .
2 0 50 2 0 50 0.5
Fx
x1 2x 1
F x = = .
50x 2
Fx
x2
12-38
Solved Problems
12
g 0 = F x = 1 .
x = x0 25
With the initial learning rate of = 0.05 , the tentative first step of the al-
gorithm is
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 t T 1
F x 1 = --- x 1 2 0 x 1 = --- 0.46 0.5 2 0 0.46 = 6.4616 .
t t
2 0 50 2 0 50 0.5
This is less than F x 0 . Therefore this tentative step is accepted and the
learning rate is increased:
0.5
1 t T 1
F x 2 = --- x 2 2 0 x 2 = --- 0.3968 0.8 2 0 0.3968 = 16.157 .
t t
2 0 50 2 0 50 0.8
Since this is more than 5% larger than F x 1 , we reject this step, reduce
the learning rate and set the momentum coefficient to zero.
12-39
12 Variations on Backpropagation
1 t T 1
F x 3 = --- x 3 2 0 x 3 = --- 0.4255 0.4375 2 0 0.4255 = 4.966
t t
2 0 50 2 0 50 0.4375
1 T
F x = --- x 2 1 x ,
2 1 2
x0 = 0.8 .
0.25
2x 1 + x 2
F x = .
x 1 + 2x 2
As with steepest descent, the first search direction for the conjugate gradi-
ent algorithm is the negative of the gradient:
12-40
Solved Problems
= 1.35 .
T
p 0 = g 0 = F x
x = x0 0.3
x1 = x0 + 0 p0 = 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
b 1 = = 0.075 , F b 1 = F 0.8 + 0.075 1.35 = 0.3721
0.25 0.3
b 2 = 2 = 0.15 , F b 2 = F 0.8 + 0.15 1.35 = 0.2678
0.25 0.3
b 3 = 4 = 0.3 , F b 3 = F 0.8 + 0.3 1.35 = 0.1373
0.25 0.3
b 4 = 8 = 0.6 , F b 4 = F 0.8 + 0.6 1.35 = 0.1893 .
0.25 0.3
12-41
12 Variations on Backpropagation
Since F c F d , we have
0.5
-0.5
-1
-1 -0.5 0 0.5 1
P12.5 To illustrate the computation of the Jacobian matrix for the Lev-
enberg-Marquardt method, consider using the network of Figure
P12.5 for function approximation. The network transfer functions
are chosen to be
1 2 2
f n = n , f n = n .
f n = 2n , f n = 1 .
1 2
12-42
Solved Problems
Find the Jacobian matrix for the first step of the Levenberg-Mar-
quardt method.
1 1 0 1 1 1 1 2
n1 = W a1 + b = 1 1 + 0 = 1 , a1 = f n1 = 1 = 1
2 2 1 2 2 2 2
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 1 1 1 1 2
n2 = W a2 + b = 1 2 + 0 = 2 , a2 = f n2 = 2 = 4
2 2 1 2 2 2 2
n2 = W a2 + b = 2 4 + 1 = 9 , a2 = f n2 = 9 = 9
12-43
12 Variations on Backpropagation
2
e2 = t2 a2 = 2 9 = 7
S 1 = F n 1 = 1
2 2 2
S 1 = F (n 1) W S 1 = 2n 1
1 1 1 2 T 2
= 2 1 2 1 = 4
1 1 2 1
S 2 = F n 2 = 1
2 2 2
2 T 2
S 2 = F (n 2) W S 2 = 2n 2
1 1 1
= 2 2 2 1 = 8
1 2 2 1
1 2
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).
v 1 v 1 v 1 v 1 e 1 1 e 1 1 e 1 1 e 1 1
------- ------- ------- ------- ------------
1
- -----------
1
- ------------
2
- -----------
2
-
x 1 x 2 x 3 x 4 w 1 1 b 1 w 1 1 b 1
Jx = =
v 2 v 2 v 2 v 2 e 1 2 e 1 2 e 1 2 e 1 2
------- ------- ------- ------- ------------
- -----------
- ------------
- -----------
-
x 1 x 2 x 3 x 4 1 1
w 1 1 b 1 w 1 1 b 1
2 2
1 1
v e 1 1 e 1 1 n 1 1 1 n 1 1 1 0
J 1 1 = -------1 = ------------ - ------------
- = ----------- - = s 1 1 ------------
- = s 1 1 a 1 1
x 1 1
w 1 1
1
n 1 1 w 1 1
1
w 1 1
1
= 4 1 = 4
1 1
v e 1 1 e 1 1 n 1 1 1 n 1 1 1
J 1 2 = -------1 = ----------- - -----------
- = ----------- - = s 1 1 -----------
- = s 1 1 = 4
x 2 b 1
1 1
n 1 1 b 1
1
b 1
1
2 2
v e 1 1 n 1 1 2 n 1 1 2 1
J 1 3 = -------1 = -----------
- ------------
- = s 1 1 ------------
- = s 1 1 a 1 1 = 1 1 = 1
x 3 2
n 1 1 w 1 1
2
w 1 1
2
12-44
Solved Problems
1 2
12
v e 1 1 n 1 1 2 n 1 1 2
J 1 4 - -----------
= -------1 = ----------- - = s 1 1 -----------
- = s 1 1 = 1
x 4 2
n 1 1 b 1
2
b 1
2
1 1
v e 1 2 n 1 2 1 n 1 2 1 0
J 2 1 = -------2 = -----------
- ------------
- = s 1 2 ------------
- = s 1 2 a 1 2 = 8 2 = 16
x 1 1
n 1 2 w 1 1
1
w 1 1
1
1 1
v e 1 2 e 1 2 n 1 2 1 n 1 2 1
J 2 2 = -------2 = ----------- - -----------
- = ----------- - = s 1 2 -----------
- = s 1 2 = 8
x 2 b 1
1 1
n 1 2 b 1
1
b 1
1
2 2
v e 1 2 n 1 2 2 n 1 2 2 1
J 2 3 - ------------
= -------2 = ----------- - = s 1 2 ------------
- = s 1 2 a 1 2 = 1 4 = 4
x 3 2
n 1 2 w 1 1
2
w 1 1
2
2 2
v e 1 2 e 1 2 n 1 2 2 n 1 2 2
J 2 4 = -------2 = ----------- - -----------
- = ----------- - = s 1 2 -----------
- = s 1 2 = 1
x 4 b 1
2 2
n 1 2 b 1
2
b 1
2
Jx = 4 4 1 1 .
16 8 4 1
12-45
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 backpropa-
gation was first popularized, there has been considerable work on methods
to accelerate the convergence of the algorithm. In this chapter we have dis-
cussed 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 cat-
egories: heuristic methods and standard numerical optimization methods.
We have discussed two heuristic methods: momentum (MOBP) and vari-
able 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: conju-
gate gradient (CGBP) and Levenberg-Marquardt (LMBP). CGBP is gener-
ally 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 train-
ing 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 bi-
ases in the network. If the network has more than a few thousand param-
eters, 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] E. Barnard, Optimization for training neural nets, IEEE
Trans. on Neural Networks, vol. 3, no. 2, pp. 232240, 1992.
A number of optimization algorithms that have promise for
neural network training are discussed in this paper.
[Batt92] R. Battiti, First- and second-order methods for learning:
Between steepest descent and Newton's method, Neural
Computation, vol. 4, no. 2, pp. 141166, 1992.
This paper is an excellent survey of the current optimiza-
tion algorithms that are suitable for neural network train-
ing.
[Char92] C. Charalambous, Conjugate gradient algorithm for effi-
cient training of artificial neural networks, IEE Proceed-
ings, 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] S. E. Fahlman, Faster-learning variations on back-propa-
gation: An empirical study, In D. Touretsky, G. Hinton &
T. Sejnowski, eds., Proceedings of the 1988 Connectionist
Models Summer School, San Mateo, CA: Morgan Kauf-
mann, pp. 3851, 1988.
The QuickProp algorithm, which is described in this paper,
is one of the more popular heuristic modifications to back-
propagation. It assumes that the error curve can be approx-
imated by a parabola, and that the effect of each weight can
be considered independently. QuickProp provides signifi-
cant speedup over standard backpropagation on many
problems.
[HaMe94] M. T. Hagan and M. Menhaj, Training feedforward net-
works 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 Leven-
berg-Marquardt algorithm is faster, but requires more
storage.
12-47
12 Variations on Backpropagation
12-48
Further Reading
12-49
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 ,
w n a
p
b
1
a = logsig (w p + b)
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 Ex-
ercise E12.1, starting from the initial guess
w 0 = 0 , b 0 = 0.5 .
1 T
F x = --- x 10 6 x + 4 4 x .
2 6 10
12-50
Exercises
x0 = 1 .
2.5
1 T
F x = --- x 3 1 x + 4 4 x .
2 1 3
ii. Is the algorithm stable with this learning rate and this momentum?
Use the ideas presented in Problem P12.2.
iii. Would the algorithm be stable with this learning rate, if the momen-
tum were zero?
1 T
F x = --- x 3 1 x + 1 2 x + 2 .
2 1 3
12-51
12 Variations on Backpropagation
1 T
F x = --- x 2 1 x + 1 2 x + 2 .
2 1 2
E12.7 For the function of Exercise E12.3, perform three iterations of the variable
learning rate algorithm, with initial guess
x0 = 1 .
2.5
Perform three iterations of the variable learning rate algorithm, with ini-
tial guess
x0 = 0 .
1
(Count an iteration each time the function is evaluated after the initial
guess.)
E12.9 For the function of Exercise E12.3, perform one iteration of the conjugate
gradient algorithm, with initial guess
x0 = 1 .
2.5
12-52
Exercises
1 T
F x = --- x 4 0 x + 2 1 x .
2 0 2
x = 0 + 1 .
0 1
ii. The learning rate must fall somewhere between 0 and 3. Perform
one iteration of the golden section search. You should find a 2 , b 2 , c 2
and d 2 , and indicate these points along the line that you drew in
part i.
1 T
F x = --- x 1 1 x + 1 1 x .
2 1 1
x = 0 + 1 .
0 0
ii. Take one iteration of the golden section search to reduce the inter-
val you obtained in part i.
1 T
F x = --- x 1 0 x .
2 0 2
12-53
12 Variations on Backpropagation
x = 1 + 1 .
1 1
1 T
F x = --- x 2 0 x .
2 0 1
x = 0 + 1 .
1 1
E12.14 We want to use the network of Figure E12.2 to approximate the function
g p = 1 + sin --- p for 2 p 2 .
4
0.41 0.13
12-54
Exercises
E12.15 Show that for a linear network the LMBP algorithm will converge to an op-
timum solution in one iteration if = 0 .
E12.16 In Exercise E11.25 you wrote a MATLAB program to implement the SDBP
1
algorithm for a 1 S 1 network, and trained the network to approximate
the function
g p = 1 + sin --- p for 2 p 2 .
4
2+2
ans = Repeat this exercise, modifying your program to use the training proce-
4 dures 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
Theory and Examples 13-2
Problem Statement 13-2
Methods for Improving Generalization 13-5
Estimating Generalization Error - The Test Set 13-6
Early Stopping 13-6
Regularization 13-8
Bayesian Analysis 13-10
Bayesian Regularization 13-12
Relationship Between Early Stopping and Regularization 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 net-
work will overfit the training data. This means that the error on the train-
ing 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 per-
form 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 pa-
rameters 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
Problem Statement
Lets begin our discussion of generalization by defining the problem. We
start with a training set of example network inputs and corresponding tar-
get outputs:
13-2
Problem Statement
{p 1, t 1} { p 2, t 2} {p Q, tQ} . (13.1)
tq = g pq + q , (13.2)
tq aq
T
F x = ED = 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 The problem of overfitting is illustrated in Figure 13.1. The blue curve rep-
resents 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 be-
tween -3 and 0. This is the region where all of the training data points oc-
ccur. 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
Interpolation 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 overfit-
Extrapolation ting, but because there is no training data there. The network is extrapo-
lating beyond the range of the input data.
In this chapter we will discuss methods for preventing errors of interpola-
tion (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 Generalization
25
20
15
10
10
15
20
25
30
3 2 1 0 1 2 3
25
20
15
10
10
15
20
25
30
3 2 1 0 1 2 3
13-4
Methods for Improving Generalization
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 sin-
gle 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 . There-
fore, 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)
8 8
6 6
4 4
2 2
t 0 a 0
2 2
4 4
6 6
3 3
2 2
3 3
1 2 1 2
0 1 0 1
p2 1 0 p2 1 0
2
3 3
2
1
p1 2
3 3
2
1
p1
13-5
13 Generalization
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 mini-
mum of the error surface. By increasing the number of iterations of train-
ing, 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 sec-
tion of this chapter we will demonstrate how the number of parameters
changes as the number of iterations increases.
In order to use early stopping effectively, we need to know when to stop the
Cross-Validation training. We will describe a method, called cross-validation, that uses a
13-6
Methods for Improving Generalization
Validation Set validation set to decide when to stop [Sarl95]. The available data (after re-
moving 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 vali-
dation 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 indi-
ces, F (the sum squared errors), during training. Although the training er-
ror 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 re-
sponse at this early stopping point. The resulting network provides a good
fit to the true function. The graph at the upper right demonstrates the net-
work response if we continue to train to point b, where the validation er-
ror has increased and the network is overfitting.
1.5 1.5
1 a 1 b
0.5 0.5
2 2
a 0 a 0
0.5 0.5
1 1
1.5 1.5
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 0.2 0.4 0.6 0.8 1
p p
3
10
2
Validation
10
a b
F 10
1
Training
0
10
1
10
0 1 2
10 10 10
Iteration
13-7
13 Generalization
The basic concept for early stopping is simple, but there are several practi-
cal 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 perfor-
mance index of Eq. (13.3) to include a term that penalizes network com-
plexity. This concept was introduced by Tikhonov [Tikh63]. He added a
penalty, or regularization, term that involved the derivatives of the approx-
imating 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 n
tq aq tq aq + xi ,
T 2
F x = E D + E W = (13.4)
q=1 i=1
where the ratio controls the effective complexity of the network solu-
tion. The larger this ratio is, the smoother the network response. (Note that
we could have used a single parameter here, but developments in later sec-
tions will require two parameters.)
Why do we want to penalize the sum squared weights, and how is this sim-
ilar to reducing the number of neurons? Consider again the example mul-
tilayer 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 re-
strict the weights to be small, then the network function will create a
13-8
Methods for Improving Generalization
smooth interpolation through the training data - just as if the network had
a small number of neurons.
2
w 1 1 = 2
2
2
a 1
2
w 1 1 = 0
1
2 1 0 1 2
13-9
13 Generalization
1.5 1.5
1 = 0 1
= 0.01
0.5 0.5
0 0
0.5 0.5
1 1
1.5 1.5
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 0.2 0.4 0.6 0.8 1
1.5 1.5
1 = 0.25 1
= 1
0.5 0.5
0 0
0.5 0.5
1 1
1.5 1.5
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 0.2 0.4 0.6 0.8 1
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 = ------------------------------- . (13.5)
P B
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 . Nor-
mally 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
Methods for Improving Generalization
To illustrate how Bayes rule can be used, consider the following medical
2
+2 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. Howev-
er, 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 (includ-
ing 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 de-
tecting 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. (No-
tice 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 prob-
ability 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)
PA B
P B A = ----------------------- , or P A B = P B A P A . (13.7)
P A
P B A P A 0.8 0.01
P A B = ------------------------------- = ------------------------ = 0.0748 . (13.9)
P B 0.107
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 in-
13-11
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 net-
works 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.
P D x M P x M
P x D M = ----------------------------------------------------------- , (13.10)
P D M
where x is the vector containing all of the weights and biases in the net-
work, D represents the training data set, and are parameters associ-
ated 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 in-
dependent and have a Gaussian distribution, then
1
P D x M = --------------- exp E D , (13.11)
ZD
13-12
Methods for Improving Generalization
2 2
where = 1 2 , is the variance of each element of q , E D is the
squared error (as defined in Eq. (13.3)), and
2 N2 N2
Z D = 2 = , (13.12)
M
where N is Q S , as in Eq. (12.34).
Likelihood Function Eq. (13.11) is called the likelihood function. It is a function of the network
weights x , and it describes how likely a given data set is to occur, given a
Maximum Likelihood specific set of weights. The maximum likelihood method selects the weights
so as to maximize the likelihood function, which in this Gaussian case is
the same as minimizing the squared error E D . Therefore, our standard
sum squared error performance index can be derived statistically with the
assumption of Gaussian noise in the training set, and our standard choice
for the weights is the maximum likelihood estimate.
Now consider the second term on the right side of Eq. (13.10): P x M .
Prior Density This is called the prior density. It embodies our knowledge about the net-
work weights before we collect any data. Bayesian statistics allows us to in-
corporate prior knowledge through the prior density. For example, if we
assume that the weights are small values centered around zero, we might
select a zero-mean Gaussian prior density:
1
P x M = ---------------- exp E W (13.13)
ZW
2 2
where = 1 2 w , w is the variance of each of the weights, E W is the
sum squared weights (as defined in Eq. (13.4)), and
2 n2 n2
Z W = 2 w = , (13.14)
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
13-14
Methods for Improving Generalization
P D M P M
P D M = ------------------------------------------------------------ . (13.16)
PD M
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 parame-
ters and , then maximizing the posterior is achieved by maximizing the
likelihood function P D M . However, note that this likelihood func-
tion 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 (13.17)
= -----------------------------------------------------------------------------------------------------
1
--------------------- exp F x
Z F
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 es-
timate 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 Tay-
lor series (see Eq. (8.9)) around its minimum point, x MP , where the gradi-
ent is zero:
1 T MP
F x F x MP + --- x x MP H x x MP , (13.18)
2
MP
where H = 2E D + 2E W is the Hessian matrix of F x , and H is the
Hessian evaluated at x MP . We can now substitute this approximation into
the expression for the posterior density, Eq. (13.15):
1 1 T MP
P x D M ------ exp F x MP --- x x MP H x x MP , (13.19)
ZF 2
13-15
13 Generalization
1 1 T MP
P x D M ------ exp F x MP exp --- x x MP H x x MP . (13.20)
Z
F 2
Therefore, equating Eq. (13.21) with Eq. (13.20), we can solve for Z F :
n2 MP 1 12
Z F 2 det H 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
- and
= ------------------------
MP
-,
= ------------------------
MP
(13.23)
2E W x 2E D x
MP MP 1
Effective # of Parameters where = n 2 tr H is called the effective number of parameters,
and n is the total number of parameters in the network. The term is a
measure of how many parameters (weights and biases) in the neural net-
work are effectively used in reducing the error function. It can range from
zero to n . (See the example on page 13-23 for more analysis of .)
13-16
Methods for Improving Generalization
13-17
13 Generalization
1.5
0.5
0.5
1.5
1 0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8 1
2 3
10 10
Training Testing
2
0
10
10
ED ED
1
10
2
10
0
10
0 1 2 3 0 1 2 3
10 10 10 10 10 10 10 10
Iteration Iteration
1 2
10 10
2
10
10
1
3
10
4 0
10 10
0 1 2 3 0 1 2 3
10 10 10 10 10 10 10 10
Iteration Iteration
13-18
Methods for Improving Generalization
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 net-
work has 61 parameters, it is equivalent to a network with only 6 parame-
ters. 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 sig-
nificant, 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 net-
work and retrain on the data set.
To experiment with Bayesian Regularization, use the MATLAB Neural
Network Design Demonstration Bayesian Regularization (nnd17breg).
T 1 T
F x = c + d x + --- x Ax , (13.24)
2
F x = Ax + d . (13.25)
13-19
13 Generalization
x k + 1 = x k g k = x k Ax k + d . (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)):
ML 1
x = A d , (13.27)
where the superscript ML indicates that this result maximizes the likeli-
hood function, in addition to minimizing the squared error, as we saw in
Eq. (13.11).
We can now rewrite Eq. (13.26) as
1 ML
x k + 1 = x k A x k + A d = x k A x k x . (13.28)
where the initial guess x 0 usually consists of random values near zero.
Continuing to the second iteration:
ML
x 2 = Mx 1 + I M x
2 ML ML
= M x 0 + M I M x + I M x
. (13.31)
2 ML 2 ML ML ML
= M x 0 + Mx M x +x Mx
2 ML 2 ML 2 2 ML
= M x0 + x M x = M x 0 + I M x
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
Methods for Improving Generalization
Regularization Analysis
Recall from Eq. (13.4) that the regularized performance index adds a pen-
alty 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 , (13.34)
W
F x = E D + E W = 0 . (13.36)
E W = 2 x x 0 . (13.37)
From Eq. (13.25) and Eq. (13.28), the gradient of the sum squared error is
1 ML
E D = Ax + d = A x + A d = A x x . (13.38)
F x = A x x
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
MP ML MP MP ML ML
Ax x = 2 x x 0 = 2 x x +x x0
(13.40)
MP ML ML
= 2 x x 2 x x0
MP ML
Now combine the terms multiplying x x :
13-21
13 Generalization
MP ML ML
A + 2I x x = 2 x 0 x . (13.41)
MP ML
Solving for x x , we find
MP ML 1 ML ML
x x = 2 A + 2I x 0 x = M x0 x , (13.42)
1
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 :
MP ML
x = M x 0 + I M x . (13.43)
This is the key result that describes the relationship between the regular-
ized 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.
1
M = I A M = 2 A + 2I
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
Methods for Improving Generalization
2
13
eig M = ---------------------- . (13.45)
i + 2
k
Therefore, in order for M to equal M , they just need to have equal eigen-
values:
2 k
---------------------- = 1 i . (13.46)
i + 2
log 1 + -----i- = k log 1 i . (13.47)
2
1 1 k
--------------------- --- = ----------------- , (13.48)
1 + -----i- 1 i
2
or
1 1 i
k = ------ ---------------------------------
-. (13.49)
2 1 + i 2
1
k ------ . (13.50)
2
13-23
13 Generalization
1 t = 1 , p = 1 t = 1 ,
p1 = 1 2 2
1 1
where the probability of the first pair is 0.75, and the probability of the sec-
ond pair is 0.25. Following Eq. (10.13) and Eq. (10.15), we can find the qua-
dratic mean square error performance index as
2 2 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
A = 2R = 2 E zz = 2 0.75 1 1 1 + 0.25 1 1 1 = 2 1 ,
T
1 1 1 2
T 1 T
E D = c + x d + --- x Ax .
2
E D x = A = 2R = 2 1 .
2
1 2
2 1 2
= 4 + 3 = 1 3 ,
A I =
1 2
1 = 1 2 = 3 .
13-24
Methods for Improving Generalization
A I v = 0 .
For 1 = 1 ,
11 v = 0 v1 = 1 ,
1
11 1
and for 2 = 3 ,
1 1 v = 0 v2 = 1 .
2
1 1 1
0.5
0
x2
0.5
1
0.5 0 0.5 1 1.5
x1
Now consider the regularized performance index of Eq. (13.34). Its Hessian
matrix will be
F x = 2E D + 2E W = 2E D + 2I = 2 1 + 2 0 = 2 + 2 1
2
.
1 2 0 2 1 2 + 2
13-25
13 Generalization
= 1
0.5 = = 0
0
x2
0.5
1
0.5 0 0.5 1 1.5
x1
x MP
0.5 = = 0
0
x2
0.5
1
0.5 0 0.5 1 1.5
x1
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 regulariza-
tion 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 increas-
es, it is equivalent to reducing .
13-26
Methods for Improving Generalization
0.5
0
x2
0.5
1
0.5 0 0.5 1 1.5
x1
13-27
13 Generalization
MP MP 1
= n 2 tr H (13.51)
2
We can express this in terms of the eigenvalues of E D x . First, we can
write the Hessian matrix as
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 re-
ciprocals 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
---------------------
1
tr H = . (13.53)
i + 2
i=1
or
n n
i
= ---------------------
i + 2
= i , (13.55)
i=1 i=1
where
i
i = --------------------- . (13.56)
i + 2
13-28
Summary of Results
Summary of Results
Problem Statement 13
A network trained to generalize will perform as well in new situations as it
does on the data on which it was trained.
Q
tq aq
T
ED = 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 gra-
dients 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
Q n
tq aq tq aq + xi
T 2
F x = E D + E W =
q=1 i=1
Bayesian Regularization
Level I Bayesian Framework
P D x M P x M
P x D M = -----------------------------------------------------------
P D M
13-29
13 Generalization
1 2
P D x M = --------------- exp E D , = 1 2
ZD
2 N2 N2
Z D = 2 =
1 2
P x M = ---------------- exp E W , = 1 2 w
ZW
2 n2 n2
Z W = 2 w =
1
P x D M = --------------------- exp F x
Z F
MP MP N
MP
- and
= ------------------------ = ------------------------
MP
-
2E W x 2E D x
MP MP 1
= n 2 tr H
13-30
Summary of Results
k k
eig M = 1 i
2
eig M = ----------------------
i + 2
1
k ------
2
0n
13-31
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 uniform-
ly distributed between 0 and x. We take a series of Q independent
samples of the random variable. Find the maximum likelihood es-
timate 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
ft x
1
---
x
t
x
1
--- 0 t x
f t x = x .
0 elsewhere
13-32
Solved Problems
1 1
Q
----- 0 t i x for all i ----- x max t i
P D x = f ti x = x Q Q
= x
0 x max t
i=1
0 elsewhere i
P D x
x
max t i
ti = x + i .
Assume that the noise has a Gaussian density, with zero mean:
13-33
13 Generalization
i
2
1
f i = -------------- exp --------
-
2
2
2
1 x2 1
f x = ---------------- exp ----------2- = ---------------- exp E W
2 x 2 x ZW
ti x
2
1
f t i x = -------------- exp ------------------ .
2
2
2
P D x = f t 1 t 2 t Q x = f t 1 x f t 2 x f t Q x = P D x
Q
2
ti x
1 i=1 1
= -------------------------- exp --------------------------- = ----------- exp E D
2
Q2 Q
2
2
Z
where
Q Q
1 Q2
ei , Z
2 2
= --------2- , E D = ti x = = .
2 i=1 i=1
13-34
Solved Problems
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
1
P D x = ----------- exp E D
Z
1 x2 1
P x = f x = ---------------- exp ----------2- = ---------------- exp E W ,
2 x 2 x ZW
where
1 12 2
= ----------2- , Z W = , E W = x .
2 x
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 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
Q Q
d d 2
t i x + x = 2 t i x + 2x
2
E D + E W =
dx d x
i=1 i=1
Q
= 2 t i Qx + 2x
i=1
Q
= 2 t i + Q x = 0
i=1
2 MP
Notice that as goes to zero (variance x goes to infinity), x approach-
ML
es x . Increasing the variance of the prior density represents increased
uncertainty in our prior knowledge about x. With large prior uncertainty,
we rely on the data for our estimate of x, which leads to the maximum like-
lihood estimate.
Figure P13.3 illustrates P D x , P x and P x D for the case where
2 2
x = 2 , = 1 , Q = 1 and t 1 = 1 . Here the variance associated with the
measurement is smaller than the variance associated with our prior densi-
MP ML
ty for x , so x is closer to x = t 1 = 1 than it is to the maximum of the
prior density, which occurs at 0.
To experiment with this signal in noise example, use the MATLAB Neural
Network Design Demonstration Signal Plus Noise (nnd13spn).
13-36
Solved Problems
0.6
Px D
0.4
PD x
0.2
Px
0
MP
x
3 2 1 0 1 2 3
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
n
1 1 h
--- log det H = ----------------
2 2det H
k=1
n
1
= ---------------- i + 2
b
2det H
i=1
n
j + 2 i + 2
1 b b
= ----------------
2det H
i = 1 ji
n
j + 2
b
ji
= i---------------------------------------------
=1
n
-
i + 2
b
i=1
n
1 1
= ------------------
b
+ 2
- = tr H
i=1 i
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 n n n
i
b b
1 1 ------------------
2 i
= n 2 ------------------
- = - = ------------------
- = -----
+ 2
b b b h
i=1
i + 2 i=1 i i=1 i + 2
i=1
i
1 MP
Now take the derivative of --- log det H with respect to .
2
13-38
Solved Problems
n
1 1 h
--- log det H = ---------------- k
2 2det H
k=1
1
n
= ---------------- i + 2
b
13
2det H
i=1
n
j + 2 i + 2
1 b b
= ----------------
2det H
i = 1 ji
n
i
b
j + 2 -----
b
1 = 1 ji
= --- i--------------------------------------------------------
n
-
2
i + 2
b
i=1
n b
1 i
= ------ ------------------
b
- = ------
2 + 2 2
i=1 i
b
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 eigen-
b
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 1 MP n
log P D M = F w --- logdet H + --- log
2 2
MP MP 1 n
= E W w tr H + ------------
-
2
MP
MP MP 1 n
= EW w tr H + ------------
MP
-=0
2
MP n MP 1
EW w = ------------
MP
- tr H
2
MP MP MP MP 1
2 EW w = n 2 tr H =
MP
= --------------------------
MP
-
2E W w
13-39
13 Generalization
MP 1 MP N
log P D M = F w --- logdet H + ---- log
2 2
MP N
= E D w ------------ + ------------
2
MP
2
MP
MP N
= ED w ------------
MP
+ ------------
MP
=0
2 2
Rearranging terms,
MP N
ED w = ------------
MP
------------
MP
2 2
MP N
= --------------------------
MP
2E D w
3
3 2 1 0 1 2 3
13-40
Solved Problems
The result of the training is shown in Figure P13.5. The neural network ap-
proximation 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 ran-
dom weights, the network might underestimate the true function in this re-
gion. 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)
8 8
6 6
4 4
2 2
t 0 a 0
2 2
4 4
6 6
3 3
2 2
3 3
1 2 1 2
0 1 0 1
0 0
p2 1
2 2
1
p1 p2 1
2 2
1
p1
3 3 3 3
P13.5 Consider the example starting on page 13-23. Find the effective
number of parameters if = 1 .
= --- = 1 .
13-41
13 Generalization
v2 = 1 ,
1
which means that we are changing w 1 1 and w 1 2 by the same amount. Al-
though 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.
tq gk pq
2
Fx =
q=1
First, we want to express the problem in matrix form. Define the following
vectors.
k
1 p1 p1
t1 x0
k
t =
t2 G = 1 p2 p2 x =
x1
k
tQ 1 pQ pQ xk
13-42
Solved Problems
To locate the minimum, we take the gradient and set it equal to zero.
T 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 ML T ML T 1 T
G G x = G t x = G G G t
To demonstrate the operation of the polynomial fitting, we will use the sim-
ple linear function t = p . To create the data set, we will sample the func-
tion 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 = p = -1:.5:1;
4 t = p + 0.5*(rand(size(p))-0.5);
Q = length(p);
ord = 4;
G = ones(Q,1);
for 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
1 4th Order
0.5
0.5
1
1 0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8 1
13-43
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 reg-
ularization, 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 pre-
vent 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] S. Amari, N. Murata, K.-R. Muller, M. Finke, and H. H.
Yang, Asymptotic Statistical Theory of Overtraining and
Cross-Validation, IEEE Transactions on Neural Net- 13
works, vol. 8, no. 5, 1997.
When using early stopping, it is important to decide on the
number of data points to place in the validation set. This
paper provides a theoretical basis for the choice of valida-
tion set size.
[FoHa97] D. Foresee and M. Hagan, Gauss-Newton Approximation
to Bayesian Learning, Proceedings of the 1997 Interna-
tional Joint Conference on Neural Networks, vol. 3, pp.
1930 - 1935, 1997.
This paper describes a method for implementing Bayesian
regularization by using the Gauss-Newton approximation
to the Hessian matrix.
[GoLa98] C. Goutte and J. Larsen, Adaptive Regularization of Neu-
ral 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 proce-
dure for setting the regularization parameter to minimize
the validation set error.
[MacK92] D. J. C. MacKay, Bayesian Interpolation, Neural Compu-
tation, vol. 4, pp. 415-447, 1992.
Bayesian approaches have been used for many years in sta-
tistics. This paper presents one of the first developments of
a Bayesian framework for training neural networks.
MacKay followed this paper with many others describing
refinements of the approach.
[Sarle95] W. S. Sarle, Stopped training and other remedies for over-
fitting, 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 de-
scribes simulation results comparing early stopping with
other methods for improving generalization.
13-45
13 Generalization
13-46
Exercises
Exercises
E13.1 Consider fitting a polynomial (kth order)
2 k
gk p = x0 + x1 p + x2 p + + xk p
tq gk pq
2
Fx =
q=1
tq gk pq + xi
2 2
Fx =
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 Q
2
d
tq gk p q +
2
Fx = g p
dp k q
q=1 i=1
iv. Derive a solution for the weights that minimizes a sum of the
squared error plus a sum of squared second derivatives.
Q Q 2 2
d
t q g k p q +
2
F x = g p
2 k q
q=1 i=1
dp
E13.2 Write a MATLAB program to implement the solutions you found in E13.1
2+2
i. through iv. Using the following data points, adjust the values to obtain
ans = the best results. Use k = 8 for all cases. Plot the data points, the noise-free
4 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 com-
mand in MATLAB).
p1 = 1 t1 = 4 , p2 = 2 t2 = 6 .
i. Find the least squares solutions for the weights x 0 and x 1 that min-
imize the following sum squared error performance index:
2
tq g 1 pq
2
Fx = .
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 1
tq g 1 p q xi .
2 2
F x = +
q=1 i=0
13-48
Exercises
f t x = ----2 exp --
t t
t0
x x
E13.6 For the random variable t given in E13.5, suppose that x is a random vari-
able with the following prior density function. Find the most probable esti-
MP
mate of x ( x ).
f x = exp x x0
E13.7 Repeat E13.6 for the following prior density function. Under what condi-
MP ML
tions will x = x ?
x x
2
1
f x = ---------------- exp --------------------
-
2 x
2
2 x
MP
E13.8 In the signal plus noise example given in Solved Problem P13.2, find x
for the following prior density functions.
i. f x = exp x x0
1
ii. f x = --- exp x
2
exp t x tx
ft x =
0 tx
For the random variable t above, suppose that x is a random variable with
the following prior density function.
1 2
f x = -------------- exp 2x
2
13-49
13 Generalization
MP
iv. Find the most probable estimate of x ( x ).
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 natu-
ral log of p t x before finding the maximum.) Is it reasonable? Ex-
plain.
pt x = x 1 x , where = ----------------------
10 t 10 t 10 10!
t t t! 10 t
2
p x = 12x 1 x , 0 x 1 .
E13.11 Suppose that the prior density in the level I Bayesian analysis (see page 13-
12) has nonzero mean, x . Find the new performance index.
2 t = 1 p = 2 t = 3
p1 = 1 2 2
1 1
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.
MP
ii. Find x and the effective number of parameters .
iii. Sketch the contour plot of the regularized performance index.
iv. Find the maximum stable learning rate if steepest descent is used
to train the network.
v. Find the initial direction for the steepest descent algorithm trajec-
tory, if both initial weights are set to zero.
vi. Sketch an approximate complete trajectory (on your contour plot
from part iii.) for the steepest algorithm, with very small learning
rate, from the initial conditions where both weights are set to zero.
Explain your procedure for sketching the trajectory.
E13.14 Suppose that we have a single layer, linear network with no bias. The in-
put/target pairs of the training set are given by
1 t = 2 , p = 1 t = 2 , p = 2 t = 4 ,
p1 = 1 2 2 3 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 itera-
tions 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 .
E13.15 Repeat E11.25, but modify your program to use early stopping and to use
2+2
30 neurons. Select 10 training points and 5 validation points. Add noise to
ans = the validation and testing points that is uniformly distributed between
4 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 re-
sults without early stopping.
13-51
13 Generalization
E13.16 Repeat E13.15, but use regularization instead of early stopping. This will
2+2
require modifying your program to compute the gradient of the regularized
ans = performance index. Add the standard gradient of the squared error, which
4 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.
13-52
Objectives
14 Dynamic Networks
Objectives 14-1
Theory and Examples 14-2
Layered Digital Dynamic Networks 14-3
Example Dynamic Networks 14-5
Principles of Dynamic Learning 14-8
Dynamic Backpropagation 14-12
Preliminary Definitions 14-12
Real Time Recurrent Learning 14-12
Backpropagation-Through-Time 14-22
Summary and Comments on Dynamic Training 14-30
Summary of Results 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 out-
put 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 net-
works, 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 dy-
namic 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 Ja-
cobians (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 Dynamic Networks
14-2
Layered Digital Dynamic Networks
T
D LW1,1
1
L a (t)
1
p (t)1 n (t) 2
a (t) a3(t)
T
1,1 2,1 3,2
IW D LW LW n3(t)
n2(t)
1
R x1 S2x1 3
S1xR
1 L S2xS1
2
S3xS2
3 S x1
f 1
S x1 2
f f
S x1 S3x1
1 b 1 1
S x1 1 b 2
1 b 3
1 1 2 3
R S1x1 S S2x1 S S3x1 S
T T
D LW1,3 D LW2,3
L L
m l
m l
n t = LW d a t d
l L m d DL m l
f
(14.1)
m l
l m
+ IW d p t d + b
l Im d DI m l
l m l
where p t is the l th input vector to the network at time t, IW is the
m l
Input Weight input weight between input l and layer m, LW is the layer weight be-
m
Layer Weight tween layer l and layer m, b is the bias vector for layer m, DL m l is the set
of all delays in the tapped delay line between Layer l and Layer m, DI m l is
the set of all delays in the tapped delay line between Input l and Layer m,
14-3
14 Dynamic Networks
f
I m is the set of indices of input vectors that connect to layer m, and L m is
the set of indices of layers that directly connect forward to layer m. The out-
put of layer m is then computed as
m m m
a t = f n t . (14.2)
Compare this with the static multilayer network of Eq. (11.6). LDDN net-
works can have several layers connecting to layer m. Some of the connec-
tions 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.
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
Simulation Order output is called the simulation order. (This order need not be unique; there
may be several valid simulation orders.) In order to backpropagate the de-
rivatives for the gradient calculations, we must proceed in the opposite or-
Backpropagation Order der, which is called the backpropagation order. In Figure 14.1, the
standard numerical order, 1-2-3, is the simulation order, and the backprop-
agation 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
Layered Digital Dynamic Networks
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.
p(t) iw1,1(0)
a(t) = iw1,1(0)p(t)+iw1,1(1)p(t-1)+iw1,1(2)p(t-2)
1 1 1
iw 1 1 0 = --- , iw 1 1 1 = --- , iw 1 1 2 = --- . (14.3)
3 3 3
at = n t = IW d p t d (14.4)
d=0
= 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 Dynamic Networks
The response of the network is shown in Figure 14.3. The open circles rep-
resent 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 net-
FIR work is called a Finite Impulse Response (FIR) filter.
1.5
0.5
0.5
1.5
0 5 10 15 20 25
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 = --- . (14.6)
2 2
14-6
Layered Digital Dynamic Networks
1.5
0.5
0.5
1.5
0 5 10 15 20 25
14-7
14 Dynamic Networks
e tt a t
2 2
Fx = t = . (14.7)
t=1 t=1
Q Q
2
F x e t a t
--------------- =
iw 1 1 --------------- = 2 e t ---------------
iw 1 1 iw 1 1
(14.9)
t=1 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 --------------- . (14.10)
lw 1 1 1 iw 1 1
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 re-
current networks, the weights have two effects on the network output. The
first is the direct effect, which is also seen in the corresponding static net-
work. The second is an indirect effect, caused by the fact that one of the net-
work inputs is a previous network output. Lets compute the derivatives of
the network output, in order to demonstrate these two effects.
14-8
Principles of Dynamic Learning
a t = lw 1 1 1 a t 1 + iw 1 1 p t . (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 ------------------------ , (14.12)
lw 1 1 1 lw 1 1 1
a t a t 1
--------------- = p t + lw 1 1 1 ---------------------- . (14.13)
iw 1 1 iw 1 1
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 in-
direct 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 under-
estimate 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) 2 b) 1.5
Total Derivative
1.5
Static Derivative
1
0 0
0.5
0.5
1
1.5
2 1.5
0 5 10 15 20 25 0 5 10 15 20 25
In Figure 14.7 we see similar results for the weight lw 1 1 1 . The key ideas
to get from this example are: 1) the derivatives have static and dynamic
components, and 2) the dynamic component depends on other time points.
14-9
14 Dynamic Networks
a) 2 b) 1.5
1.5
1
Original Response
0.5
Incremental Response
0.5
0 0
0.5
0.5
1
1.5 Total Derivative
Static Derivative
2 1.5
0 5 10 15 20 25 0 5 10 15 20 25
p(t)
a(t)
Multilayer Network
a(t) = NN(p(t),a(t-1),x)
D
14-10
Principles of Dynamic Learning
Q
e
F a t T F
------ =
x ------------
x
T
------------ ,
a t
(14.14)
t=1
or
Q T
e
F at F
------ =
x --------------
x
T
- ------------ .
a t
(14.15)
t=1
and
e e
F F at + 1 F
- ---------------------- .
------------ = ------------ + ----------------------- (14.17)
a t a t T
a t a t + 1
Eq. (14.14) and Eq. (14.16) make up the real-time recurrent learning
RTRL (RTRL) algorithm. Note that the key term is
a t
------------
T
, (14.18)
x
which must be propagated forward through time. Eq. (14.15) and Eq.
BPTT (14.17) make up the backpropagation-through-time (BPTT) algorithm.
Here the key term is
F
------------ (14.19)
a t
14-11
14 Dynamic Networks
Dynamic Backpropagation
In this section, we will develop general RTRL and BPTT algorithms for dy-
namic networks represented in the LDDN framework. This development
will involve generalizing Eq. (14.14) through Eq. (14.17).
Preliminary Definitions
In order to simplify the description of the training algorithm, some layers
of the LDDN will be assigned as network outputs, and some will be as-
Input Layer signed as network inputs. A layer is an input layer if it has an input weight,
or if it contains any delays with any of its weight matrices. A layer is an
Output Layer output layer if its output will be compared to a target during training, or if
it is connected to an input layer through a matrix that has any delays as-
sociated with it.
For example, the LDDN shown in Figure 14.1 has two output layers (1 and
3) and two input layers (1 and 2). For this network the simulation order is
1-2-3, and the backpropagation order is 3-2-1. As an aid in later deriva-
tions, we will define U as the set of all output layer numbers and X as the
set of all input layer numbers. For the LDDN in Figure 14.1, U={1,3} and
X={1,2}.
The general equations for simulating an arbitrary LDDN network are giv-
en in Eq. (14.1) and Eq. (14.2). At each time point, these equations are it-
erated forward through the layers, as m is incremented through the
simulation order. Time is then incremented from t = 1 to t = Q .
Eq. (14.14)
The first step in developing the RTRL algorithm is to generalize Eq.
(14.14). For the general LDDN network, we can calculate the terms of the
gradient by using the chain rule, as in
Q T
u e
F a t F
------ =
x --------------
x
T
- --------------
u
a t
- . (14.20)
t = 1u U
14-12
Dynamic Backpropagation
Eq. (14.16)
The next step of the development of the RTRL algorithm is the generaliza-
tion of Eq. (14.16). Again, we use the chain rule:
u e u e u e x u'
a t a t a t n t a t d
--------------
T
-+
- = ----------------
T -----------------T --------------------------T- ------------------------
T
- . (14.21)
x x x
u' U x X d DL x u' n t
u'
a t d x
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 be-
fore it is input to another layer. That is the reason for the first two summa-
tions 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
- (14.22)
x
(14.24)
l
R
x l
iwk i d' p i t d'
l x
+ + bk
l Ix d' DI x l i = 1
14-13
14 Dynamic Networks
u m u m u m
s 1 1 t s 1 2 t s 1 Sm t
e u u m u m u m
u m a t s 2 1 t s 2 2 t s 1 Sm t
S t = ------------------T- = , (14.27)
m
n t
u m u m u m
s Su 1 t s Su 2 t s S u Sm t
or in matrix form
e u e x
a t n t u x x u'
-----------------T --------------------------T- = S t LW d . (14.29)
x u'
n t a t d
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 x u
E LW x = u U LW d 0 d 0 , (14.31)
14-14
Dynamic Backpropagation
X X
The difference between E S u and E S u is that E S u contains only input
layers. E S u will not be needed in the simplification of Eq. (14.30), but it
will be used for the calculation of sensitivities in Eq. (14.38).
Using Eq. (14.31) and Eq. (14.32), we can rearrange the order of the sum-
mations in Eq. (14.30) and sum only over nonzero terms:
u e u
a t a t
--------------
T
- = ----------------
T
-
x x
u' . (14.34)
u x x u' a t d
+ S t LW d ------------------------
x
T
-
X d DL x u'
x ES u u'
U
E LW x
Eq. (14.34) makes up the generalization of Eq. (14.16) for the LDDN net-
u m
work. It remains to compute the sensitivity matrices S t and the explic-
e 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
u u
e u
ak t f n i t for i = k
s k i t = ----------------
- = , uU, (14.35)
u
n i t 0 for i k
where F n t is defined as
u u
f n 1 t
u u
0 0
u u
F n t =
u u 0 f n2 t 0 (14.37)
f n Su t
u u
0 0
u m
(see also Eq. (11.34)). The matrices S t can be computed by backpropa-
gating through the network, from each network output, using
u m u l l m
0 F n t , u U ,
m
m
S t = S t LW (14.38)
b
l ES u Lm
14-15
14 Dynamic Networks
Explicit Derivatives
We also need to compute the explicit derivatives
e u
a t
-.
----------------
T
(14.39)
x
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 ak t ni t u m l
----------------------
m l m
- ----------------------
- = ---------------- m l
- = s k i t p j t d . (14.40)
iw i j d n i t iw i j d
and in a similar way we can derive the derivatives for layer weights and
biases:
e u
a t l T u m
-------------------------------------------T- = a t d S t , (14.43)
m l
vec LW d
e u
a t u m
----------------T- = S t , (14.44)
m
b
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 Kroneck-
er product of A and B [MaNe99].
The total RTRL algorithm for the LDDN network is summarized in the fol-
lowing pseudo code.
14-16
Dynamic Backpropagation
14-17
14 Dynamic Networks
a t = n t = iw 1 1 0 p t + iw 1 1 1 p t 1 + iw 1 1 2 p t 2 .
t t a t e
2 2 2 2 2
F = = t = e 1 + e 2 + e 3 ,
t=1 t=1
p 1 t 1 p 2 t 2 p 3 t 3 .
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 im-
mediately 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
1 1
1 = F n 1 = 1 ,
1 1
S
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
a 1 a1 1 T 1 1
------------------------------------------T = ----------------------- = p 1 S t = p 1 ,
vec IW 0
1 1 iw 1 1 0
e 1 e
a 1 a1 1 T 1 1
------------------------------------------T = ----------------------- = p 0 S t = p 0 ,
vec IW 1
1 1 iw 1 1 1
e 1 e
a 1 a1 1 T 1 1
------------------------------------------T = ----------------------- = p 1 S t = p 1 .
vec IW 2
1 1 iw 1 1 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 re-
spect to the weights, using Eq. (14.20):
Q T 3 T
u e 1 e
F a t F a t F
------ =
x --------------
x
T
- --------------
u
a t
- = --------------
x
T
- --------------
1
a t
- .
t = 1u U t=1
F
----------------------- = p 1 2e 1 + p 2 2e 2 + p 3 2e 3 ,
iw 1 1 0
F
----------------------- = p 0 2e 1 + p 1 2e 2 + p 2 2e 3 ,
iw 1 1 1
F
----------------------- = p 1 2e 1 + p 0 2e 2 + p 1 2e 3 .
iw 1 1 2
We can then use this gradient in any of our standard optimization algo-
rithms from Chapters 9 and 12. Note that if we use steepest descent, this
result is a batch form of the LMS algorithm (see Eq. (10.33)).
2 Lets now do an example using a recurrent neural network. Consider again
+2
the simple recurrent network in Figure 14.4. From Eq. (14.5), the equation
of operation of this network is
a t = lw 1 1 1 a t 1 + iw 1 1 p t
14-19
14 Dynamic Networks
U = 1 , X = 1 , I 1 = 1 , DI 1 1 = 0 ,
f U
DL 1 1 = 1 , L 1 = 1 , E LW 1 = 1 .
e
2 2 2 2 2
F = t t a t = t = e 1 + e 2 + e 3 ,
D t=1 t=1
p 1 t 1 p 2 t 2 p 3 t 3 .
We initialize with
X
U = , E S 1 = , E S 1 = .
In addition, the initial condition for the delay, a 0 , and the initial deriva-
tives
a 0 a 0
--------------- and -----------------------
iw 1 1 lw 1 1 1
a 1 = lw 1 1 1 a 0 + iw 1 1 p 1
since the transfer function is linear. We also update the following sets:
X
ES 1 = 1 , ES 1 = 1 .
e 1 e
a 1 a1 1 T 1 1
-------------------------------------------T- = ----------------------- = a 0 S 1 = a 0 .
vec LW 1
1 1 lw 1 1 1
14-20
Dynamic Backpropagation
The next step is to compute the total derivative, using Eq. (14.34):
1 e 1 1
a t a t 1 1 1 1 a t 1
--------------
T
- + S t LW 1 -----------------------
- = ----------------
T T
-. (14.45)
x x x
Replicating this formula for each of our weights for this network, for t = 1 ,
we have
a 1 a 0
--------------- = p 1 + lw 1 1 1 --------------- = p 1 ,
iw 1 1 iw 1 1
a 1 a 0
----------------------- = 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 e
a2 a2
---------------- = p 2 , ----------------------- = a 1 ,
iw 1 1 lw 1 1 1
a 2 a 1
--------------- = p 2 + lw 1 1 1 --------------- = p 2 + lw 1 1 1 p 1 ,
iw 1 1 iw 1 1
a 2 a 1
----------------------- = a 1 + lw 1 1 1 ----------------------- = a 1 + lw 1 1 1 a 0 ,
lw 1 1 1 lw 1 1 1
e 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 3 a 2 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 Dynamic Networks
The final step is to compute the derivatives of the performance index with
respect to the weights, using Eq. (14.20):
Q T 3 T
u e 1 e
F a t F a t F
------ =
x --------------
x
T
- --------------
u
a t
- = --------------
x
T
- --------------
1
a t
- .
t = 1u U t=1
F a 1 a 2 a 3
--------------- = --------------- 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
F a 1 a 2 a 3
----------------------- = ----------------------- 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 prac-
tice, 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 net-
works.
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
u
Q S e u e m
F F ak t ni t
----------------------
m l
lw i j d
- = --------------
u
- ----------------
m
- ----------------------
m l
- (14.46)
t=1 u U k = 1 a k t n i t lw i j d
(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
(14.47)
lw i j d
The terms of the gradient for the layer weights can then be written
Q
F
d i t aj t d ,
m l
----------------------
m l
- = (14.49)
lw i j d
t=1
u m T F
m
d t = S t --------------
u
- (14.52)
uU a t
where
T
F F F F
- = --------------
-------------- u u
- ----------------
- -------------- u (14.53)
u
a t a 1 t a 2 t a S u t
and by similar steps we can find the derivatives for the biases and input
weights:
14-23
14 Dynamic Networks
Q
F T
d
m l
-------------------------
m l
- = t p t d , (14.55)
IW d t=1
Q
F
d
m
--------m- = t . (14.56)
b 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 generaliza-
tion of Eq. (14.17). Again, we use the chain rule:
e
F F
--------------
u
- = --------------
u
-
a t a t
e u' e x T (14.57)
a t + d n t + d F
+ --------------------------T- --------------------------
x u T
- ------------------------
u'
a t + d
-
u' U x X d DL x u n t + d a t
F
---------------
u'
(14.58)
a t
14-24
Dynamic Backpropagation
e
F F
--------------
u
- = --------------
u
-
a t a t
(14.60)
u' x x u T F
+ S t + d LW d ------------------------
u'
a t + d
-
u' U x X d DL x u
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 x u
E LW u = x X LW d 0 d 0 , (14.61)
U u x
E S x = u U S 0 . (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
(14.63)
x u T u' x T F
+ LW d S t + d ------------------------
u'
a t + d
-
x E LW u d DL x u
X U
u' E S x
Summary
The total BPTT algorithm is summarized in the following pseudo code.
14-25
14 Dynamic Networks
14-26
Dynamic Backpropagation
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 first step in the derivative calculation will be the sensitivity calcula-
tion. For BPTT, we start at the last time point ( t = 3 ):
1 1
3 = F n 3 = 1 ,
1 1
S
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
---------------
1
- = 2e 3 .
- = ---------------
1
a 3 a 3
1 1 1 T F
d 3 = S 3 ---------------
1
- = 2e 3 .
a 3
1 1 1 T F
d 2 = S 2 ---------------
1
- = 2e 2 ,
a 2
1 1 1 T F
d 1 = S 1 ---------------
1
- = 2e 1 .
a 1
14-27
14 Dynamic Networks
3 3
F F T
d 2e t p t 1 ,
1 1
- = ----------------------- =
------------------------- t p t 1 =
IW 1
1 1 iw 1 1 1
t=1 t=1
3 3
F F T
d 2e t p t 2 .
1 1
- = ----------------------- =
------------------------- t p t 2 =
IW 2
1 1 iw 1 1 2
t=1 t=1
Note that this is the same result we obtained for the RTRL algorithm ex-
ample on page 14-19. RTRL and BPTT should always produce the same
gradient. The only difference is in the implementation.
2 Lets now use our previous recurrent neural network example of Figure
+2
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 de-
rivatives:
a 4 a 4
--------------- and ----------------------- ,
iw 1 1 lw 1 1 1
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
since the transfer function is linear. We also update the following sets:
X
ES 1 = 1 , ES 1 = 1 .
14-28
Dynamic Backpropagation
e
F F 1 1 T 1 1 T F
--------------
1
- + LW 1 S t + 1 -----------------------
- = --------------
1 1
-
a t a t a t + 1
For t = 3 , we find
0
e e
F F 1 1 T F F
---------------
1
- + lw 1 1 1 S 4 ---------------
- = ---------------
1 1 1
- = 2e 3
- = ---------------
a 3 a 3 a 4 a 3
and
1 1 1 T F
d 3 = S 3 ---------------
1
- = 2e 3
a 3
Continuing to t = 2 ,
1 1
2 = F n 2 = 1 ,
1 1
S
e
F F 1 1 T F
---------------
1 1
- + lw 1 1 1 S 3 ---------------
- = --------------- 1
-
a 2 a 2 a 3
= 2e 2 + lw 1 1 1 2e 3
and
1 1 1 T F
d 2 = S 2 ---------------
1
- = 2e 2 + lw 1 1 1 2e 3
a 2
Finally, for t = 1 ,
1 1
1 = F n 1 = 1 ,
1 1
S
e
F F 1 1 T F
---------------
1
- + lw 1 1 1 S 2 ---------------
- = ---------------
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 1 1 T F 2
d 1 = S 1 ---------------
1
- = 2e 1 + lw 1 1 1 2e 2 + lw 1 1 1 2e 3
a 1
Now we can compute the total gradient, using Eq. (14.54) and Eq. (14.55):
14-29
14 Dynamic Networks
3
F F T
d
1 1
- = ----------------------- =
--------------------------- t a t 1
LW 1
1 1 lw 1 1 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
3
F F T
d
1 1
- = --------------- =
------------------------- t p t
IW 0
1 1 iw 1 1
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.
14-30
Dynamic Backpropagation
14-31
14 Dynamic Networks
The input sequence that we use to train a dynamic network must be repre-
sentative of all possible input sequences. Because this network is so simple,
it is not difficult to find an appropriate input sequence, but for many prac-
tical networks it can be difficult. We will use a standard form of input se-
quence (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 repre-
sent 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).
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
1
0 2 4 6 8 10 12 14 16 18 20
14-32
Dynamic Backpropagation
F
1.5
1.4
1 1.2
1
0.5
0.8
lw 1 1 1 0 0.6
0.4
0.5
0.2
0
1
14
2
1 2
1.5 1
0
lw 1 1 1
0
1
1
2
2 1.5 1 0.5 0 0.5 1 1.5 2 2 2 iw 1 1
iw 1 1
14-33
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
D For all u U , if E S u L m
b
u m u l l m
0 F n t
m
m
S t = S t LW
b
l ES u Lm
add m to the set E S u
X
if m X , add m to the set E S u
EndFor u
If m U
m m
S t = F n t
m m
14-34
Summary of Results
14-35
14 Dynamic Networks
Definitions/Notation
l
p t is the lth input vector to the network at time t.
m
n t is the net input for layer m.
m
f is the transfer function for layer m.
m
a t is the output for layer m.
m l
D IW is the input weight between input l and layer m.
m l
LW is the layer weight between layer l and layer m.
m
b is the bias vector for layer m.
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
L m is the set of indices of layers that directly connect forward to layer m.
b
L m is the set of indices of layers that are directly connected backwards to
layer m (or to which layer m connects forward) and that contain no delays
in the connection.
A layer is an input layer if it has an input weight, or if it contains any de-
lays with any of its weight matrices. The set of input layers is X.
A layer is an output layer if its output will be compared to a target during
training, or if it is connected to an input layer through a matrix that has
any delays associated with it. The set of output layers is U.
e u
u m ak t
The sensitivity is defined s k i t ----------------
m
-.
n i t
U x u
E LW x = u U LW d 0 d 0
X u x
E S u = x X S 0
u x
E S u = x S 0
X x u
E LW u = x X LW d 0 d 0
U u x
E S x = u U S 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:
2 3
9 9
1
1
2 3 1 4 5 1 6
1
3 2
3 2 1 2 4
7 8 1 9 10
2 3 2 1
14-37
14 Dynamic Networks
f f f f f
D L 6 = 2 5 , L 7 = 2 , L 8 = 7 , L 9 = 4 8 , L 10 = 6 9 .
b b b b b
L 1 = 2 , L 2 = 3 6 7 , L 3 = , L 4 = 5 9 , L 5 = ,
b b b b b
L 6 = 10 , L 7 = 4 8 , L 8 = , L 9 = 10 , L 10 = .
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 .
U U
E LW 6 = 5 , E LW 9 = 8 .
X X
E LW 5 = 6 , E LW 8 = 9 .
14-38
Solved Problems
P14.2 Write out the BPTT equations for the network presented in Prob-
lem 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 backpropa-
gation order, which is the reverse of the simulation order:
10 9 8 6 5 4 7 3 2 1 .
10 10
t = F n t
10 10
S
e
F F
----------------
10
- = ----------------
10
-
a t a t
10 10 10 T F
d t = S t ----------------
10
-
a t
10 9 10 10 10 9
0 F n t
9 9
S t = S t LW
9 10 9 T F
d t = S t ----------------
10
-
a t
8 8
t = F n t
8 8
S
e
F F 9 8 T 10 9 T F
8 8
- + LW 1 S
- = --------------
-------------- t + 1 -------------------------
10
-
a t a t a t + 1
8 8 8 T F
d t = S t --------------
8
-
a t
10 6 10 10 10 6
0 F n t
6 6
S t = S t LW
6 10 6 T F
d t = S t ----------------
10
-
a t
5 5
t = F n t
5 5
S
e
F F 6 5 T 10 6 T F 6 5 T 10 6 T F
--------------
5
- + LW 1 S t + 1 -------------------------
- = --------------
5 10
- + LW 0 S t ----------------
10
-
a t a t a t + 1 a t
5 5 5 T F
d t = S t --------------
5
-
a t
14-39
14 Dynamic Networks
10 4 10 9 9 4
0 F n t
4 4
S t = S t LW
5 4 5 5 5 4
0 F n t
4 4
S t = S t LW
4 4
t = F n t
4 4
S
e
F F 4 4 T 4 4 T F 5 4 T F 10 4 T F
- = --------------
-------------- - + S t + 1 -----------------------
- + LW 1 S t + 1 ----------------------- - + S t + 1 -------------------------
-
D 4
a t
4
a t
4
a t + 1
5
a t + 1
10
a t + 1
4 4 4 T F 5 4 T F 10 4 T F
d t = S 4
- + S t --------------
t -------------- 5
- + S t ----------------
10
-
a t a t a t
10 7 10 4 4 7
0 F n t
7 7
S t = S t LW
8 7 8 8 8 7
0 F n t
7 7
S t = S t LW
5 7 5 4 4 7
0 F n t
7 7
S t = S t LW
4 7 4 4 4 7
0 F n t
7 7
S t = S t LW
7 10 7 T F 8 7 T F 5 7 T F 4 7 T F
d t = S 10
- + S t --------------
t ---------------- 8
- + S t --------------
5
- + S t --------------
4
-
a t a t a t a t
3 3
t = F n t
3 3
S
e
F F 4 3 T 4 4 T F 5 4 T F 10 4 T F
--------------
3
- + LW 1 S t + 1 -----------------------
- = --------------
3 4
- + S t + 1 -----------------------
5
- + S t + 1 -------------------------
10
-
a t a t a t + 1 a t + 1 a t + 1
3 3 3 T F
d t = S t --------------
3
-
a t
10 2 10 6 6 2 10 7 7 2
0 F n t + S t LW 0 F n t
2 2 2 2
S t = S t LW
8 2 8 7 7 2
0 F n t
2 2
S t = S t LW
5 2 5 7 7 2
0 F n t
2 2
S t = S t LW
4 2 4 7 7 2
0 F n t
2 2
S t = S t LW
3 2 3 3 3 2
0 F n t
2 2
S t = S t LW
14-40
Solved Problems
2 2
t = F n t
2 2
S
e
F F 2 2 T 2 2 T F 3 2 T F
2
- = --------------
-------------- 2 2
- + S t + 1 -----------------------
- + LW 1 S t + 1 ----------------------- 3
-
a t a t a t + 1 a t + 1
4 2 T F 5 2 T F
+S 4
- + S t + 1 -----------------------
t + 1 ----------------------- 5
-
a t + 1 a t + 1
F F
+S
8 2 T
-+S
t + 1 -----------------------
8
a t + 1
10 2 T
t + 1 -------------------------
10
a t + 1
- 14
2 10 2 T F 8 2 T F 5 2 T F
d t = S 10
- + S t --------------
t ---------------- 8
- + S t --------------
5
-
a t a t a t
4 2 T F 3 2 T F 2 2 T F
+ S 4
- + S t --------------
t -------------- 3
- + S t --------------
2
-
a t a t a t
10 1 10 2 2 1
0 F n t
1 1
S t = S t LW
8 1 8 2 2 1
0 F n t
1 1
S t = S t LW
5 1 5 2 2 1
0 F n t
1 1
S t = S t LW
4 1 4 2 2 1
0 F n t
1 1
S t = S t LW
3 1 3 2 2 1
0 F n t
1 1
S t = S t LW
2 1 2 2 2 1
0 F n t
1 1
S t = S t LW
1 10 1 T F 8 1 T F 5 1 T F
d t = S 10
- + S t --------------
t ---------------- 8
- + S t --------------
5
-
a t a t a t
4 1 T F 3 1 T F 2 1 T F
+ S 4
- + S t --------------
t -------------- 3
- + S t --------------
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 fol-
lows:
Q
F T
d
m l
---------------------------
m l
- = t a t d
LW d t=1
14-41
14 Dynamic Networks
Q
F T
d
m l
-------------------------
m l
- = t p t d
IW d t=1
Q
F
d
m
--------m- = t
b t=1
P14.3 Write out the RTRL equations for the network presented in Prob-
lem 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 accord-
u m
ing to the backpropagation order. The sensitivity matrices S t are com-
puted 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
a t 1 T 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
a t l T u m
-------------------------------------------T- = a t d S t
m l
vec LW d
e u
a t u m
----------------T- = S t
m
b
2 e 2 2
a t a t 2 2 2 2 a t 1
--------------
T T
- + S t LW 1 -----------------------
- = ---------------- T
-
x x x
3 e 3 2
a t a t 3 2 2 2 a t 1
--------------
T
- + S t LW 1 -----------------------
- = ----------------
T T
-
x x x
14-42
Solved Problems
4 e 4 4 3
a t a t 4 4 4 4 a t 1 4 3 a t 1
--------------
T
- + S t LW 1 -----------------------
- = ----------------
T T
- + LW 1 -----------------------
T
-
x x x x
2
4 2 2 2 a t 1
+S t LW 1 -----------------------
T
-
x
5
a t
--------------
x
T
e 5
a t
x
T
5 4 4 4 a t 1
- + S t LW 1 -----------------------
- = ----------------
x
T
4 3
4
a t 1
- + LW 1 -----------------------
x
T
-
3
14
2
5 2 2 2 a t 1
+S t LW 1 -----------------------
T
-
x
8 e 8 2
a t a t 8 2 2 2 a t 1
T T
- + S t LW 1 -----------------------
- = ----------------
-------------- T
-
x x x
10 e 10 8
a t a t 10 9 9 8 a t 1
----------------
T
- + S t LW 1 -----------------------
- = ------------------
T T
-
x x x
5 5
10 6 6 5 a t 6 5 a t 1
+S t LW - + LW 1 -----------------------
0 --------------
T T
-
x x
4 3 2
10 4 4 4 a t 1 4 3 a t 1 10 2 2 2 a t 1
+S t LW - + LW 1 -----------------------
1 -----------------------
T T
- +S t LW 1 -----------------------
T
-
x x x
After the above steps are iterated through all time points, we can compute
the gradient with
Q T T T
e 2 e 3 e 4
F F a t F a t F a t
-------T- =
x
--------------
2
a t
- --------------
x
T
- + --------------
3
a t
- --------------
x
T
- + --------------
4
a t
- --------------
x
T
-
t=1
e T 5 e T 8 e T 10
F a t F a t F a t
+ --------------
5
- --------------
T
- + --------------
8
- --------------
T
- + ----------------
10
- ----------------
T
-
a t x a t x a t x
P14.4 From the previous problem, show the detail of the calculations in-
volved in the explicit derivative term
e 2
a t 1 T 2 1
------------------------------------------T = p t S t
1 1
vec IW 0
14-43
14 Dynamic Networks
First, lets display the details of the individual vectors and matrices in this
expression:
1 1 1 1 1 1
1 1 iw 1 1 iw 1 2 iw 1 3
IW 0 =
1 1 1 1 1 1
iw 2 1 iw 2 2 iw 2 3
1 1 T
vec IW 0 = iw 1 1 iw 1 1 iw 1 1 iw 1 1 iw 1 1 iw 1 1
D 1 1 2 1 1 2 2 2 1 3 2 3
2 1 2 1
p1 e 2
s 1 1 s 1 2
1 2 1 a t
p t = p2 S t = -----------------T- = s 2 1 s 2 1
1 2 1 2 2
n t
p3 2 1 2 1
s 3 1 s 3 2
2 2 2 2 2 2
a 1 a 1 a 1 a 1 a 1 a 1
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
e 2
a t
2 2 2 2 2 2
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 2 2 2 2 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
a 1 1 B a 1 m B
AB =
a n 1 B a n m B
,
therefore
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
1 T 2 1
p t S 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 algo-
rithms 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 ).
1
D
R
S
1
Q
F T
d
1 1
---------------------------
1 1
- = t a t d ,
LW d t=1
1 2
The outer product calculation involves S operations, which must be
done for Q time steps and for D delays, so the BPTT gradient calculation is
1 2
O S DQ .
The complexity of the RTRL gradient is based generally on Eq. (14.34). For
this sample network, we can consider the equation for u = 2 :
D
2 e 2 1
a t a t 2 1 1 1 a t d
--------------
x
T
- + S t
- = ----------------
x
T LW d -----------------------
x
T
-
d=1
1 1
Inside the summation we have a matrix multiplication involving an S S
1 1 1
matrix times an S DS + 3 S + 1 matrix. This multiplication will be
1 4
O S D . It must be done for every d and every t, therefore the RTRL gra-
1 4 2
dient calculations are O S D Q . The multiplication by the sensitivity
matrix does not change the order of the complexity.
14-45
14 Dynamic Networks
Epilogue
Dynamic networks can be trained using the same optimization procedures
that we described in Chapter 12 for static multilayer networks. However,
the calculation of the gradient for dynamic networks is more complex than
for static networks. There are two basic approaches to the gradient calcu-
lation in dynamic networks. One approach, backpropagation through time
(BPTT), starts at the last time point, and works backward in time to com-
pute the gradient. The second approach, real-time recurrent learning
(RTRL), starts at the first time point, and then works forward through
time.
RTRL requires more calculations than BPTT for calculating the gradient,
but RTRL allows a convenient framework for on-line implementation. Also,
RTRL generally requires less storage than BPTT. For Jacobian calcula-
tions, RTRL is often more efficient than the BPTT algorithm.
Chapter 27 presents a real-world case study for using dynamic networks to
solve a prediction problem.
14-46
Further Reading
Further Reading
[DeHa07] O. De Jess and M. Hagan, Backpropagation Algorithms
for a Broad Class of Dynamic Networks, IEEE Transac-
tions on Neural Networks, vol. 18, no. 1, pp., 2007.
This paper presents a general development of BPTT and
RTRL algorithms for gradient and Jacobian calculations.
Experimental results are presented that compare the com-
putational complexities of the two algorithms for a variety
14
of network architectures.
[MaNe99] J.R. Magnus and H. Neudecker, Matrix Differential Calcu-
lus, John Wiley & Sons, Ltd., Chichester, 1999.
This textbook provides a very clear and complete descrip-
tion of matrix theory and matrix differential calculus.
[PhHa13] M. Phan and M. Hagan, Error Surface of Recurrent Net-
works, 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 er-
ror surfaces of recurrent networks. It also describes some
procedures that can be used to improve training of recur-
rent networks.
[Werb90] P. J. Werbos, Backpropagation through time: What it is
and how to do it, Proceedings of the IEEE, vol. 78, pp.
15501560, 1990.
The backpropagation through time algorithm is one of the
two principal approaches to computing the gradients in re-
current neural network. This paper describes the general
framework for backpropagation through time.
[WiZi89] R. J. Williams and D. Zipser, A learning algorithm for con-
tinually running fully recurrent neural networks, Neural
Computation, vol. 1, pp. 270280, 1989.
This paper introduced the real-time, recurrent learning al-
gorithm 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, im-
plementation.
14-47
14 Dynamic Networks
Exercises
E14.1 Put the network of Figure 14.1 into the schematic form, which we intro-
duced 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
E14.3 Consider the network in Figure P14.3, with D = 2 , S = 1 , R = 1 ,
1 1 1 1 1 1 1
IW = 1 , LW 1 = 0.5 , LW 2 = 0.2 , a 0 = 2 and
1 1 1 1 1
a 1 = 1 . If p 1 = 1 , p 2 = 2 and p 3 = 1 , find a 1 ,
1 1
a 2 and a 3 .
E14.4 Consider the network in Figure E14.1. Define the network architecture, by
f b U X
showing U , X , I m , DI m 1 , DL m l , L m , L m , E LW x , E LW u . Also, select a
simulation order and indicate the dimension of each weight matrix.
2
1 2 3 2 4
2
3 2 4 5 3
E14.5 Write out the RTRL equations for the network in Figure E14.2
1 1 2 3
1
2
3
2 2 2
E14.6 Write out the BPTT equations for the network in Figure E14.2.
14-48
Exercises
E14.7 Write out the equations of operation for the network in Figure E14.3. As-
sume 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 net-
work. 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 1 2
1
1
3
2 5
14-49
14 Dynamic Networks
1
i. 1 2
1
3
2 5
ii. 1 2
1
3
2 5
1 2 1 3
1
2
3
1 5 4
ii. Select a simulation order and write out the equations needed to de-
termine the network response.
u x
iii. Which S t will need to be calculated (i.e., for which u and which
x )?
3
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
3
E14.11 Repeat E14.10 for the following networks, except, in part iv., change a to
the indicated layer.
2
1 3 4
4
i. 3 2 5 ,a .
3
2 5
1
6 3
1
ii. 1 1 2 3 1 4 4
,a .
1
3 2 2 5 5
2
1 2 4
1
2
iii. 2 5 3 ,a .
3
14-51
14 Dynamic Networks
2
1 3 4
iv. 3 2 5 2
,a .
3
2 5
1
6 3
1 2 3 4 6
3 3 2 2 5 1
v. ,a .
1
2 5
2
6 3
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 implementa-
tion. Suppose that you are implementing the RTRL algorithm, and you up-
date 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 = ii. Implement the RTRL algorithm in MATLAB for the network in Fig-
4 ure 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 Fig-
ure 14.10, and use the network responses a t as the targets. Using
this data set, train the network using the steepest descent algo-
rithm, with a learning rate of = 0.1 . Set the initial weights to ze-
ro. 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 gradi-
ent 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
a t 1 T 3 2
-------------------------------------------T- = a t 1 S t
2 1
vec LW 1
If
1
a 1 = 1 and S 3 2 2 = 2 3 ,
1 4 5
e 3
e 3
a 2 a 1 2
Find -------------------------------------------T- and indicate ---------------------------------------
-.
2 1 2 1 T
vec LW 1 vec lw 1 2 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 l m l
m l l m
n t = LW d a t d + IW d p t d + b .
l L m d DL m l l I m d DI m l
f
If, instead of summing, the net input was computed as a product of the con-
tributions, how would the RTRL and BPTT algorithms change?
E14.16 As discussed in Exercise E14.15, the contribution to the net input from oth-
er layers is computed as product of a layer matrix with a layer output, as in
m l l
LW d a t d .
14-53
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 lay-
er output, as in
n i = iw a .
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 D 2
3
2 S
2
E14.18 Consider again the network of Figure 14.4. Let the input weight of the net-
work iw 1 1 = 1 . Assume that the initial network output is a 0 = 0 .
p t = 3 1 1 6 3 5 1 6 .
14-54
Objectives
15 Associative Learning
Objectives 15-1
Theory and Examples 15-2
Simple Associative Network 15-3
Unsupervised Hebb Rule 15-5
Hebb Rule with Decay 15-7
Simple Recognition Network 15-9
Instar Rule 15-11
Kohonen Rule 15-15
Simple Recall Network 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 tar-
get 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 asso-
ciations between patterns that occur together frequently. Once learned, as-
sociations 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 foun-
dation for powerful networks in Chapters 16, 18, 19.
15-1
15 Associative Learning
15-2
Simple Associative Network
w n a
p
b = -0.5
1
a = hardlim (wp + b)
1 stimulus 1 response
p = a = (15.2)
0 no stimulus 0 no response
15-3
15 Associative Learning
Sight of banana p0 w0 = 1
n a Banana?
Smell of banana p w = 0 b = -0.5
1
a = hardlim (w0p0 + w p + b)
Network 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
Banana? a value less than b to w . The following values satisfy these requirements:
0
w = 1, w = 0. (15.4)
15-4
Unsupervised Hebb Rule
0
a = hardlim p 0.5 . (15.5)
0
Thus, the network will only respond if a banana is sighted ( p = 1 ), wheth-
er 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.
w ij q = w ij q 1 + a i q p j q . (15.6)
(See also Eq. (7.5).) The learning rate dictates how many times a stimu-
lus 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 .
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
Local Learning 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 . (15.7)
p 1 p 2 p Q . (15.8)
15-5
15 Associative Learning
w q = w q 1 + a q p q . (15.11)
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 (15.14)
= hardlim 1 1 + 0 1 0.5 = 1 (banana) .
Because the smell stimulus and the response have occurred simultaneous-
ly, 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 re-
sponds anyway. It has made a useful association between the smell of a ba-
nana and its response.
15-6
Unsupervised Hebb Rule
0 0
a 3 = hardlim w p 3 + w 2 p 3 0.5 (15.16)
= hardlim 1 0 + 1 1 0.5 = 1 (banana)
w 3 = w 2 + a 3 p 3 = 1 + 1 1 = 2 (15.17)
From now on, the network is capable of responding to bananas that are de-
tected either by sight or smell. Even if both detection systems suffer inter-
mittent faults, the network will be correct most of the time.
To experiment with the unsupervised Hebb rule, use the Neural Network De-
sign Demonstration Unsupervised Hebb Rule (nnd13uh).
We have seen that the unsupervised Hebb rule can learn useful associa-
tions. 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 ar-
bitrarily 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 stim-
ulus.
W q = W q 1 + a q p T q W q 1
= 1 W q 1 + a q p T q , (15.18)
Decay Rate where , the decay rate, is a positive constant less than one. As approach-
es 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
The maximum weight value w ij is determined by . This value is found
by setting both a i and p j to a value of 1 for all q (to maximize learning) in
the scalar version of Eq. (15.18) and solving for the steady state weight (i.e.
when both new and old weights are equal).
15-7
15 Associative Learning
w ij = 1 w ij + a i p j
w ij = 1 w ij + (15.19)
w ij = ---
2 Lets examine the operation of the Hebb rule with decay on our previous ba-
+2
nana associator problem. We will use a decay rate of 0.1. The first itera-
tion, where only the smell stimulus is presented, is the same:
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. How-
ever, this time the weight increases by only 0.9, instead of 1.0.
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 1
w ij = --- = ------- = 10 (15.23)
0.1
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 De-
sign Demonstrations Hebb with Decay(nnd13hd) and Effect of Decay Rate
(nnd13edr).
15-8
Simple Recognition Network
30 10
20
6
w
4
10 Hebb Rule Hebb with Decay
0 0
0 10 20 30 0 10 20 30
q q
Figure 15.3 Response of the Hebb Rule, With and Without Decay
The Hebb rule with decay does solve the problem of large weights. Howev-
er, it does so at a price. The environment must be counted on to occasionally
present all stimuli that have associations. Without reinforcement, associa-
tions 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)
w ij q = 0.9 w ij q 1 . (15.25)
15-9
15 Associative Learning
p1 w1,1
w1,2 n a
p2
pR w1,R b
1
a = hardlim (Wp + b)
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 direc-
tion 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 Chap-
ters 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 pro-
duces 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 de-
cay only when the instar is active ( a 0 ). Weight values would still be lim-
ited, 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 (15.32)
Instar Rule 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 Associative Learning
iw q = iw q 1 + p q iw q 1
= 1 iw q 1 + p q . (15.34)
p(q)
w(q)
i
w(q - 1)
i
15-12
Instar Rule
2
The bias b is 2 , a value slightly more positive than p = 3 . (See Eq.
(15.29).)
Sight of orange p0 w0 = 3
w1,1 n a Orange?
Measured shape p1
Measured texture p2 b = -2
Measured weight p3 w1,3
1
a = hardlim (w0 p0 + W p + b)
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 1 = 0 p 1 = 1 p 2 = 1 p 2 = 1 (15.39)
1 1
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
1
(15.40)
a 1 = hardlim 3 0 + 0 0 0 1 2 = 0 (no response)
1
Since the neuron did not respond, its weights 1w are not altered by the in-
star rule.
1w 1 = 1w 0 + a 1 p 1 1w 0 (15.41)
0 1 0 0
= 0 + 0 1 0 = 0
0 1 0 0
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 (15.42)
1
= hardlim 3 1 + 0 0 0 1 2 = 1 (orange)
1
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 (15.43)
0 1 0 1
= 0 + 1 1 0 = 1
0 1 0 1
The network can now recognize the orange by its measurements. The neu-
ron 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
1
(15.44)
a 3 = hardlim 3 0 + 1 1 1 1 2 = 1 (orange)
1
1w 3 = 1w 2 + a 3 p 3 1w 2 (15.45)
15
1 1 1 1
= 1 + 1 1 1 = 1
1 1 1 1
Kohonen Rule
At this point it is appropriate to introduce another associative learning
Kohonen Rule rule, which is related to the instar rule. It is the Kohonen rule:
iw q = 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
a = satlins Wp . (15.47)
The symmetric saturating function satlins was chosen because this net-
work will be used to recall a vector containing values of -1 or 1.
Symmetric Saturating
Input Linear Layer
n1 a1
w1,1
w2,1 n2 a2
p
wS,1 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 :
(This assumes that the elements of a are less than or equal to 1 in mag-
nitude.)
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 net-
work 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 de-
cay 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, col-
umn 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)
Symmetric Saturating
Inputs Linear Layer
a1 Recalled shape
w1,10 = 1 n1
Measured shape p 0
1
Measured texture p20 w2,2
0
=1
Measured weight p30 =1 n2 a2 Recalled texture
w3,3
0
w1,1
a3 Recalled weight
n3
Identified Pineapple p
w3,1
15-17
15 Associative Learning
where
Fruit 0
1 0 0
W = 0 1 0 . (15.53)
0 0 1
Sight Measure
0
The networks two inputs provide it with measurements p taken on a fruit
Network (unconditioned stimulus), as well as a signal p indicating a pineapple has
been identified visually (conditioned stimulus).
Measurements? 0
shape 1 if a pineapple can be seen
p = texture p = (15.54)
0 otherwise
weight
w j q = w j q 1 + a q w j q 1 p q . (15.55)
1
pineapple
p = 1 . (15.56)
1
0 1
0 0
p 1 = 0 p 1 = 1 p 2 = 1 p 2 = 1 (15.57)
0 1
15-18
Outstar Rule
In the first iteration, the pineapple is seen, but the measurements are un-
available.
0 0
a 1 = satlins W p 1 + Wp 1 , (15.58)
0 0 0
a 1 = satlins 0 + 0 1 = 0 (no response) (15.59)
0 0 0
The network sees the pineapple but cannot output proper measurements,
because it has not learned them and the measurement system is not work-
ing. The weights remain unchanged after being updated.
15
0 0 0
0
w 1 1 = w 1 0 + a 1 w 1 0 p 1 = 0 + 0 0 1 = 0 (15.60)
0 0 0 0
In the second iteration the pineapple is seen, and the measurements are
taken properly.
1 0 1
a 2 = satlins 1 + 0 1 = 1 (measurements given) (15.61)
1 0 1
w 1 2 = w 1 1 + a 2 w 1 1 p 2
0 1 0
1
= 0 + 1 0 1 = 1 .
0 1 0 1
(15.62)
Since the sight of the pineapple and the measurements were both avail-
able, 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 Associative Learning
In iteration three, measurements are unavailable once again, but the out-
put is
0 1 1
a 3 = satlins 0 + 1 1 = 1 (measurements recalled) . (15.63)
0 1 1
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 differ-
ent 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 De-
sign 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 re-
sponse B.
Instar
Inputs Hard Limit Neuron
p1 w1,1
w1,2 n a
p2
pR w1,R b
1
a = hardlim (Wp + b)
a = hardlim 1w T p + b
Instar Rule
iw q = iw q 1 + a i q p q iw q 1
iw q = 1 w q 1 + p q if a i q = 1
15-21
15 Associative Learning
p(q)
iw(q)
iw(q - 1)
Kohonen Rule
iw q = iw q 1 + p q iw q 1 for i X q
Outstar
Symmetric Saturating
Input Linear Layer
n1 a1
w1,1
w2,1 n2 a2
p
wS,1 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 to-
gether 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 expres-
sion 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 2 max
w ij = 1 w ij +,
max
w ij = ---------------2- .
2
2+2
ans = We can use MATLAB to make a plot of this relationship. The plot will show
4 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 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).
20
15
Maximum weight
10
0
0
0.2 1
0.4 0.8
0.6 0.6
0.4
0.8 0.2
1 0
Learning Rate
Decay Rate
max
Figure P15.1 Maximum Weight w ij
P15.2 Retrain the orange recognition network on page 13-13 using the in-
star rule with a learning rate of 0.4. Use the same training se-
quence. 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 re-
T
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 = We will use MATLAB to make the calculations. These two lines of code set
4 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
W = W + 0.4*a*(p-W)
W =
0.4000 -0.4000 -0.4000
But the association is still not strong enough for a response in the third it-
eration.
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 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 measure-
ments 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 ex-
amples could only learn a single vector. Draw the diagram and de-
termine the parameters of a network capable of recognizing and
responding to the following two vectors:
5 5
p1 = 5 p2 = 5 .
5 5
15-26
Solved Problems
w1,1 n1 a1
p1
b1
p2
1
n2 a2
p3
w2,3
b2
1
a = hardlim (Wp + b)
T T
1w p1 5 5 5 .
W = = =
T T 5 5 5
2w p2
(Note that this is the same manner in which we determined the weight ma-
trix 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:
2 2 2
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)):
2
b1 = b2 = p1 = 75 .
2+2
ans = We can use MATLAB to test that the network does indeed respond to p 1 .
4
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
P15.4 A single instar is being used for pattern recognition. Its weights
and bias have the following values:
T
W = 1w = 1 1 1 b = 2 .
1w
Tp = 1w p cos b .
We can find the maximum angle between 1w and p that meets this condi-
tion by substituting for the norms and solving
3 3 cos 2
15-28
Solved Problems
2 2 2
p1 = p1 + p2 + p3 = 3,
T
1w 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 2 2 2 2
p1 + p2 + p3 = 3 p2 + p3 = 3 ,
p1 p2 p3 2 p2 + p3 = 2 ,
15
2 2 2 2
p 2 + p 3 = p 2 + p 3 + 2p 2 p 3 = 2 = 4 ,
3 + 2p 2 p 3 = 4 p 2 p 3 = 0.5 ,
2 2
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 rec-
ognized.
0
p = 1 + 0.5
1 0.5
15-29
15 Associative Learning
T
a = hardlim 1w p + b
0
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 0 1
p 1 = 0 p 1 = p 2 = 1 p 2 = .
1 1
p0 w0 = 3
w1,1 n a
p1
b = -2
p2 w1,2
1
a = hardlim (w0 p0 + W p + b)
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
0 1 0 0
15
Because the unconditioned stimulus appears on the second iteration, the
instar does respond.
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
0 1 0 0.5
0 0
a 3 = hardlim w p 3 + Wp 3 2
a 3 = hardlim 3 0 + 0.5 0.5 1 2 = 0
1
Since the neuron did not respond, its weights are not updated.
15-31
15 Associative Learning
1w 3 = 1w 2 + 0.5a 3 p 3 1w 2
= 0.5 + 0 1 0.5 = 0.5
0.5 1 0.5 0.5
0 0
a 4 = hardlim w p 4 + Wp 4 2
a 4 = hardlim 3 1 + 0.5 0.5 1 2 = 1
1
1w 4 = 1w 3 + 0.5a 4 p 4 1w 3
= 0.5 + 0.5 1 0.5 = 0.75
0.5 1 0.5 0.75
1w q = 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 vec-
tor 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 posi-
tion toward the input vector.
1w q = 0.5 1w q 1 + 0.5 p q
15-32
Solved Problems
p
1 w(4)
1 w(2)
1 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 chap-
ter 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 sta-
ble learning.
15-34
Further Reading
Further Reading
[Ande72] J. Anderson, A simple neural network generating an inter-
active memory, Mathematical Biosciences, vol. 14, pp.
197220, 1972.
Anderson has proposed a linear associator model for asso-
ciative memory. The model was trained, using a generali-
zation of the Hebb postulate, to learn an association
between input and output vectors. The physiological plau-
sibility 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 conse-
quences of psychological postulates, Proceedings of the Na-
15
tional Academy of Sciences, vol. 60, pp. 758765, 1968.
This article describes early mathematical models (nonlin-
ear differential equations) of associative learning. It syn-
thesizes psychological, mathematical and physiological
ideas.
[Gros82] S. Grossberg, Studies of Mind and Brain, Boston: D. Reidel
Publishing Co., 1982.
This book is a collection of Stephen Grossberg papers from
the period 1968 through 1980. It covers many of the funda-
mental concepts which are used in later Grossberg net-
works, such as the Adaptive Resonance Theory networks.
[Hebb49] D. O. Hebb, The Organization of Behavior, New York:
Wiley, 1949.
The main premise of this seminal book was that behavior
could be explained by the action of neurons. In it, Hebb pro-
posed one of the first learning laws, which postulated a
mechanism for learning at the cellular level.
[Koho72] T. Kohonen, Correlation matrix memories, IEEE Trans-
actions on Computers, vol. 21, pp. 353359, 1972.
Kohonen proposed a correlation matrix model for associa-
tive memory. The model was trained, using the outer prod-
uct rule (also known as the Hebb rule), to learn an
association between input and output vectors. The mathe-
matical structure of the network was emphasized. Ander-
son published a closely related paper at the same time
[Ande72], although the two researchers were working inde-
pendently.
15-35
15 Associative Learning
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.
p0 w0 = 1
n a
p w b = -0.8
1
a = hardlim (w0p0 + wp + b)
ii. Assume that w has an initial value of 1. How many consecutive pre-
sentations of the following training set are required before the neu-
ron will no longer be able to respond to the test set? Make a plot of
w versus iteration number.
0 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 dif-
ferently:
old
w ij = a i p j + w ij
15-37
15 Associative Learning
p0 w0 = 1
w1,1 n a
p1
w1,2 b = -0.5
p2
1
a = hardlim (w0p0 + Wp + b)
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 train-
ing, 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 0 2 = 1 p 2 = 1 .
p 1 = 0 p 1 =
1 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).
p0 w0 = 3
w1,1 n a
p1
b = -2
p2 w1,2
1
a = hardlim (w0 p0 + W p + b)
15-39
15 Associative Learning
1 1 1
p1 = 1
p2 = 1 p3 = 1
1 1 1
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
15-40
Exercises
p0
Floor Code 2x1
W0
2x2
a Floor?
2 2x1
p n
Retinal Scan W
3x1 2x1
2x3
3
1 b 2
2x1
a = hardlims (W0 p0 + W p + b)
Network
p 1 = 1 (1st floor) 1 (2nd floor)
0 0
p2 =
1 1
Floor?
p 3 = 1 (3rd floor) p 4 = 1 (4th floor)
0 0
1 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.
W = I , b = 0.5
0
0.5
The second input is always available. It consists of three elements that rep-
resent the three executives:
15-41
15 Associative Learning
1 0 0
p 1 = 0 (President) , p 2 = 1 (Vice-President) , p 3 = 0 (Chairman) .
0 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 = i. Use MATLAB to simulate the network for the following sequence of
4 events:
President pushes 4, Vice-President pushes 3,
Chairman pushes 1, Vice-President pushes 3,
Chairman pushes 2, President pushes 4.
In other words, train the network on the following sequence:
0 0 0 0 0 0
p = p 4 p = p 1 , p = p 3 p = p 2 , p = p 1 p = p 3 ,
0 0 0 0 0 0
p = p 3 p = p 2 , p = p 2 p = p 3 , p = p 4 p = p 1 .
15-42
Objectives
16 Competitive Networks
Objectives 16-1
Theory and Examples 16-2
Hamming Network 16-3
Layer 1 16-3
Layer 2 16-4
Competitive Layer 16-5
Competitive Learning 16-7
Problems with Competitive Layers 16-9
Competitive Layers in Biology 16-10
Self-Organizing Feature Maps 16-12
Improving Feature Maps 16-15
Learning Vector Quantization 16-16
LVQ Learning 16-18
Improving LVQ Networks (LVQ2) 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 tech-
nique for using a neural network for pattern recognition. It required that
the prototype patterns be known beforehand and incorporated into the net-
work 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 adaptive-
ly 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 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. Fi-
nally, 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.
p
Rx1
W1 n2(t + 1) a2(t + 1) a2(t)
n1 a1
SxR
Sx1 Sx1
W2 Sx1 Sx1 D Sx1
SxS
1 b1
Sx1
R S S
- Exp 1(W
a1 = purelin - 1 p + b 1) a2(0) = a1 a2(t + 1) = poslin (W2a2(t))
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 vec-
tors:
p 1 p 2 p Q . (16.1)
16-3
16 Competitive Networks
Then the weight matrix, W 1 , and the bias vector, b 1 , for Layer 1 will be:
1w
T p 1T
R
2w
T p 2T
W1 = = , b1 = R , (16.2)
Sw p QT
T
R
p 1T p + R
1 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 pro-
totype 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 de-
cide which prototype vector is closest to the input. Instead of the hardlim
transfer function, we will use a competitive layer to choose the closest pro-
totype.
Layer 2 is a competitive layer. The neurons in this layer are initialized with
the outputs of the feedforward layer, which indicate the correlation be-
tween the prototype patterns and the input vector. Then the neurons com-
pete 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 rep-
resents a category).
1
The first-layer output a is used to initialize the second layer.
2 1
a 0 = a (16.4)
16-4
Competitive Layer
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.
w ij = 1 if i = j
2 1
, where 0 ------------ (16.6)
otherwise S 1
Lateral Inhibition 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.
a i t + 1 = poslin a i t a j t
2 2 2
(16.7)
ji
Competitive Layer
Competition The second-layer neurons in the Hamming network are said to be in com-
petition because each neuron excites itself and inhibits all the other neu-
rons. 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 Competitive Networks
1 i = i
ai = , where n i n i i , and i i n i = n i (16.9)
0 i i
p n a
Rx1
W Sx1 C Sx1
SxR
R S
a = compet (Wp)
2
1w
T
1w
Tp L cos 1
2w 2w
Tp 2
= L cos 2 .
T
n = Wp = p = (16.10)
Sw Sw
T Tp 2
L cos S
a = compet Wp . (16.11)
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 net-
work, 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
(16.13)
= 1 iw q 1 + p q
and
iw q = iw q 1 i i (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)
i
w(q - 1)
i
16-7
16 Competitive Networks
T
1w
0.7071 w = 0.7071 w = 1.0000 , W =
1w = . (16.16)
T
2w
2 3
p1 p2 0.7071 0.7071 0.0000
2w 3w
T
p3 The data vectors are shown at left, with the weight vectors displayed as ar-
3w rows. Lets present the vector p 2 to the network:
p4
p6 0.7071 0.7071
1w
p5 0.1961
a = compet Wp 2 = compet 0.7071 0.7071 (16.17)
0.9806
1.0000 0.0000
0.5547 0
= compet 0.8321 = 1 .
0.1961 0
The second neurons weight vector was closest to p 2 , so it won the compe-
tition ( i = 2 ) and output a 1. We now apply the Kohonen learning rule to
the winning neuron with a learning rate of = 0.5.
16-8
Competitive Layer
p1 p2
2w
p3
1w
p4
3w
p6
p5
1w 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
3w
show which region each neuron will respond to. The competitive layer as-
signs 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).
1 Sometimes this trade-off between fast learning and stability can be used to
advantage. Initial training can be done with a large learning rate for fast
learning. Then the learning rate can be decreased as training progresses,
to achieve stable prototype vectors. Unfortunately, this technique will not
work if the network needs to continuously adapt to new arrangements of
input vectors.
A more serious stability problem occurs when clusters are close together.
In certain cases, a weight vector forming a prototype of one cluster may in-
16-9
16 Competitive Networks
vade the territory of another weight vector, and therefore upset the cur-
rent classification scheme.
The series of four diagrams in Figure 16.6 illustrate this problem. Two in-
put 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.
16-10
Competitive Layers in Biology
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 = . (16.19)
if i j
Eq. (16.20) assigns the same values as Eq. (16.19), but in terms of the dis-
tances d ij between neurons:
neuron j
1 if d ij = 0
-e -e -e -e -e w ij = . (16.20)
if d ij 0
-e -e -e -e -e
-e -e +1 -e -e
Either Eq. (16.19) or Eq. (16.20) will assign the weight values shown in the
-e -e -e -e -e diagram at left. Each neuron i is labeled with the value of the weight w ij ,
-e -e -e -e -e which comes from it to the neuron marked j .
On-center/off-surround The term on-center/off-surround is often used to describe such a connection
pattern between neurons. Each neuron reinforces itself (center), while in-
hibiting all other neurons (surround).
It turns out that this is a crude approximation of biological competitive lay-
ers. 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.
This transition is illustrated on the left side of Figure 16.7. This is a func-
tion that relates the distance between neurons to the weight connecting
them. Those neurons that are close provide excitatory (reinforcing) connec-
tions, and the magnitude of the excitation decreases as the distance in-
creases. Beyond a certain distance, the neurons begin to have inhibitory
connections, and the inhibition increases as the distance increases. Be-
Mexican-Hat Function cause 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 neuron j
- - - - -
+ - + + + -
dij - + + + -
- + + + -
-
- - - - -
Figure 16.7 On-Center/Off-Surround Layer in Biology
16-11
16 Competitive Networks
iw q = iw q 1 + p q iw q 1
i N i d , (16.21)
= 1 iw q 1 + p q
Neighborhood 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 presenta-
tions, neighboring neurons will have learned vectors similar to each other.
2 To demonstrate the concept of a neighborhood, consider the two diagrams
+2
shown in Figure 16.8. The left diagram illustrates a two-dimensional
neighborhood of radius d = 1 around neuron 13 . The right diagram shows
a neighborhood of radius d = 2 .
The definition of these neighborhoods would be
N 13 1 = 8 12 13 14 18 , (16.23)
N 13 2 = 3 7 8 9 11 12 13 14 15 17 18 19 23 . (16.24)
16-12
Self-Organizing Feature Maps
1 2 3 4 5 1 2 3 4 5
6 7 8 9 10 6 7 8 9 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)
1 2 3 4 5
6 7 8 9 10
p n a
3x1
W 25 x 1 C 25 x 1
11 12 13 14 15
25 x 3 16 17 18 19 20
21 22 23 24 25
3 25
1 a = compet (Wp)
0.8
0.6
Figure 16.9 Self-Organizing Feature Map
0.4
0.2 The diagram in the left margin shows the initial weight vectors for the fea-
0
ture map. Each three-element weight vector is represented by a dot on the
-0.2
sphere. (The weights are normalized, therefore they will fall on the surface
-0.4
of a sphere.) Dots of neighboring neurons are connected by lines so you can
-0.6
see how the physical topology of the network is arranged in the input space.
-0.8
-1
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
16-13
16 Competitive Networks
1
The diagram to the left shows a square region on the surface of the sphere.
0.8
We will randomly pick vectors in this region and present them to the fea-
0.6
ture map.
0.4
0.2
Each time a vector is presented, the neuron with the closest weight vector
0
will win the competition. The winning neuron and its neighbors move their
-0.2
-0.4
weight vectors closer to the input vector (and therefore to each other). For
-0.6
this example we are using a neighborhood with a radius of 1.
-0.8
-1
The weight vectors have two tendencies: first, they spread out over the in-
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
put 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 twen-
ty-five neurons spread out over the active input space and organize them-
selves to match its topology.
1 1 1 1
0 0 0 0
-1 -1 -1 -1
-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 0.2 0.4 0.6 0.8 1 -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 0.2 0.4 0.6 0.8 1
1 1 1 1
0 0 0 0
-1 -1 -1 -1
-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 0.2 0.4 0.6 0.8 1 -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 0.2 0.4 0.6 0.8 1
16-14
Self-Organizing Feature Maps
1 1 1 1
0 0 0 0
-1 -1 -1 -1
-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 0.2 0.4 0.6 0.8 1 -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 0.2 0.4 0.6 0.8 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
-0.2 -0.2
-0.4 -0.4
-0.6 -0.6
-0.8 -0.8
-1 -1
-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 0.2 0.4 0.6 0.8 1
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 di-
rectly 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 Demon-
strations 1-D Feature Maps (nnd14fm1) and 2-D Feature Maps (nnd14fm2).
W1 2
1
S xR a
2
S x1
p n1 a1 n2
Rx1
||dist||
S1x1 C 1
S x1
W 2
2
S x1
S2xS1
1 2
R S S
1 1
n i = ||iw -p|| a2 = W2a1
1 1
a = compet(n )
Figure 16.13 LVQ Network
16-16
Learning Vector Quantization
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 net-
works by calculating the distance directly. One advantage of calculating
the distance directly is that vectors need not be normalized. When the vec-
tors 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 1
n i = iw p , (16.25)
1
1w p
1
1
n = 2w p
16
1
w p
1
S
. (16.26)
The output of the first layer of the LVQ is
1 1
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.
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
Subclass winning neuron indicates a subclass, rather than a class. There may be sev-
eral 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 repre-
2
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
w ki = 1 subclass i is a part of class k (16.28)
The process of combining subclasses to form a class allows the LVQ net-
work 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 su-
pervision. 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 be-
longs. 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 ex-
press this as
0
12
1 .
p1 = 0 t1 = (16.29)
0
12 0
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
If hidden neuron i is to be assigned to class k, then set w ki = 1 . (16.30)
2 1
Once W is defined, it will never be altered. The hidden weights W are
trained with a variation of the Kohonen rule.
The LVQ learning rule proceeds as follows. At each iteration, an input vec-
tor p is presented to the network, and the distance from p to each proto-
type vector is computed. The hidden neurons compete, neuron i wins the
competition, and the i th element of a is set to 1. Next, a is multiplied
1 1
2 2
by W to get the final output a , which also has only one nonzero element,
k , indicating that p is being assigned to class k .
The Kohonen rule is used to improve the hidden layer of the LVQ network
in two ways. First, if p is classified correctly, then we move the weights
1
i
w of the winning hidden neuron toward p .
1 1 1 2
i
w q = i
w q 1 + p q iw q 1 , if a k = t k = 1 (16.31)
16-18
Learning Vector Quantization
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 .
1 1 1 2
i
w q = i
w 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 Lets take a look at an example of LVQ training. We would like to train an
+2
LVQ network to solve the following classification problem:
class 1: p 1 = 1 p 2 = 1 , class 2: p 3 = 1 p 4 = 1 , (16.33)
Class 1 1 1 1 1
p4 p2 as illustrated by the figure in the left margin. We begin by assigning target
vectors to each input:
16
1 t = 1 , p = 1 t = 1 ,
p1 = 1 2 2 (16.34)
p1 p3 1 0 1 0
Class 2
1 t = 0 , p = 1 t = 0 .
p3 = 3 4 4 (16.35)
1 1 1 1
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
W = 1 1 0 0 .
2
(16.36)
0 0 1 1
2
W connects hidden neurons 1 and 2 to output neuron 1. It connects hidden
neurons 3 and 4 to output neuron 2. Each class will be made up of two con-
vex regions.
1
The row vectors in W are initially set to random values. They can be seen
4w
1
1w
1
p4 p2 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
3w
1
class 2 are marked with solid circles. The values for these weights are
2w
1
16-19
16 Competitive Networks
1
1w p 3
1 1 2w p 3
1
a = compet n = compet (16.38)
3w p 3
1
1
4w p 3
T T
0.543 0.840 1 1
2.40
T T
0
0.969 0.249 1 1
= compet = 0
= compet 2.11
T T
0.997 0.094 1 1 1.09 1
2.03 0
0.456 0.954 T 1 1 T
The third hidden neuron has the closest weight vector to p 3 . In order to de-
1 2
termine which class this neuron belongs to, we multiply a by W .
0
a = W a = 1 1 0 0 0 = 0
2 2 1
(16.39)
0 0 1 1 1 1
0
1
This output indicates that p 3 is a member of class 2. This is correct, so 3w
is updated by moving it toward p 3 .
1 1 1
3w 1 = 3w 0 + p 3 3w 0 (16.40)
= 0.997 + 0.5 1 0.997 = 0.998
0.094 1 0.094 0.453
1
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
Learning Vector Quantization
The diagram on the right side of Figure 16.14 also indicates how the re-
gions 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.
1w
1
4w
1
4w
1
1w
1 p4 p2
p4 p2
2w
1
3w
1
p1 p3 p1 p3
2w 3w
1 1
16-21
16 Competitive Networks
Summary of Results
Competitive Layer
Input Competitive Layer
p n a
Rx1
W Sx1 C Sx1
SxR
R S
a = compet (Wp)
i
wq = i
wq 1 i i ,
p(q)
w(q)
i
w(q - 1)
i
16-22
Summary of Results
1 2 3 4 5
6 7 8 9 10
p n a
3x1
W 25 x 1 C 25 x 1
11 12 13 14 15
25 x 3 16 17 18 19 20
21 22 23 24 25
3 25
a = compet (Wp)
= 1 iw q 1 + p q
i N i d 16
N i d = j d ij d
LVQ Network
Inputs Competitive Layer Linear Layer
1
W 2
1
S xR a
2
S x1
p n
1
a1 n
2
Rx1
||dist||
S1x1 C 1
S x1
W 2
S2x1
S2xS1
R S1 S2
1 1
n i = ||iw -p|| a2 = W2a1
1 1
a = compet(n )
2
w ki = 1 subclass i is a part of class k
1 1 1 2
i
w q = i
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 n a
Rx1
W Sx1 C Sx1
SxR
R S
a = compet (Wp)
1w = 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:
T
1w 1 2 1 2
T
2w 1 2 1 2 .
W = =
3w
T
1 2 1 2
T 2 5 1 5
4w
We get Figure P16.3 by drawing these weight vectors with arrows and bi-
secting the circle between each adjacent weight vector to get the class re-
gions.
class 1 class 2
class 4
class 3
P16.2 Figure P16.4 shows three input vectors and three initial weight
vectors for a three-neuron competitive layer. Here are the values
of the input vectors:
p1 = 1 , p2 = 0 , p3 = 1 2 .
0 1 1 2
0 , w = 2 5 , w = 1 5 .
1w = 2 3
1 1 5 2 5
16-25
16 Competitive Networks
p1 , p2 , p3 , p1 , p2 , p3 .
p2
3w
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
0 1 0 0
1
a = compet Wp 1 = compet 2 5 1 5 = compet 0.894 = 1
0
1 5 2 5 0.447 0
= 2 5 + 0.5 1 2 5 = 0.947
new old old
2w = 2w + p 1 2w
p2
3w 0
p3 1 5 1 5 0.224
2w
p1
The diagram at left shows that the new 2w moved closer to p 1 .
We will now repeat this process for p 2 .
1w
16-26
Solved Problems
0 1 1 0
0
a = compet Wp 2 = compet 0.947 0.224 = compet 0.224 = 0
1
1 5 2 5 0.894 1
= 1 5 + 0.5 0 1 5 = 0.224
new old old
3w = 3w + p 2 3w
1
2 5 2 5 0.947
We now present p 3 .
0 1
1 2
a = compet Wp 3 = compet 0.947 0.224
1 2
0.224 0.947
0.707 0
= compet 0.512 = 0
0.512 1
= 0.224 + 0.5 1 2 0.224 = 0.2417
new old old
3w = 3w + p 2 3w
0.947 1 2 0.947 0.8272
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 .
2w 0.414 0.8103
p1
The final weights are also shown in the diagram at left.
Note that 2w has almost learned p 1 , and 3w is directly between p 2 and p 3 .
1w The other weight vector, 1w , was never updated. The first neuron, which
never won the competition, is a dead neuron.
16-27
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
2 w(0) w(0)
1
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 re-
sults are displayed in Figure P16.6.
p4
w(0)
2 w(0)
1
2w(4)
1 w(1)
w(3)
2
p3 p1
w(2)
1
p2
16-28
Solved Problems
p 1 , since = 0.5 . Next, p 2 is presented, and again neuron 1 wins the com-
petition and 1w is moved halfway to p 2 . During these first two iterations,
2w is not changed.
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 di-
mension.
p n a 4
3x1
W 9x1 C 9x1 5
9x3 6
7
3 9 8
a = compet(Wp)
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
7 4
0.4 1
0.2
0 8 5 2
-0.2
-0.4 9 6 3
-0.6
-0.8
-1
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
a = compet Wp
T
= compet 0.91 0.96 0.85 0.70 0.74 0.63 0.36 0.36 0.3
T
= 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
Figure P16.9 shows the feature map after the weights were updated.
1
0.8
0.6
7 4
0.4
1
0.2
0 8 5 2
-0.2
-0.4 9 6 3
-0.6
-0.8
-1
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
P16.5 Given the LVQ network shown in Figure P16.10 and the weight val-
ues shown below, draw the regions of the input space that make up
each class.
0 0
1 1 1 0 0 0 0
1 2
W = 1 1 , W = 0 1 0 0 0
1 1 0 0 1 1 1
1 1
16-31
16 Competitive Networks
W1 2
5x2 a
3x1
p n1 a1 n
2
2x1
-||dist||
5x1 C 5x1
W
2
3x1
3x5
2 5 3
1 1
n i = -||iw -p|| a2 = W2a1
1 1
a = compet(n )
16-32
Solved Problems
W1 2
9x2 a
3x1
p n1 a1 n2
2x1
-||dist||
9x1 C 9x1
W
2
3x1
3x9
2 9 3
1 1
n i = -||iw -p|| a2 = W2a1
1 1
a = compet(n )
16-33
16 Competitive Networks
1
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 proto-
type 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 1 0 0 0 1 1 1
Now each neuron in the first layer will respond to a different cluster.
2
Next we choose W so that each subclass is connected to the appropriate
class. To do this we use the following rule:
2
If subclass i is to be assigned to class k, then set w ki = 1 .
For example, the first subclass is the top-left cluster in the vector diagram.
The vectors in this cluster are white, so they belong in the first class. There-
2
fore we should set w 1 1 to one.
Once we have done this for all nine subclasses we end up with these values:
1 0 0 0 0 1 0 1 0
2
W = 0 1 0 0 1 0 1 0 0 .
0 0 1 1 0 0 0 0 1
We can test the network by presenting a vector to it. Here we calculate the
T
output of the first layer for p = 1 0 :
5 0
2 0
1 0
2 0
a = compet n = compet
1 1
1 = 0 .
0 1
5 0
2 0
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.
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 magni-
tude information, which may be important, is lost.
Another solution is to replace the inner product expression usual-
ly used to calculate net input,
a = compet Wp ,
n i = iw p and a = compet n ,
as is done with the LVQ network. This works and saves the magni-
tude 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
p1 = 1 , p2 = 0 , p3 = 0 .
1 1 0
1 0 0
p' 1 = 1 , p' 2 = 1 , p' 3 = 0
1 1 1
1 1 1 3
p'' 1 = 1 1 = 1 3
1 1 1 3
0 0 0
p'' 2 = 1 1 = 1 2
1 1 1 2
0 0 0
p'' 3 = 0 0 = 0
1 1 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 pro-
totype vectors that are learned by the network become representative of a
particular class of input vector. Thus the competitive networks learn to di-
vide 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 oper-
ation 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 re-
sult 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 super-
vised learning to recognize clusters. It uses a second layer to combine mul-
tiple 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 lat-
eral inhibition, on-center/off-surround networks and the biology that in-
spired 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 real-
world clustering problem.
16-37
16 Competitive Networks
Further Reading
[FrSk91] J. Freeman and D. Skapura, Neural Networks: Algorithms,
Applications, and Programming Techniques, Reading, MA:
Addison-Wesley, 1991.
This text contains code fragments for network algorithms,
making the details of the networks clear.
[Koho87] T. Kohonen, Self-Organization and Associative Memory,
2nd Ed., Berlin: Springer-Verlag, 1987.
Kohonen introduces the Kohonen rule and several net-
works that use it. It provides a complete analysis of linear
associative models and gives many extensions and exam-
ples.
[Hech90] R. Hecht-Nielsen, Neurocomputing, Reading, MA: Addi-
son-Wesley, 1990.
This book contains a section on the history and mathemat-
ics of competitive learning.
[RuMc86] D. Rumelhart, J. McClelland et al., Parallel Distributed
Processing, vol. 1, Cambridge, MA: MIT Press, 1986.
Both volumes of this set are classics in neural network lit-
erature. The first volume contains a chapter describing
competitive layers and how they learn to detect features.
16-38
Exercises
Exercises
E16.1 Suppose that the weight matrix for layer 2 of the Hamming network is giv-
en by
3 3
1 --- ---
4 4
2 3
W = --- 1 3
--- .
4 4
3 3
--- --- 1
4 4
3 1 1
= --- ------------ = --- .
4 S1 2
Give an example of an output from Layer 1 for which Layer 2 will fail to
operate correctly.
E16.2 Consider the input vectors and initial weights shown in Figure E16.1.
p4 p1
p2 p3
3w
2w
1w
p1 , p2 , p3 , p4 .
16-39
16 Competitive Networks
p1 = 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 pre-
sented 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 tech-
nique 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
0.9b i , if i i
old
new
bi = .
b old 0.2 , if i = i
i
16-40
Exercises
p a
2x1 W 3x1
n
3x2
3x1 C
1 b
3x1
2 3
a = compet (Wp + b)
p2
3w
p3
2w
p1
1w
p1 = 1 , p2 = 0 , p3 = 1 2
0 1 1 2
0 , w = 2 5 , w = 1 5 , b 0 = b 0 = b 0 = 0
1w = 2 3 1 2 3
1 1 5 2 5
16-41
16 Competitive Networks
E16.5 The net input expression for LVQ networks calculates the distance be-
tween the input and each weight vector directly, instead of using the inner
product. The result is that the LVQ network does not require normalized
input vectors. This technique can also be used to allow a competitive layer
to classify nonnormalized vectors. Such a network is shown in Figure
E16.4.
W
2x2
p n1 a1
2x1
-||dist||
2x1 C 2x1
2 2
1
n i = -||iw-p||
1 1
a = compet(n )
p1 = 1 , p2 = 1 , p3 = 2
1 2 2
p1 , p2 , p3 , p2 , p3 , p1 .
1w = 0 , 2w = 1 .
1 0
E16.6 Repeat E16.5 for the following inputs and initial weights. Show the move-
ments 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
W = 1 1 .
1 1
E16.8 Show that the modified competitive network of Figure E16.4, which com-
putes distance directly, will produce the same results as the standard com-
petitive network, which uses the inner product, when the input vectors are
normalized.
E16.9 We would like a classifier that divides the interval of the input space de-
fined below into five classes.
0 p1 1
2+2
ans = i. Use MATLAB to randomly generate 100 values in the interval
4 shown above with a uniform distribution.
ii. Square each number so that the distribution is no longer uniform.
iii. Write a MATLAB M-file to implement a competitive layer. Use the
M-file to train a five-neuron competitive layer on the squared values
16-43
16 Competitive Networks
E16.10 We would like a classifier that divides the square region defined below into
sixteen classes of roughly equal size.
0 p1 1 , 2 p2 3
2+2
ans = i. Use MATLAB to randomly generate 200 vectors in the region shown
4 above.
ii. Write a MATLAB M-file to implement a competitive layer with Ko-
honen learning. Calculate the net input by finding the distance be-
tween the input and weight vectors directly, as is done by the LVQ
network, so the vectors do not need to be normalized. Use the M-file
to train a competitive layer to classify the 200 vectors. Try different
learning rates and compare performance.
iii. Write a MATLAB M-file to implement a four-neuron by four-neuron
(two-dimensional) feature map. Use the feature map to classify the
same vectors. Use different learning rates and neighborhood sizes,
then compare performance.
E16.11 We want to train the following 1-D feature map (which uses distance in-
stead of inner product to compute the net input):
W 1
4x2
p n a 2
2x1
-||dist|| 4x1 C 4x1
3
2 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 it-
eration of the feature map learning rule. (You can do this graphical-
ly.) Use a neighborhood size of 1 and a learning rate of = 0.5 .
T
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.
W
4x2 a 1 2
4x1
p n
2x1
-||dist|| 4x1 C
3 4
2 4
ni = -||iw - p||
a = compet(n)
iii. Plot the weights after the first iteration, and show their topological
connections.
16-45
16 Competitive Networks
0 0
1 0 1 0 0 0 0
1 2
W = 1 0 , W = 0 1 1 0 0 .
0 1 0 0 0 1 1
0 1
i. How many classes does this LVQ network have? How many sub-
classes?
ii. Draw a diagram showing the first-layer weight vectors and the de-
cision 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 accord-
ing to the classes indicated:
1 1 1 1 1 1 1
class 1: 1 1 , class 2:
1 1 1 , class 3: 1 1 .
1 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 accord-
ing to the classes indicated:
1 p = 1
class 1: p 1 = 1 p 2 = 0 , class 2: p3 = 4
1 2 1 2
16-46
Exercises
iv. Initialize the first-layer weights of the network to all zeros and cal-
culate 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
W = 0 1 ,W = 1 1 0 ,
1 2
0 0 1
0 0
2 t = 1 , p = 2 t = 0 , p = 2 t = 1 ,
p1 = 1 2 2 3 3
2 0 0 1 2 0
2 t = 0
p4 = 4
0 1
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.
0 0 0 1 1 1 1 0 1 0 1 0 0 1
i. How many classes does this LVQ network have? How many sub-
classes?
ii. Draw a diagram showing the first-layer weight vectors and the de-
cision boundaries that separate the input space into subclasses.
iii. Label each subclass region to indicate which class it belongs to.
16-47
16 Competitive Networks
T
iv. Suppose that an input p = 1 0.5 from Class 1 is presented to the
network. Perform one iteration of the LVQ algorithm, with = 0.5 .
0 2 2 1 1 1 0 0 0 1 1 1
i. How many classes does this LVQ network have? How many sub-
classes?
ii. Draw a diagram showing the first-layer weight vectors and the de-
cision 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 in-
T T
put/target pair: p = 1 2 , t = 1 0 . Use learning rate
= 0.5 .
16-48
Objectives
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 applica-
tions as multilayer networks.
This chapter will follow the structure of Chapter 11. We will begin by dem-
onstrating, 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 deriva-
tives computed using a form of backpropagation. However, they can also be
trained using a two-stage process, in which the first layer weights are com-
puted 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 Radial Basis Networks
17-2
Radial Basis Network
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 trans-
fer (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 dif-
ferent 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
2
n
a = e , (17.2)
1.0
0.8
2
0.6 n
a = e
a
0.4
0.2
3 2 1 0 1 2 3
17-3
17 Radial Basis Networks
W1
S1xR
1 1 2
p a a
1
||dist|| 1 W2 2
R x1 S x1 S x1
n1 S2xS1
n2
.* S1x1 S2x1
1 b 1
1 b 2
1 1
S2
1
R S x1 S S2x1
1 1 1 2 2 1 2
a i = radbas(||iw -p||b i) 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 out-
put neuron, and with the following default parameters:
1 1 1 1
w 1 1 = 1 , w 2 1 = 1 , b 1 = 2 , b 2 = 2 ,
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 Fig-
2
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 pa-
rameters, 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
Radial Basis Network
2
a
1
2 1 0 1 2
2 2
1 1
b2 w 2 1
1 1
0 0
1 1
2 1 0 1 2 2 1 0 1 2
(a) (b)
2 2
2 2
w 1 1 b
1 1
0 0
1 1
2 1 0 1 2 2 1 0 1 2
(c) (d)
17-5
17 Radial Basis Networks
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
Center 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 loca-
tions 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 virtual-
ly 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 func-
tions 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 To illustrate the capabilities of the RBF network for pattern classification,
+2
consider again the classic exclusive-or (XOR) problem. The categories for
the XOR gate are
Category 1: p 2 = 1 p 3 = 1 , Category 2: p 1 = 1 p 4 = 1 .
1 1 1 1
17-6
Radial Basis Network
The problem is illustrated graphically in the figure to the left. Because the
two categories are not linearly separable, a single-layer network cannot
p2 p4 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
p1 p3 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 capabil-
ities 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
p2
= 1 1 .
1
W = (17.5)
T
p3 1 1
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 func-
tion 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:
2 2
n 1 2 2
a = e = e = 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
b = 1 .
1
(17.7)
1
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 Radial Basis Networks
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 2
W = 2 2 , b = 1 . (17.8)
For the network parameter values given in (17.5), (17.7) and (17.8), the net-
work 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.
0.5
2 0.5
a
1
1.5
2
3
2
3
1 2
0 1
1 0
p2 2 2
1
p1
3 3
17-8
Radial Basis Network
p2 0
3
3 2 1 0 1 2 3
p1
17-9
17 Radial Basis Networks
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 re-
sponse 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 func-
tions will be active.
There are advantages and disadvantages to each approach. The global ap-
proach tends to require fewer neurons in the hidden layer, since each neu-
ron 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, es-
pecially 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 ap-
pears 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 rep-
resentation in other regions. Local representations will not have this prob-
lem 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.
17-10
Training RBF Networks
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.
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
Curse of Dimensionality 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 in-
creases, 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 vari-
able. 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 ba-
sis 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
17
efficient approach is to use a method such as the Kohonen competitive lay-
er 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-11
17 Radial Basis Networks
1
1 S
b i = ---------- , (17.9)
d max
{p 1, t 1} { p 2, t 2} {p Q, tQ} , (17.10)
1 1 1
n i q = p q iw b i , (17.11)
1 1
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 1 1
a 1 t 1 a 2 t 2 a Q t Q . (17.13)
We want to select the weights and biases in this layer to minimize the sum
square error performance index over the training set:
Q
2 T
tq aq
2
Fx = tq aq (17.15)
q=1
Our derivation of the solution to this linear least squares problem will fol-
low 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 pa-
rameters we are adjusting, including the bias, into one vector:
17-12
Training RBF Networks
2
x = 1w . (17.16)
2
b
1
zq = aq . (17.17)
1
2 2 T 1 2
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 Q Q
F x = eq
2
= tq aq
2
= tq x
T 2
zq . (17.20) 17
q=1 q=1 q=1
T
1u
T
t1 z1 e1
T T
2u z2
t2 , U = ,e = e2 . (17.21)
t = =
tQ T
zQ
T eQ
Qu
e = t Ux , (17.22)
17-13
17 Radial Basis Networks
F x = t Ux t Ux + x i = t Ux t Ux + x x , (17.24)
T 2 T T
i=1
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:
T 1 T
F x = c + d x + --- x Ax . (17.26)
2
F x = c + d x + --- x Ax = d + Ax = 2U t + 2 U U + I x . (17.28)
T 1 T T T
2
17-14
Training RBF Networks
U U + I x = U t .
T T
(17.30)
Example
2 To illustrate the least squares algorithm, lets choose a network and apply
+2
it to a particular problem. We will use an RBF network with three neurons
in the first layer to approximate the following function
g p = 1 + sin --- p for 2 p 2 . (17.32)
4
To obtain our training set we will evaluate this function at six values of p :
2 0.5
1 1
W = 0 , b = 0.5 . (17.35)
2 0.5
The next step is to compute the output of the first layer, using the following
equations.
1 1 1
n i q = p q iw b i , (17.36)
1 1
a q = radbas n q . (17.37)
1
This produces the following a vectors
17-15
17 Radial Basis Networks
We can use Eq. (17.17) and Eq. (17.21) to create the U and t matrices
T
t = 0 0.19 0.69 1.3 1.8 2 . (17.40)
The next step is to solve for the weights and biases in the second layer us-
ing Eq. (17.30). We will begin with the regularization parameter set to zero.
1
x = U U + I U t
T T
1
2.07 1.76 0.42 2.71 1.01 1.03
(17.41)
= 1.76 3.09 1.76 4.05 4.05 = 0
0.42 1.76 2.07 2.71 4.41 1.03
2.71 4.05 2.71 6 6 1
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 (includ-
ing 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
Training RBF Networks
2.5
1.5
2
a 1
0.5
0.5
1.5
1 0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8 1
1
a 0.5
0
1 0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8 1
1.5
2 1
a
0.5
0.5
1
2 1.5 1 0.5 0 0.5 1 1.5 2
1
a 0.5
0
2 1.5 1 0.5 0 0.5 1 1.5 2
17-17
17 Radial Basis Networks
To experiment with the linear least squares fitting, use the MATLAB Neu-
ral Network Design Demonstration RBF Linear Least Squares (nnd17lls).
17-18
Training RBF Networks
t = Ux + e . (17.44)
We will use our standard notation for matrix rows and columns to individ-
ually identify both the rows and the columns of the matrix U:
T
1u
T
z1
T T
U = 2u = z2 =
u1 u2 un (17.45)
T
zQ
T
Qu
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).
Eq. (17.44) is in the form of a standard linear regression model. The matrix
Regression Matrix U is called the regression matrix, and the columns of U are called the re-
gressor 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 prob-
lem 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. Or-
thogonalizing the columns means that we can decompose U as follows:
U = MR , (17.46)
17-19
17 Radial Basis Networks
1 r 1 2 r 1 3 r 1 n
0 1 r 2 3 r 2 n
R = , (17.47)
0 0 0 r n 1 n
0 0 0 1
T
v 1 1 0 0 m1 m1 0 0
T 0 v 2 2 0 0
T
m2 m2 0
M M = V = = . (17.48)
0 0 v n n 0 0
T
mn mn
t = MRx + e = Mh + e , (17.49)
where
h = Rx . (17.50)
m1 = u1 , (17.53)
17-20
Training RBF Networks
k1
mk = uk ri k mi , (17.54)
i=1
where
T
mi uk
- , i = 1 k 1 .
r i k = -------------
T
(17.55)
mi mi
Therefore the total sum square value from Eq. (17.56) becomes
n
hi mi mi + e
T T T T T T 2 T T
t t = h M Mh + e e = h Vh + e e = 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 re-
maining sum squared value that is not explained by the regressors. There-
fore, regressor (basis function) i contributes
2 T
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 T
hi mi mi
-.
o i = -------------------
T
(17.61)
t t
17-21
17 Radial Basis Networks
Now lets put all these ideas together into an algorithm for selecting cen-
ters.
iT
i m1 t
-,
h 1 = --------------------- (17.63)
i T i
m1 m1
i 2 iT i
i h1 m1 m1
o 1 = -------------------------------------
T
. (17.64)
t t
We then select the basis function that creates the largest reduction in er-
ror:
i i
o 1 = o 1 1 = max o 1 , (17.65)
i
m 1 = m 1 1 = u i1 . (17.66)
k1
i i
mk = ui rj k mj , (17.68)
j=1
17-22
Training RBF Networks
iT
i mk t
-,
h k = --------------------- (17.69)
i T i
mk mk
i 2 iT i
i hk mk mk
ok = -------------------------------------
T
, (17.70)
t t
ik i
ok = ok = max o k , (17.71)
i
r j k = r j k , j = 1 k 1 .
k
(17.72)
i
mk = mk .
k
(17.73)
The iterations continue until some stopping criterion is met. One choice of
stopping criterion is
k
1 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 (ad-
justable 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 net-
works described in Chapter 16. Recall that the competitive layer of Ko-
honen (see Figure 16.2) and the Self Organizing Feature Map (see Figure
17-23
17 Radial Basis Networks
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 select-
ing biases for the first layer of the RBF network. If we take the input vec-
tors 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 clus-
tering of these vectors, using the Kohonen learning rule of Eq. (16.13), and
repeated here:
1 1 1
i
w q = i
w q 1 + p q iw q 1 , (17.78)
1
where p q is one of the input vectors in the training set, and iw q 1 is
the weight vector that was closest to p q . (We could also use other cluster-
ing algorithms, such as the Self Organizing Feature Map, or the k-means
clustering algorithm, which was suggested in [MoDa89].) As described in
Chapter 16, Eq. (17.78) is repeated until the weights have converged. The
resulting converged weights will represent cluster centers of the training
set input vectors. This will insure that we will have basis functions located
in areas where input vectors are most likely to occur.
In addition to selecting the first layer weights, the clustering process can
provide us with a method for determining the first layer biases. For each
neuron (basis function), locate the n c input vectors from the training set
that are closest to the corresponding weight vector (center). Then compute
the average distance between the center and its neighbors.
1
nc ---
1 1 2
2
dist i = ----- p j iw
i
(17.79)
nc
j=1
i 1 i
where p1 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
Training RBF Networks
1 1
b i = ------------------ . (17.80)
2dist i
Nonlinear Optimization
It is also possible to train RBF networks in the same manner as MLP net-
worksusing 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 net-
works 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 com-
puting 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):
1
S
2
pj w i j
1 1 1 1 1
n i = p iw b i = b i . (17.81)
j=1
17-25
17 Radial Basis Networks
If we take the derivative of this function with respect to the weights and
biases, we obtain
1 1 1
n i 1 12 1 b i w i j p j
1
- = b i --------------------------------------
---------- - 2 p j w i j 1 = -,
----------------------------
1
(17.82)
w i j p iw
1
S
1 2
pj wi j
j=1
1
n i 1
-------1- = p iw . (17.83)
b i
This produces the modified gradient equations (compare with Eq. (11.23)
and Eq. (11.24)) for Layer 1 of the RBF network
1 1
F 1 b i w i j p j
----------
1
- = s i -,
----------------------------
1
(17.84)
w i j p iw
F 1 1
-------1- = s i p iw . (17.85)
b i
17-26
Summary of Results
Summary of Results
W1
S1xR
1
p a1 a2
1
||dist|| W2
R x1 S1x1 S2x1
n1 S2xS1
n2
.* S1x1 S2x1
1 b
1
1 b
2
1 1
S2
1
R S x1 S S2x1
1 1 1 2 2 1 2
a i = radbas(||iw -p||b i) a = W a +b
T
1u
T
t1 z1 e1
T T
2u z2
t2 e2
t = ,U = = ,e =
tQ T
zQ eQ
T
Qu
T T
F x = t Ux t Ux + x x
U U + I x = U t
T T
17-27
17 Radial Basis Networks
iT
i m1 t
-,
h 1 = ---------------------
i T i
m1 m1
i 2 iT i
i h1 m1 m1
o 1 = -------------------------------------
T
.
t t
i 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
i mj uk
- , j = 1 k ,
r j k = -------------
T
mj mj
k1
i i
mk = ui r j k mj ,
j=1
iT
i mk t
hk -,
= ---------------------
i T i
mk mk
i 2 iT i
i hk mk mk
ok = -------------------------------------
T
,
t t
i i
o k = o k k = max o k ,
i
mk = mk k .
17-28
Summary of Results
Clustering
Training the weights
1 1 1
i
w q = i
w q 1 + p q iw q 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
----------
1
- = s i -,
----------------------------
1
w i j p iw
F 1 1
-------1- = s i p iw .
b i
17-29
17 Radial Basis Networks
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 val-
ues of p :
p = 1 0.5 0 0.5 1 .
t = 1 0 1 0 1 .
Perform one iteration of the OLS algorithm. Assume that the in-
puts in the training set are the potential centers and that the bias-
es are all equal to 1.
First, we compute the outputs of the first layer:
1 1 1
n i q = p q iw b i ,
1 1
a q = radbas n q ,
1.000 0.779 0.368 0.105 0.018
0.779 1.000 0.779 0.368 0.105
1
a = 0.368 0.779 1.000 0.779 0.368 .
0.105 0.368 0.779 1.000 0.779
0.018 0.105 0.368 0.779 1.000
We can use Eq. (17.17) and Eq. (17.21) to create the U and t matrices:
T
t = 1 0 1 0 1 .
17-30
Solved Problems
0.018 1.000
0.105 1.000
5 6
m1 = 0.368 , m 1 = 1.000 ,
0.779 1.000
1.000 1.000
iT
i m1 t
h1 -,
= ---------------------
i T i
m1 m1
1 2 3 4 5
h1 = 0.371 , h 1 = 0.045 , h 1 = 0.106 , h 1 = 0.045 , h 1 = 0.371 ,
6
h1 = 0.200 ,
i 2 iT i
i h1 m1 m1
o1 = -------------------------------------
T
,
t t
1 2 3 4 5
o1 = 0.0804 , o 1 = 0.0016 , o 1 = 0.0094 , o 1 = 0.0016 , o 1 = 0.0804 ,
6
o1 = 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 Radial Basis Networks
1
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
This will work for our problem, so we select the first layer bias vector to be
b = 1 .
1
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 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 inter-
2
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
3
0.5
2
2.5 a 0
p2 2
0.5
1.5
1.5
1 2
0
1 4
0.5 3
2
p1 3
1
2
p2
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4 0
p1
17-33
17 Radial Basis Networks
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 1 2 2
w 0 = 0 , b 0 = 1 , w 0 = 2 , b 0 = 1 .
p = 1 t = 1 .
1 1 1 2
n = p w b = 1 1 0 = 1
1 2
1 1 n 1
a = radbas n = e = e = 0.3679
2 2 1 2
n = w a + b = 2 0.3679 + 1 = 0.2642
2 2 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).
s = 2F (n ) t a = 2 1 e = 2 1 0.7358 = 1.4716
2 2 2
1 2
1 n
s = F (n ) W s = 2 n e
1 1 1 2 T 2 2 2 1
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 2 2 1 T
w 1 = w 0 s a = 2 1 1.4716 0.3679 = 1.4586 ,
1 b w p
1 1
1 0 1
= 0 1 2.1655 ---------------------------- = 2.1655 ,
1 1
w 1 = w 0 s -------------------------
pw
1 10
2 2 2
b 1 = b 0 s = 1 1 1.4716 = 2.4716 ,
1 1 1 1
b 1 = b 0 s p w = 1 1 2.1655 1 0 = 3.1655 .
17-34
Epilogue
Epilogue
The radial basis function network is an alternative to the multilayer per-
ceptron network for problems of function approximation and pattern recog-
nition. In this chapter we have demonstrated the operation of the RBF
network, and we have described several techniques for training the net-
work. 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
17 Radial Basis Networks
Further Reading
[Bish91] C. M. Bishop, Improving the generalization properties of
radial basis function neural networks, Neural Computa-
tion, Vol. 3, No. 4, pp. 579-588, 1991.
First published use of the expectation-maximization algo-
rithm for optimizing cluster centers for the radial basis net-
work.
[BrLo88] D.S. Broomhead and D. Lowe, Multivariable function in-
terpolation 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] S. Chen, C.F.N. Cowan, and P.M. Grant, Orthogonal least
squares learning algorithm for radial basis function net-
works, IEEE Transactions on Neural Networks, Vol.2,
No.2, pp.302-309, 1991.
The first description of the use of the subset selection tech-
nique for selecting centers for radial basis function net-
works.
[ChCo92] S. Chen, P. M. Grant, and C. F. N. Cowan, Orthogonal
least squares algorithm for training multioutput radial ba-
sis function networks, Proceedings of the Institute of Elec-
trical Engineers, Vol. 139, Pt. F, No. 6, pp. 378384, 1992.
This paper extends the orthogonal least squares algorithm
to the case of multiple outputs.
[ChCh96] S. Chen, E. S. Chng, and K. Alkadhimi, Regularised or-
thogonal 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 Genet-
ic Algorithm Optimization and Regularized Orthogonal
Least Squares Learning for Radial Basis Function Net-
works, 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
17-37
17 Radial Basis Networks
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.
E17.2 Choose the weights and biases for an RBF network with two neurons in the
hidden layer and one output neuron, so that the network response passes
through the points indicated by the blue circles in Figure E17.2.
Use the MATLAB Neural Network Design Demonstration RBF Network
Function (nnd17nf) to check your result.
1
2 1 0 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:
W = 1 , b = 0.5 .
1 1
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, as-
suming 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 = iii. Write a MATLAB M-file to check your answers to parts i. and ii.
4
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 net-
work 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 single-
layer perceptron. If we use a linear transfer function in each layer
of an RBF network, is that equivalent to a single-layer network? Ex-
plain.
2+2
ans = ii. Work out an example, equivalent to Figure 17.4, to demonstrate the
4 operation of the RBF network with linear transfer function in the
first layer. Use MATLAB to plot your figures. Do you think that
the RBF network will be a universal approximator, if the first layer
transfer function is linear? Explain your answer.
17-39
17 Radial Basis Networks
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 tar-
gets are given by
a = 2 1 0 , t = 0 1 2 .
1
1 2 1
i. Use linear least squares to find the second layer weights of the net-
work.
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 re-
duce 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? Ex-
plain.
a = 1 2 1 , t = 1 2 1 .
1
i.
2 1 1
a = 2 1 0 , t = 3 1 2 .
1
ii.
1 1 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 net-
work response as the input varies from -2 to 2.
17-40
Exercises
W1
2x1
p a1 a2
||dist|| W2
1x1 2x1 1x1
n1 1x2
n2
.* 2x1 1x1
1 b
1
1 2x1 2 1
1 1 1 2 2 1
a i = ||iw -p||b i a =Wa
E17.10 Write a MATLAB program to implement the linear least squares algo-
1
rithm for the 1 S 1 RBF network with first layer weights and biases
fixed. Train the network to approximate the function
g p = 1 + sin --- p for 2 p 2 .
8
2+2
ans = i. Select 10 training points at random from the interval 2 p 2 .
4
ii. Select four 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, assuming
that there is no regularization. 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.
iii. Double the bias from part ii and repeat.
iv. Decrease the bias by half from part ii, and repeat.
v. Compare the final sum squared errors for all cases and explain your
results.
E17.11 Use the function described in Exercise E17.10, and use an RBF network
with 10 neurons in the hidden layer.
i. Repeat Exercise E17.10 ii. with regularization parameter = 0.2 .
Describe the changes in the RBF network response.
2+2
ans = ii. Add uniform random noise in the range 0.1 0.1 to the training
4 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 Radial Basis Networks
E17.12 Write a MATLAB program to implement the orthogonal least squares al-
gorithm. Repeat Exercise E17.10 using the orthogonal least squares algo-
2+2
rithm. Use the 10 random training point inputs as the potential centers,
ans = and use Eq. (17.9) to set the bias. Use only the first four selected centers.
4 Compare your final sum squared errors with the result from E17.10 part ii.
g p = 1 + sin --- p for 2 p 2 .
8
2+2
ans = You should be able to use a slightly modified version of the program you
4 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 pa-
rameters. 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 ap-
proximate the following function:
t = sin 2p 1 cos 2p 2 .
2+2
ans = i. Use MATLAB to randomly generate 200 input vectors in the region
4 shown above.
ii. Write a MATLAB M-file to implement a four-neuron by four-neuron
(two-dimensional) feature map. Calculate the net input by finding
the distance between the input and weight vectors directly, as is
done by the LVQ network, so the vectors do not need to be normal-
ized. Use the feature map to cluster the input vectors.
iii. Use the trained feature map weight matrix from part ii as the
weight matrix of the first layer of an RBF network. Use Eq. (17.79)
to determine the average distance between each cluster and its cen-
ter, and then use Eq. (17.80) to set the bias for each neuron in the
first layer of the RBF network.
iv. For each of the 200 input vectors in part i, compute the target re-
sponse for the function above. Then use the resulting input/target
pairs to determine the second-layer weights and bias for the RBF
network.
v. Repeat parts ii to iv, using a two by two feature map. Compare your
results.
17-43
Objectives
18 Grossberg Network
Objectives 18-1
Theory and Examples 18-2
Biological Motivation: Vision 18-3
Illusions 18-4
Vision Normalization 18-8
Basic Nonlinear Model 18-9
Two-Layer Competitive Network 18-12
Layer 1 18-13
Layer 2 18-17
Choice of Transfer Function 18-20
Learning Law 18-22
Relation to Kohonen Law 18-24
Summary of Results 18-26
Solved Problems 18-30
Epilogue 18-42
Further Reading 18-43
Exercises 18-45
Objectives
This chapter is a continuation of our discussion of associative and compet-
itive 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 re-
current networks, and we will introduce concepts here that will be further
explored in Chapters 20 and 21. This Grossberg network is also the foun-
dation 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 Gross-
berg 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 de-
velop new understanding of brain function.
18-1
18 Grossberg Network
18-2
Biological Motivation: Vision
Bipolar Cell
Ganglion Cell
Amacrine
Cell Optic
Nerve
Cone
Light Lens
Rod
Horizontal
Cell
Retina
18-3
18 Grossberg Network
Horizontal Cells cells. Horizontal cells link the receptors and the bipolar cells, and amacrine
Amacrine Cells 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.
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 Fig-
ure 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 syn-
apses with lateral geniculate cells, and the axons of the lateral geniculate
Visual Cortex 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.
Lateral
Primary Geniculate
Visual Nucleus
Cortex
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
Biological Motivation: Vision
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 Stabilized
Spot Images Fade
Retina
18-6
Biological Motivation: Vision
the lower figure we see the completed edge, after the emergent segmenta-
tion and featural filling-in.
Before Processing
After Processing
18-7
18 Grossberg Network
Vision Normalization
In addition to emergent segmentation and featural filling-in, there are two
other phenomena that give us an indication of what operations are being
Brightness Constancy performed in the early vision system: brightness constancy and brightness
Brightness Contrast contrast. The brightness constancy effect is evidenced by the test illustrat-
ed in Figure 18.8. In this test a subject is shown a small grey disk inside a
darker grey annulus, which is illuminated by white light of a certain inten-
sity. The subject is asked to indicate the brightness of the central disk by
looking at a series of grey disks, separately illuminated, and selecting the
disk with the same brightness. Next, the brightness of the light illuminat-
ing the grey disk and dark annulus is increased, and the subject is again
asked to select the disk with the same brightness. This process is repeated
for several different levels of illumination. It turns out that in each case the
subject will choose the same disk as matching the original central disk.
Even though the total light entering the subjects eye is 10 to 100 times
brighter, it is only the relative brightness that registers.
Variable Separate
Illumination Constant Illumination
18-8
Basic Nonlinear Model
dn(t)
------------ = n(t) + p(t) , (18.1)
dt
Leaky Integrator
.
+ n n
p 1/
-
dn/dt = - n + p
t 1 t t
n(t) = e n(0) + --- e p() d . (18.2)
0
18-9
18 Grossberg Network
0.75
n 0.5
0.25
0
0 1 2 3 4 5
dn(t) + + - -
------------ = n(t) + b n(t) p n(t) + b p , (18.4)
dt
+
Excitatory where p is a nonnegative value representing the excitatory input to the
-
network (the input that causes the response to increase), and p is a non-
Inhibitory negative value representing the inhibitory input (the input that causes the
+ -
response to decrease). The biases b and b are nonnegative constants that
determine the upper and lower limits on the neuron response, as we will
explain next.
18-10
Basic Nonlinear Model
b+ +
p+
-
.
+ + n n
1/
- -
+
p-
+
b-
18-11
18 Grossberg Network
1 1
0.75 + 0.75 +
p = 1 p = 5
nt 0.5 0.5
0.25 0.25
0 0
0 1 2 3 4 5 0 1 2 3 4 5
t t
18-12
Two-Layer Competitive Network
Layer 1 Layer 2
(Retina) (Visual Cortex)
Input
STM
LTM
(Adaptive Weights)
Normalization Contrast
Enhancement
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 Ko-
honen 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 .
p + + n1 n1 a1
1/
S1 x 1
- -
+
-W1
S1 S1
S1 x S1
+
-b1
18-13
18 Grossberg Network
1 0 0
0
W = 0 1
+ 1
. (18.6)
0 0 1
Therefore the excitatory input to neuron i is the ith element of the input
vector.
- 1
The inhibitory input to Layer 1 is W p , where
0 1 1
1
W = 1 0
- 1
. (18.7)
1 1 0
Thus the inhibitory input to neuron i is the sum of all elements of the input
vector, except the ith element.
+ 1 - 1
The connection pattern defined by the matrices W and W is called an
On-Center/Off-Surround on-center/off-surround pattern. This is because the excitatory input for
neuron i (which turns the neuron on) comes from the element of the input
vector centered at the same location (element i ), while the inhibitory input
(which turns the neuron off) comes from surrounding locations. This type
of connection pattern produces a normalization of the input pattern, as we
will show in the following discussion.
- 1
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 + 1 1
bi = 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
Two-Layer Competitive Network
1
dn i (t)
- = n i (t) + b n i (t) p i n i (t) p j .
1 + 1 1 1
------------- (18.9)
dt
ji
1
In the steady state ( dn i (t) dt = 0 ) we have
0 = n i + b n i p i n i p j .
1 + 1 1 1
(18.10)
ji
1
If we solve for the steady state neuron output n i we find
+ 1
1 b pi
n i = ----------------------
1 . (18.11)
S
1+ pj
j=1
Note that Layer 1 of the Grossberg network explains the brightness con-
stancy 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 Grossberg Network
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 rel-
ative 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 1
1
1 n2
0.75
n2 0.75
0.5
p1 = 2 0.5 p 2 = 10
8 40
1 1
0.25 n1 0.25 n1
0 0
0 0.05 0.1 0.15 0.2 0 0.05 0.1 0.15 0.2
t t
18-16
Two-Layer Competitive Network
Layer 2
Layer 2 of the Grossberg network, which is a layer of continuous-time in-
stars, performs several functions. First, like Layer 1, it normalizes total ac-
tivity 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
Short-Term Memory 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 Lay-
er 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 enhance-
ment of the pattern. We will demonstrate these properties in the following
discussion.
Layer 2
+ + On-Center
W2 +W2
+b2
S2 x S1 + S2 x S2
-
.
a1 + + n2 n2 a2
1/ f2
S1 - -
+
S2
+
-b2
-W2
Off-Surround
S2 x S2
18-17
18 Grossberg Network
+ 2 2 2 2 1
This is a shunting model with excitatory input W f (n (t)) + W a ,
+ 2 + 1 2
where W = W provides on-center feedback connections, and W con-
sists of adaptive weights, analogous to the weights in the Kohonen net-
2
work. The rows of W , after training, will represent the prototype patterns.
- 2 2 2
The inhibitory input to the shunting model is W f (n (t)) , where
- 2 - 1
W = W provides off-surround feedback connections.
2 To illustrate the performance of Layer 2, consider a two-neuron layer with
+2
2 T
w
= 0.1 , b = 1 , b = 0 , W = 1 = 0.9 0.45 ,
+ 2 - 2 2
(18.18)
1 0 2 T 0.45 0.9
2w
and
2
2 10 n
f (n) = ------------------2- . (18.19)
1 + n
2
dn 2(t) 2 2 2 2 2 T 1
0.1 -------------
- = n 2(t) + 1 n 2(t) f (n 2(t)) + 2w a (18.21)
dt
2 2 2
n 2(t)f (n 1(t)) .
Note the relationship between these equations and the Hamming and Ko-
honen 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
Contrast Enhance competition between the neurons, which tends to contrast enhance the out-
put 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 out-
puts to zero. The exception is the one with the largest input. In the Gross-
berg network, the competition maintains large values and attenuates small
values, but does not necessarily drive all small values to zero. The amount
18-18
Two-Layer Competitive Network
2
of contrast enhancement is determined by the transfer function f , as we
will see in the next section.
Figure 18.17 illustrates the response of Layer 2 when the input vector
1 T
a = 0.2 0.8 (the steady state result obtained from our Layer 1 example)
is applied for 0.25 seconds and then removed.
2 T 1
2w a 2
n 2(t)
0.75
2 T 1
1w a
0.5
0.25 2
n 1(t)
0
0 0.1 0.2 0.3 0.4 0.5
t
2 T 1
1w a = 0.9 0.45 0.2 = 0.54 , (18.22)
0.8
2 T 1
2w a = 0.45 0.9 0.2 = 0.81 . (18.23)
0.8
Therefore the second neuron has 1.5 times as much input as the first neu-
ron. 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 pat-
tern. 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 Grossberg Network
Active
Active
Inactive
18-20
Two-Layer Competitive Network
Stored Pattern
f 2(n) n2() Comments
Linear
Perfect storage
of any pattern,
but amplifies
noise.
Slower than
Linear Amplifies noise,
reduces contrast.
Faster than
Winner-take-all,
Linear
suppresses noise,
quantizes total
activity.
Sigmoid Supresses
noise, contrast
enhances, not
quantized.
2
Figure 18.19 Effect of Transfer Function f (n) (after [Gross82])
18-21
18 Grossberg Network
To experiment with Layer 2 of the Grossberg network, use the Neural Net-
work Design Demonstration Grossberg Layer 2 (nnd15gl2).
Learning Law
The third component of the Grossberg network is the learning law for the
2
Long-Term Memory 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 sub-
section we will look more closely at the relationship between the Grossberg
network and the Kohonen network.
2
One learning law for W is given by
2
dw i j(t) 2 2 1
----------------- = w i j(t) + n i (t)n j (t) . (18.24)
dt
The first term in the bracket on the right-hand side of Eq. (18.24) is a pas-
sive 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 for-
2
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) , (18.25)
dt
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 sub-
section we will demonstrate the equivalence of Eq. (18.25) and Eq. (15.32).
18-22
Two-Layer Competitive Network
where the learning rate coefficient has been set to 1 . To simplify our ex-
ample, 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 effec-
tively constant over the 0.2 seconds. The Layer 1 and Layer 2 outputs for
the two different input patterns will be
for pattern 1: n =
1 0.9 , n 2 = 1 , (18.31)
0.45 0
18-23
18 Grossberg Network
2
0.75
w 1 1(t) 2
w 2 2(t)
2
0.5
w 1 2(t)
0.25 2
w 2 1(t)
0
0 0.5 1 1.5 2 2.5 3
(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
2 2 2 2 1
iw (t + t) = 1 t n i (t) iw (t) + t n i (t) n (t) . (18.36)
18-24
Relation to Kohonen Law
a nonzero output; call it neuron i . Then only row i of the weight matrix
will be updated:
2 2 1
i
w (t + t) = 1 ' iw (t) + ' n (t) , (18.37)
2
where ' = t n i(t) .
This is almost identical to the Kohonen rule for the competitive network
that we introduced in Chapter 14 in Eq. (16.13). The weight vector for the
1
winning neuron (with nonzero output) will be moved toward n , which is a
normalized version of the current input pattern.
There are three major differences between the Grossberg network that we
have presented in this chapter and the basic Kohonen competitive network.
First, the Grossberg network is a continuous-time network (satisfies a set
of nonlinear differential equations). Second, Layer 1 of the Grossberg net-
work automatically normalizes the input vectors. Third, Layer 2 of the
Grossberg network can perform a soft competition, rather than the win-
ner-take-all competition of the Kohonen network. This soft competition al-
lows more than one neuron in Layer 2 to learn. This causes the Grossberg
network to operate as a feature map.
18-25
18 Grossberg Network
Summary of Results
Leaky Integrator
.
+ n n
p 1/
-
dn/dt = - n + p
Shunting Model
dn(t) + + - -
------------ = n(t) + b n(t) p n(t) + b p
dt
b+ +
p+
- b+
.
+ + n n
1/
- - 0 n(t)
+ -b-
p-
+
b-
18-26
Summary of Results
STM
LTM
(Adaptive Weights)
Normalization Contrast
Enhancement
Layer 1
Input Layer 1
+b1
+
+W1
-
S1 x S1 .
p + + n1 n1 a1
1/
S1 x 1
- -
+
S1
-W1
+
S1 18
S1 x S1
-b1
1
dn (t) 1 + 1 1 + 1 1 - 1 - 1
-------------- = n (t) + b n (t) W p n (t) + b W p
dt
1 0 0 0 1 1
0 1
W = 0 1 W = 1 0
+ 1 - 1
0 0 1 1 1 0
On-Center Off-Surround
18-27
18 Grossberg Network
Layer 2
Layer 2
+ + On-Center
W2 +W2
+b2
S2 x S1 + S2 x S2
-
.
a1 + + n2 n2 a2
1/ f2
S1 - -
+
S2
+
-b2
-W2
Off-Surround
S2 x S2
18-28
Summary of Results
Slower than
Linear
Amplifies noise,
reduces contrast.
Faster than
Winner-take-all,
Linear
suppresses noise,
quantizes total
activity.
Sigmoid Supresses
noise, contrast
enhances, not
quantized.
Learning Law
2
d iw (t) 2 2 1
--------------------- = n i (t) iw (t) + n (t)
dt 18
(Continuous-Time Instar Learning)
18-29
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 in-
put p = 1 .
Leaky Integrator
.
+ n n
p 1/
-
dn/dt = - n + p
dn(t)
------------ = n(t) + p(t) .
dt
t 1 t t
n(t) = e n(0) + --- e p(t ) d .
0
t 1 t t
n(t) = e n(0) + --- e d .
0
This response begins at n(0) , and then grows exponentially (or decays ex-
ponentially, 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
1
= 0.125
0.75
0.5
= 1
0.25
0
0 0.5 1 1.5 2
t
n(t + t) n(t)
----------------------------------- = n(t) + p(t)
t
or
18-31
18 Grossberg Network
0.75
0.5
0.25
0
0 0.25 0.5 0.75 1
18-32
Solved Problems
p(0.1) + + p( k 1 0.1) .
k1 k2
n k0.1 = 0.1 0.9 p(0) + 0.9
P18.3 Find the response of the shunting network shown in Figure P18.4
+ - + -
for = 1 , b = 1 , b = 1 , p = 0 , p = 10 and n(0) = 0.5 .
b+ +
p+
-
.
+ + n n
1/
- -
+
p-
+
b-
dn(t) + + - -
------------ = n(t) + b n(t) p n(t) + b p .
dt
dn(t)
------------ = n(t) n(t) + 1 10 = 11n(t) 10 .
dt
18-33
18 Grossberg Network
or
0.5 + ------ 1 e .
11t 10 11t
n(t) = e
11
0.5
-0.5
-1
0 0.25 0.5 0.75 1
0.5 + --------- 1 e
101t 100 101t
n(t) = e .
101
101t 11t
Since e decays more rapidly than e , the response will be faster.
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. Dem-
onstrate the effect of c on the response.
18-34
Solved Problems
1
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
1 + 3c t 1 t 1 + 3c t
+ e
1
n 1(t) = e n 1(0) c d ,
0
1 + 3c t 1 t 1 + 3c t
+ e
1
n 2(t) = e n 2( 0) 2c d .
0
n 1(t) = --------------- 1 e
1 c 1 + 3c t
,
1 + 3c
n 2(t) = --------------- 1 e
1 2c 1 + 3c t
.
1 + 3c
Note that the outputs of Layer 1 retain the same relative intensities as the
inputs; the output of neuron 2 is always twice the output of neuron 1. This
behavior is consistent with Eq. (18.13). In addition, the total output inten-
1 1 + 1
sity ( n 1(t) + n 2(t) ) is never larger than b = 1 , as predicted in Eq. (18.14).
As c is increased, it has two effects on the response. First, the steady state
values increase slightly. Second, the response becomes faster, since
1 + 3c t
e decays more rapidly as c increases.
P18.5 Consider Layer 2 of the Grossberg network. Assume that the input
to Layer 2 is applied for some length of time and then removed (set
to zero).
i. Find a differential equation that describes the variation in
the total output of Layer 2,
2
S
nk (t) ,
2 2
N (t) =
k=1
18-35
18 Grossberg Network
2 S2
dn i (t) 2
-------------- = n i (t) + b f (n i (t)) n i (t) f (n k (t)) .
2 + 2 2 2 2 2
dt k = 1
f (n k(t)) ,
2 2 2
F (t) =
k=1
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
2 2
d 2 d n i (t) 1 d 2 n i (t) d 2
n (t) = - n (t) ------------------
------------ = ----------- - N (t) .
dt i d t N 2(t) 2 dt i
N (t) N (t) d t
2 2
d 2 1 2 2 + 2 2 2
n i (t) = -----------
2
- 1 + F (t) n i (t) + b f (n i (t))
dt N (t)
2
n i (t) 2 2 + 2 2
- 1 + F (t) N (t) + b F (t) .
-----------
2
N (t)
2
d 2 1 + 2 2 2 n i (t) + 2 2
n i (t) = -----------
2
- b f (n i (t)) -----------
2
- b F (t) ,
dt N (t) N (t)
or
+ 2 2 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 brack-
ets:
2 2
f (n i (t)) n i (t)
------------------
2
2
1
- = -----------------------
-----------
2 2 2
2 2 2 2 2
- f (n i (t))N (t) n i (t)F (t)
18
F (t) N (t) F (t)N (t)
2 2
S S
1
- g (n i (t))n i (t) n k (t) n i (t) g (n k (t))n k (t)
2 2 2 2 2 2 2 2
= -----------------------
2 2
F (t)N (t)
k=1 k=1
2
2 S
n i (t)
nk(t) g (ni (t)) g (n k(t))
2 2 2 2 2
= -----------------------
2 2
- ,
F (t)N (t) k=1
where
2 2
2 2 f (n i (t))
g (n i (t)) = ------------------
2
.
n i (t)
18-37
18 Grossberg Network
2
S
d 2 + 2 2 2
n k(t) g (ni (t)) g (n k(t))
2 2 2 2
n i (t) = b n i (t) .
dt
k=1
This form of the differential equation describing the evolution of the rela-
tive 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 net-
work is linear.
i. Show that the relative outputs of Layer 2 will not change af-
ter 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
2
S
d 2 + 2 2 2
n k(t) g (ni (t)) g (n k(t))
2 2 2 2
n i (t) = b n i (t) .
dt
k=1
2
If the transfer function for Layer 2, f (n) , is linear, then
2
f ( n) = c n .
Therefore
2
2 f ( n) cn
g (n) = ----------- = ------- = c .
n n
18-38
Solved Problems
2
If f (n) is linear, then
2 2 2
S S S
We want to know the conditions under which the total output will converge
to each of these possible solutions. Consider two cases:
+ 2
1. 1 b c
For this case, the derivative of the total output,
dN (t)
2
+ 2 2 2
--------------- = 1 b c + c N (t) N (t) ,
dt
18
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
t
+ 2
2. 1 b c
2 + 2
(a) If N (0) b c 1 c , then the derivative of the total output will
2 + 2
be negative until N (t) = b c 1 c , when the derivative will be
zero. Therefore,
+ 2
2 b c 1
lim N (t) = ------------------------ .
t c
18-39
18 Grossberg Network
2 + 2
(b) If N (0) b c 1 c , then the derivative of the total output will
2 + 2
be positive until N (t) = b c 1 c , when the derivative will be ze-
ro. Therefore,
+ 2
2 b c 1
lim N (t) = ------------------------ .
t c
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 out-
put will converge to
+ 2
2 b c 1 1.5 1
lim N (t) = ------------------------ = --------------------- = 0.5 .
t c 1
In Figure P18.6 we can see the response of Layer 2 for two different sets of
initial conditions:
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
2
N (t)
0.5
2
n 1(t)
2
n 2(t)
0
0 5 10
2
Figure P18.6 Response of Layer 2 for Linear f (n)
P18.7 Show that the continuous-time Hebb rule with decay, given by Eq.
(18.24), is equivalent to the discrete-time version given by Eq.
(15.18).
The continuous-time Hebb rule with decay is
2
dw i j(t) 2 2 1
----------------- = w i j(t) + n i (t)n j (t) .
dt
2 2 2 1 T
W (t + t) = 1 t W (t) + t n (t) n (t) .
18-41
18 Grossberg Network
Epilogue
The Grossberg network presented in this chapter was inspired by the visu-
al system of higher vertebrates. To motivate the network, we presented a
brief description of the primary visual pathway. We also discussed some vi-
sual illusions, which help us to understand the mechanisms underlying the
visual system.
The Grossberg network is a two-layer, continuous-time competitive net-
work, which is very similar in structure and operation to the Kohonen com-
petitive network presented in Chapter 14. The first layer of the Grossberg
network normalizes the input pattern. It demonstrates how the visual sys-
tem can use on-center/off-surround connection patterns and a shunting
model to implement an automatic gain control, which normalizes total ac-
tivity.
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 pat-
tern 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 winner-
take-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 extensive-
ly 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 net-
work 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 discus-
sion of this problem.
18-42
Further Reading
Further Reading
[GrMi89] S. Grossberg, E. Mingolla and D. Todorovic, A neural net-
work architecture for preattentive vision, IEEE Transac-
tions 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 con-
sists of two main subsystems: a boundary contour system
and a feature contour system.
[Gros76] S. Grossberg, Adaptive pattern classification and univer-
sal recoding: I. Parallel development and coding of neural
feature detectors, Biological Cybernetics, vol. 23, pp. 121
134, 1976.
Grossberg describes a continuous-time competitive net-
work, inspired by the developmental physiology of the visu-
al cortex. The structure of this network forms the
foundation for other important networks.
[Gros82] S. Grossberg, Studies of Mind and Brain, Boston: D. Reidel
Publishing Co., 1982.
This book is a collection of Stephen Grossberg papers from
the period 1968 through 1980. It covers many of the funda-
mental concepts that are used in later Grossberg networks,
such as the adaptive resonance theory networks.
[Hube88] D.H. Hubel, Eye, Brain, and Vision, New York: Scientific
18
American Library, 1988.
David Hubel has been at the center of research in this area
for 30 years, and his book provides an excellent introduc-
tion to the human visual system. He explains the current
view of the visual system in a way that is easily accessible
to anyone with some scientific training.
[vanT75] H. F. J. M. van Tuijl, A new visual illusion: Neonlike color
spreading and complementary color induction between
subjective contours, Acta Psychologica, vol. 39, pp. 441
445, 1975.
This paper describes the original discovery of the illusion in
which crosses of certain colors, when placed inside Ehren-
stein figures, appear to spread into solid shapes.
18-43
18 Grossberg Network
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 = iv. Check your answers to the previous parts by writing a MATLAB
4 M-file to simulate the leaky integrator. Use the ode45 routine. Plot
the response for each case.
Leaky Integrator
.
+ n n
p 1/
-
dn/dt = - n + p
18-45
18 Grossberg Network
b+ +
p+
-
.
+ + n n
1/
- -
+
p-
+
b-
E18.3 Suppose that Layer 1 of the Grossberg network has two neurons, with
+ 1 T
b = 0.5 , = 0.5 and input vector p = 2 1 . Assume that the initial
conditions are set to zero.
T
E18.4 Repeat Exercise E18.3 for input vector p = 20 10 .
E18.5 Consider the first layer of the Grossberg network. The parameters are set
+ 1 - 1 T
to be b = 2 , b = 0 , = 2 . The input to the network is p = 4 1 . Find
the first layer outputs and sketch them versus time.
18-46
Exercises
E18.6 Find the differential equation that describes the variation in the total out-
put of Layer 1,
1
S
ni (t) .
1 1
N (t) =
i=1
E18.7 Assume that Layer 2 of the Grossberg network has two neurons, with
2 + 2 - 2
f n = 2n , = 1 , b = 1 and b = 0 . The inputs have been applied for
some length of time, then removed.
2
i. What will be the steady state total output, lim N (t) ?
t
+ 2
ii. Repeat part (i) if b = 0.25 .
2+2
ans = iii. Check your answers to the previous parts by writing a MATLAB
4 M-file to simulate Layer 2 of the Grossberg network. Use the ode45
routine. Plot the responses for the following initial conditions:
1 0.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 ze-
ro, 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 sta-
ble 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 = iv. Check your answers to the previous parts by writing a MATLAB
4 M-file and simulating the total response of Layer 2 for c = 4 and
2
N ( 0) = 3 .
E18.9 Simulate the response of the adaptive weights for the Grossberg network.
Assume that the coefficient is 1 . Assume that two different input pat-
2+2 terns are alternately presented to the network for periods of 0.2 seconds at
ans = a time. Also, assume that Layer 1 and Layer 2 converge very quickly, in
4
comparison with the convergence of the weights, so that the neuron out-
18-47
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:
0.2 0
0.5 1
E18.10 Repeat Exercise E18.9, but use the Hebb rule with decay, Eq. (18.24), in-
2+2
stead of the instar learning of Eq. (18.25). Explain the differences between
ans = the two responses.
4
18-48
Objectives
Objectives
In Chapter 16 and Chapter 18 we learned that one key problem of compet-
itive 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 Adaptive Resonance Theory
19-2
Overview of Adaptive Resonance
Layer 1 Layer 2
Gain Control
Input
Expectation
Reset
Orienting
Subsystem
19-3
19 Adaptive Resonance Theory
Layer 1
The main purpose of Layer 1 is to compare the input pattern with the ex-
pectation pattern from Layer 2. (Both patterns are binary in ART1.) If the
patterns are not closely matched, the orienting subsystem will cause a re-
set in Layer 2. If the patterns are close enough, Layer 1 combines the ex-
pectation 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 differ-
ences 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 in-
put 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
W2:1 a2
+b1 S1 x S2
+
-
.
p + + n1 n1 a1
1/ f1
S1 x 1
- -
+
S1 S1
-b1 +
-W1 a2
Gain Control
S1 x S2
19-4
Layer 1
1 + 1
a = hardlim n , (19.2)
where
+ 1, n 0
hardlim n = . (19.3)
0, n 0
2:1 2
Eq. (19.1) is a shunting model with excitatory input p + W a t , which is
the sum of the input vector and the L2-L1 expectation. For example, as-
sume that the jth neuron in Layer 2 has won the competition, so that its
output is 1, and the other neurons have zero output. For this case we have
0
0
2:1 2 2:1
W a = w 2:1 2:1 2:1
1 w2 wj
2:1
w 2 = wj ,
S
(19.4)
1
2:1 2:1 2:1
where w j is the jth column of the matrix W . (The W matrix is
trained using an outstar rule, as we will show in a later section.) Now we
can see that
2:1 2 2:1
p+W 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 pat-
tern with the expectation using an AND operation, as we will see later.
- 1 2
The inhibitory input to Layer 1 is the gain control term W a t , where
1 1 1
1
W = 1 1
- 1
. (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 compe-
tition 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 in-
put 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
19 Adaptive Resonance Theory
1 S
2
S
2
dn i 1 2:1 2
-------- = n i + b n i p i + w i j a j n i + b a j ,
1 + 1 1 - 1 2
(19.7)
dt
j=1
j=1
19-6
Layer 1
1
dn 1 + 1 1 2:1 1 - 1
-------i- = n i + b n i p i + w i j n i + b . (19.12)
dt
1
In the steady state ( dn i (t) dt = 0 ) we have
1 + 1 1 2:1 1 - 1
0 = n i + b n i p i + w i j n i + b (19.13)
2:1 1 + 1 2:1 - 1
= 1 + p i + w i j + 1 n i + b p i + w i j b .
1
If we solve for the steady state neuron output n i we find
+ 1 2:1 - 1
1 b p i + w i j b
ni -.
= --------------------------------------------
2:1
(19.14)
2 + p i + w i j
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 pat-
terns (both the input and the expectation), we will use a logical AND oper-
1
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.
19-7
19 Adaptive Resonance Theory
- 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
If Layer 2 is not active (i.e., each a j = 0 ),
1
a = p. (19.20)
2
If Layer 2 is active (i.e., one a j = 1 ),
1 2:1
a = p wj . (19.21)
2 To demonstrate the operation of Layer 1, assume the following network pa-
+2
rameters:
+ 1 - 1
= 0.1 , b = 1 and b = 1.5 . (19.22)
Assume also that we have two neurons in Layer 2, two elements in the in-
put vector and the following weight matrix and input:
= 1 1 and p = 0 .
2:1
W (19.23)
0 1 1
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 (19.24)
dt
1 1 1 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 (19.25)
dt
1 1 1 1
= n 2 + 1 n 2 1 + 1 n 2 + 1.5 = 4n 2 + 0.5 .
19-8
Layer 1
1
dn 1 1
-------- = 30n 1 5 , (19.26)
dt
1
dn 2 1
-------- = 40n 2 + 5 . (19.27)
dt
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 solu-
tions are
1 1 30t
n 1 t = --- 1 e , (19.28)
6
1 1 40t
n 2 t = --- 1 e . (19.29)
8
1
0.1
n2 t
-0.1
1
n1 t
-0.2
0 0.05 0.1 0.15 0.2
= 0 1 = 0 = a .
2:1 1
p w2 (19.30)
1 1 1
To experiment with Layer 1 of the ART1 network, use the Neural Network
Design Demonstration ART1 Layer 1 (nnd16al1).
19-9
19 Adaptive Resonance Theory
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 en-
hancement will be a winner-take-all competition, so only the neuron that
receives the largest input will have a nonzero output.
There is one major difference between the second layers of the Grossberg
a0 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
n n 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 pe-
riod 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, us-
ing chemical neurotransmitters, in their ART3 architecture [CaGr90]. For
our purposes we will not be concerned with the specific biological imple-
mentation.
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 be-
tween the input signal and the L2-L1 expectation.
One other small difference between Layer 2 of the ART1 network and Lay-
er 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
+ +
On-Center +W2
W 1:2
S2 x S1
+b2 S2 x S2
+
-
. f2
a1 + + n2 n2
1/
- - a2
+
a0 -b2 +
S2
Reset -W2
Off-Surround
S2 x S2
+ 2 2 2 1:2 1
This is a shunting model with excitatory input W f (n (t)) + W a ,
+ 2
where W provides on-center feedback connections (identical to Layers 1
1:2
and 2 of the Grossberg network of Chapter 18, Eq. (18.6)), and W con-
sists of adaptive weights, analogous to the weights in the Kohonen net-
work. They are trained according to an instar rule, as we will see in a later
1:2
section. The rows of W , after training, will represent the prototype pat-
terns.
- 2 2 2 - 2
The inhibitory input to the shunting model is W f (n (t)) , where W pro-
vides off-surround feedback connections (identical to Layers 1 and 2 of the
Grossberg network Eq. (18.7)).
19-11
19 Adaptive Resonance Theory
1:2 T
w
= 0.1 , b = 1 , b = 1 , W = 1 = 0.5 0.5 , (19.32)
+ 2 - 2 1:2
1 1 1:2 T 1 0
2w
and
2 10 n 2 , n0
f ( n) = . (19.33)
0, n0
2
dn 2(t) 2 2 2 2 1:2 T 1
0.1 -------------
- = n 2(t) + 1 n 2(t) f (n 2(t)) + 2w a (19.35)
dt
2 2 2
n 2(t) + 1 f (n 1(t)) .
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 be-
2
tween the neurons. The transfer function f (n) is chosen to be a faster-than-
linear 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
1 T 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
a = 0 .
2
(19.36)
1
1
1:2 T 1
2w a 2
n2 t
0.5
1:2 T 1
1w a
0
-0.5 2
n1 t
-1
1:2 T 1 1:2 T 1
2 1, if iw a = max jw a
ai = . (19.37)
0, otherwise
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 Sub-
system. 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 Adaptive Resonance Theory
Orienting Subsystem
+b0
+
p +W0
-
1 x S1 .
+ + n0 n0 a0
1/ f0
- - Reset
+
a1 -W0 1
1 x S1 -b0 +
W p = p = pj = p ,
+ 0 2
(19.40)
j=1
19-14
Orienting Subsystem
Whenever the excitatory input is larger than the inhibitory input, the Ori-
enting Subsystem will be driven on. Consider the following steady state op-
eration:
0 + 0 0 2 0 - 0 1 2
0 = n + b n p n + b a (19.43)
2 1 2 0 + 0 2 - 0 1 2
= 1 + p + a n + b p b a .
0
If we solve for n , we find
+ 0 2 - 0 1 2
0 b p b a
n = ------------------------------------------------------------ . (19.44)
2 1 2
1 + p + a
+ 0 - 0 0 2 1 2
Let b = b = 1 , then n 0 if p a 0 , or in other words:
1 2
0 a
n 0 if -----------2- --- = . (19.45)
p
p = 1 and a = 1 .
1
(19.46)
1 0
19-15
19 Adaptive Resonance Theory
or
0
dn (t) 0
-------------- = 110n (t) + 20 . (19.48)
dt
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 vigi-
lance 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 param-
1
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
0
n t
0.1
-0.1
-0.2
0 0.05 0.1 0.15 0.2
1 2 2
0 1, if a p
a = . (19.49)
0, otherwise
To experiment with the Orienting Subsystem, use the Neural Network De-
sign Demonstration Orienting Subsystem (nnd16os).
19-16
Learning Law: L1-L2
L2 instar learning law, and in the following section we will present the L2-
L1 outstar learning law.
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 ad-
Resonance aptation, 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 dif-
ference. 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
= 1 1 0 ,
1:2
W (19.50)
1 1 1
1 1
1:2 1:2
1w = 1 and 2w = 1 . (19.51)
0 1
1:2 1:2 1:2 1:2
We say that 1w is a subset of 2w , since 2w has a 1 wherever 1w has
a 1.
If the output of Layer 1 is 19
1
1
a = 1 , (19.52)
0
1
W a = 11 0 1 = 2 .
1:2 1
(19.53)
11 1 2
0
19-17
19 Adaptive Resonance Theory
1
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 1
--- --- 0
= 2 2
1:2
W . (19.54)
1 1 1
--- --- ---
3 3 3
1 1
--- --- 0 1 1
a = 2 2
1:2 1
W 1 = 2 . (19.55)
1 1 1 ---
--- --- --- 0 3
3 3 3
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 net-
work we will normalize the prototype patterns by using an on-center/off-
surround competition in the L1-L2 learning law.
Learning Law
1:2
The learning law for W is
1:2
d iw t 2 + 1:2 + 1
------------------------- = a i t b iw t W a t (19.56)
dt
1:2 - - 1
iw t + b W a t ,
where
1 0 1 0 0 0 1 1
1
b = 1 , b = 0 , W = 0 1 0 and -
W = 1 0
+ - +
. (19.57)
1 0 0 0 1 1 1 0
19-18
Learning Law: L1-L2
ak
1:2 1 1:2 1
0 = 1 w i j a j w i j . (19.59)
kj
1:2
To find the steady state value of w i j , we will consider two cases. First, as-
1
sume that a j = 1 . Then we have
or
1:2
-.
w i j = ----------------------------- (19.61)
1 2
+ a 1
1
S
1 2
ak
1 1
(Note that = a , since a is a binary vector.)
k=1
1
On the other hand, if a j = 0 , then Eq. (19.59) reduces to
1:2 1 2
0 = w i j a , (19.62)
or
19-19
19 Adaptive Resonance Theory
1:2
w i j = 0 . (19.63)
19-20
ART1 Algorithm Summary
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 neu-
ron j of Layer 2 is active and there is a sufficient match between the expec-
tation 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
1 2: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 col-
2: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)
and activate the neuron in Layer 2 with the largest input (Eq. (19.37)):
19-21
19 Adaptive Resonance Theory
1:2 T 1 1:2 T 1
2 1, if iw a = max kw a
ai = . (19.69)
0, otherwise
In case of a tie, the neuron with the smallest index is declared the win-
ner.
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.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)
1 2 2
0 1, if a p
a = . (19.72)
0, otherwise
0 2
6. If a = 1 , then we set a j = 0 , inhibit it until an adequate match occurs
0
(resonance), and return to step 1. If a = 0 , we continue with step 7.
1:2
7. Resonance has occurred. Therefore we update row j of W (Eq.
(19.61)):
1
1:2 a
jw -.
= ----------------------------- (19.73)
1 2
+ a 1
2:1
8. We now update column j of W (Eq. (19.66)):
2:1 1
wj = a . (19.74)
9. We remove the input pattern, restore all inhibited neurons in Layer 2,
and return to step 1 with a new input pattern.
The input patterns continue to be applied to the network until the weights
stabilize (do not change). Carpenter and Grossberg have shown [CaGr87a]
that the ART1 algorithm will always form stable clusters for any set of in-
put patterns.
See Problems P19.5, P19.6 and P19.7 for detailed examples of the ART1 al-
gorithm.
19-22
Other ART Architectures
To experiment with the ART1 algorithm, use the Neural Network Design
Demonstration ART1 (nnd16a1).
19-23
19 Adaptive Resonance Theory
Summary of Results
Basic ART Architecture
Layer 1 Layer 2
Gain Control
Input
Expectation
Reset
Orienting
Subsystem
+ +
Expectation
W2:1 a2
+b1 S1 x S2
+
-
.
p + + n1 n1 a1
1/ f1
S1 x 1
- -
+
S1 S1
-b1 +
-W1 a2
Gain Control
S1 x S2
19-24
Summary of Results
Layer 1 Equation
1
dn (t) 1 + 1 1 2:1 2 1 - 1 - 1 2
-------------- = n (t) + b n (t) p + W a t n (t) + b W a t
dt
ART1 Layer 2
Layer 2
+ +
On-Center +W2
W 1:2
S2 x S1
+b2 S2 x S2
+
-
. f2
a1 + + n2 n2
1/
- - a2
+
a0 -b2 +
S2
Reset -W2
Off-Surround
S2 x S2
Layer 2 Equation
19
2
dn (t) 2 + 2 2 + 2 2 2 1:2 1 2 - 2 - 2 2 2
-------------- = n (t) + b n (t) W f (n (t)) + W a n (t) + b W f (n (t))
dt
1:2 T 1 1:2 T 1
2 1, if iw a = max jw a
ai =
0, otherwise
19-25
19 Adaptive Resonance Theory
Orienting Subsystem
Orienting Subsystem
+b0
+
p +W0
-
1 x S1 .
+ + n0 n0 a0
1/ f0
- - Reset
+
a1 -W0 1
1 x S1 -b0 +
1 2 2
0 1, if a p
a =
0, otherwise
1 0 1 0 0 0 1 1
0 1
b = 1 b = 0 W = 0 1
+ - +
W = 1 0
-
1 0 0 0 1 1 1 0
19-26
Summary of Results
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.
In case of a tie, the neuron with the smallest index is declared the win-
ner.
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 Adaptive Resonance Theory
4. Now that Layer 2 is active, we adjust the Layer 1 output to include the
L2-L1 expectation:
1 2:1
a = p wj .
1 2 2
0 1, if a p
a = .
0, otherwise
0 2
6. If a = 1 , then we set a j = 0 , inhibit it until an adequate match occurs
0
(resonance), and return to step 1. If a = 0 , we continue with step 7.
1:2
7. Resonance has occurred, therefore we update row j of W :
1
1:2 a
jw -.
= -----------------------------
1 2
+ a 1
2:1
8. We now update column j of W :
2:1 1
wj = a .
19-28
Solved Problems
Solved Problems
P19.1 Consider Layer 1 of the ART1 network with the following parame-
ters:
+ 1 - 1
= 0.01 b = 2 b = 3.
= 0 1 p = 1 .
2:1
W
1 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 1 1 1
= n 2 + 2 n 2 1 + 1 n 2 + 3 = 4n 2 + 1 .
If we assume that both neurons start with zero initial condition, the solu-
tions are
19-29
19 Adaptive Resonance Theory
1 1 300t
n 1 t = --- 1 e ,
3
1 1 400t
n 2 t = --- 1 e .
4
1
0.2
n2 t
-0.2
1
n1 t
-0.4
0 0.005 0.01 0.015 0.02
t
= 1 0 = 0 = a .
2:1 1
p w1 (19.75)
1 1 1
P19.2 Consider Layer 2 of the ART1 network with the following parame-
ters:
1:2 T
1w
b = 2 b = 2 = 0.5 0.5
+ 2 - 2 1:2
= 0.1 W =
2 2 1:2 T 1 0
2w
and
2 10 n 2 n0
f ( n) = .
0 n0
19-30
Solved Problems
a = 1 .
1
2
dn 2(t) 2 2 2 2 1:2 T 1
0.1 -------------
- = n 2(t) + 2 n 2(t) f (n 2(t)) + 2w a
dt
2 2 2
n 2(t) + 2 f (n 1(t)) .
Figure P19.2 illustrates the response of Layer 2 when the input vector is
1 T 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
2
1:2 T 1 n2 t
2w a
1
1:2 T 1
1w a
-1
2
n1 t
-2
0 0.05 0.1 0.15 0.2
t
19-31
19 Adaptive Resonance Theory
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 out-
puts 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 2
ii. At steady state, n 1(t) has a positive value, and n 2(t) has a negative val-
ue. The steady state Layer 2 output will then be
a = 1 .
2
This agrees with the desired steady state response characteristics of Layer
2:
1:2 T 1 1:2 T 1
2 1, if iw a = max jw a
ai = .
0, otherwise
P19.3 Consider the Orienting Subsystem of the ART1 network with the
following parameters:
+ 0 - 0
= 0.1 = 0.5 = 2 ( = 0.25 ) b = b = 0.5 .
1 1
1
p = 1 a = 0 .
1 1
0
i. Find and plot the response of the Orienting Subsystem n t .
ii. Verify that the steady state conditions are satisfied.
The equation of operation of the Orienting Subsystem is
0
dn (t) 0 0
0.1 -------------- = n (t) + 0.5 n (t) 0.5 p 1 + p 2 + p 3
dt
0 1 1 1
n (t) + 0.5 2 a 1 + a 2 + a 3
or
19-32
Solved Problems
0
dn (t) 0
-------------- = 65n (t) 12.5 .
dt
0 65t
n t = 0.1923 1 e
0
This response is plotted in Figure P19.3. In this case, since n t is nega-
0 + 0
tive, a = hardlim n = 0 , and therefore a reset signal will not be sent to
Layer 2.
0.3
0.15
0
-0.15 n t
-0.3
0 0.05 0.1 0.15 0.2
1 2 2
0 1, if a p
a = .
0, otherwise
19-33
19 Adaptive Resonance Theory
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
This is equivalent to the outstar rule of Chapter 15 (Eq. (15.51)). Here the
2
input to the L2-L1 connections is a j (t) , and the output of the L2-L1 connec-
1
tions is a .
0 1 1
p1 = 1 , p2 = 0 , p3 = 1 .
0 0 0
2
Use the parameters = 2 , and = 0.4 , and choose S = 3 (3 cate-
gories).
Our initial weights will be
0
1
a = p1 = 1 .
0
19-34
Solved Problems
Since all neurons have the same input, pick the first neuron as the win-
ner. (In case of a tie, pick the neuron with the smallest index.)
1
2
a = 0
0
11 1 1 1
2:1 2 2:1
W a = 1 1 1 0 = 1 = w1 .
11 1 0 1
0 1 0
1 2:1
a = p1 w1 = 1 1 = 1 .
0 1 0
1 2 2 1 0
a p1 = --- = 0.4 , therefore a = 0 (no reset).
0
1
19
6. Since a = 0 , continue with step 7.
1:2
7. Resonance has occurred, therefore update row 1 of W :
1 0 0 1 0
1:2 2a 1 1:2
1w = -----------------------------
- = a = 1 , W = 0.5 0.5 0.5 .
1 2
2+ a 1
0 0.5 0.5 0.5
2:1
8. Update column 1 of W :
19-35
19 Adaptive Resonance Theory
0 0 1 1
2:1 1 2:1
w1 = a = 1 ,W = 1 1 1 .
0 0 1 1
1
1
a = p2 = 0 .
0
0 1 0 1 0
1:2 1
W a = 0.5 0.5 0.5 0 = 0.5 .
0.5 0.5 0.5 0 0.5
Since neurons 2 and 3 have the same input, pick the second neuron as
the winner:
0
2
a = 1 . (19.76)
0
01 1 0 1
2:1 2 2:1
W a = 1 1 1 1 = w2 = 1 .
01 1 0 1
1 1 1
1 2:1
a = p2 w2 = 0 1 = 0 .
0 1 0
1 2 2 1 0
a p2 = --- = 0.4 , therefore a = 0 (no reset).
1
19-36
Solved Problems
0
6. Since a = 0 , continue with step 7.
1:2
7. Resonance has occurred, therefore update row 2 of W :
1 1 0 1 0
1:2 2a 1 1:2
2w = -----------------------------
- = a = 0 , W = 1 0 0 .
1 2
2+ a 1
0 0.5 0.5 0.5
2:1
8. Update column 2 of W :
1 0 1 1
2:1 1 2:1
w2 = a = 0 ,W = 1 0 1 .
0 0 0 1
1
1
a = p3 = 1 .
0
0 1 0 1 1
1:2 1
W a = 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 win-
ner:
19
1
2
a = 0 .
0
01 1 1 0
2:1 2 2:1
W a = 1 0 1 0 = w1 = 1 .
00 1 0 0
19-37
19 Adaptive Resonance Theory
1 0 0
1 2:1
a = p3 w1 = 1 1 = 1 .
0 0 0
1 2 2 1 0
a p3 = --- = 0.4 , therefore a = 0 (no reset).
2
0
6. Since a = 0 , continue with step 7.
1:2
7. Resonance has occurred, therefore update row 1 of W :
1 0 0 1 0
1:2 2a 1 1:2
1w = -----------------------------
- = a = 1 , W = 1 0 0 .
1 2
2+ a 1
0 0.5 0.5 0.5
2:1
8. Update column 1 of W :
0 0 1 1
2:1 1 2:1
w2 = 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 success-
fully clustered. This type of result (stable learning) is guaranteed for the
ART1 algorithm, since it has been proven to always produce stable clus-
ters.
1
1
a = p3 = 1 .
0
19-38
Solved Problems
0 1 0 1 1
1:2 1
W a = 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 win-
ner:
1
2
a = 0 .
0
01 1 1 0
2:1 2 2:1
W a = 1 0 1 0 = w1 = 1 .
00 1 0 0
1 0 0
1 2:1
a = p3 w1 = 1 1 = 1 .
0 0 0
1 2 2 1 0
a p3 = --- = 0.6 , therefore a = 1 (reset).
2
0 2
6. Since a = 1 , set a 1 = 0 , inhibit it until an adequate match occurs
(resonance), and return to step 1.
19
1. Recompute the Layer 1 response (Layer 2 inactive):
1
1
a = p3 = 1 .
0
19-39
19 Adaptive Resonance Theory
0 1 0 1 1
1:2 1
W a = 1 0 0 1 = 1 .
0.5 0.5 0.5 0 1
0
2
a = 1 .
0
01 1 0 1
2:1 2 2:1
W a = 1 0 1 1 = w2 = 0 .
00 1 0 0
1 1 1
1 2:1
a = p3 w2 = 1 0 = 0 .
0 0 0
1 2 2 1 0
a p3 = --- = 0.6 , therefore a = 1 (reset).
2
0 2
6. Since a = 1 , set a 2 = 0 , inhibit it until an adequate match occurs
(resonance), and return to step 1.
1. Recompute the Layer 1 response:
1
1
a = p3 = 1 .
0
0 1 0 1 1
1:2 1
W a = 1 0 0 1 = 1 .
0.5 0.5 0.5 0 1
19-40
Solved Problems
0
2
a = 0 .
1
01 1 0 1
2:1 2 2:1
W a = 1 0 1 0 = w3 = 1 .
00 1 1 1
1 1 1
1 2:1
a = p3 w3 = 1 1 = 1 .
0 1 0
1 2 2 2 0
a p3 = --- = 0.6 , therefore a = 0 (no reset).
2
0
6. Since a = 0 , continue with step 7.
1:2
7. Resonance has occurred, therefore update row 3 of W :
2
--- 0 1 0
1 3
2a 2 1
3w
1:2
2+ a 1
1 2
- = --- a = 2 , W = 1 0 0 .
= -----------------------------
3 ---
3
1:2
2 2
--- --- 0
19
3 3
0
2:1
8. Update column 3 of W :
1 0 1 1
2:1 1 2:1
w3 = 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 Adaptive Resonance Theory
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 proto-
type. 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
2
- = ----------------------------- = 0.0769 .
---------------------------
+ S 1
1 2 + 25 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 cal-
culations 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
1 6
1 2
2 7
3 8
1
4 9
5 10
19-43
19 Adaptive Resonance Theory
Epilogue
Competitive learning, and many other types of neural network training al-
gorithms, 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 inno-
vation of ART is the use of expectations. As each input pattern is present-
ed 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 learn-
ing. They have as much to do with understanding how the brain works as
they do with inspiring practical pattern recognition systems. For this rea-
son, 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 prob-
lem that we have not yet discussed. This is the stability of the differential
equations that implement the short-term memory equations of the net-
work. In Layer 2, for example, we have a set of differential equations with
nonlinear feedback. Can we make some general statement about the sta-
bility 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 ar-
chitecture for a self-organizing neural pattern recognition
machine, Computer Vision, Graphics, and Image Process-
ing, vol. 37, pp. 54115, 1987.
In this original presentation of the ART1 architecture, Car-
penter and Grossberg demonstrate that the architecture
self-organizes and self-stabilizes in response to an arbi-
trary 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-organiza-
tion 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 architec-
ture that is designed to handle analog input patterns.
[CaGr90] G. A. Carpenter and S. Grossberg, ART3: Hierarchical
search using chemical transmitters in self-organizing pat-
tern recognition architectures, Neural Networks, vol. 3,
no. 23, pp. 129152, 1990.
This article demonstrates how the Orienting Subsystem of
the ART networks could be implemented in biological neu-
rons through the use of chemical transmitters.
[CaGrMa92] G. A. Carpenter, S. Grossberg, N. Markuzon, J. Reynolds
and D. Rosen, Fuzzy ARTMAP: An adaptive resonance ar-
chitecture for incremental learning of analog maps, Pro-
ceedings of the International Joint Conference on Neural
Networks, Baltimore, MD, vol. 3, no. 5, pp. 309314, 1992. 19
The authors present a modification of the ARTMAP archi-
tecture to include fuzzy logic that enables better perfor-
mance in a noisy environment.
[CaGrRe91] G. A. Carpenter, S. Grossberg and J. Reynolds, ARTMAP:
Supervised real-time learning and classification of nonsta-
tionary data by a self-organizing neural network, Neural
Networks, vol. 4, no. 5, pp. 169181, 1991.
This article presents an adaptive resonance theory net-
work for supervised learning. The network consists of two
interconnected ART modules. One module receives the in-
put vector, and the other module receives the desired out-
put vector.
19-45
19 Adaptive Resonance Theory
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 ma-
trix and input:
= 0 1 p = 0 .
2:1
W
1 1 1
E19.2 Consider Layer 2 of the ART1 network with the following parameters:
1:2 T 2 2
1:2 1w --- ---
= 0.1 W = = 3 3
1:2 T
2w 1 0
and
2 10 n 2 , n0
f (n) = .
0, n0
a = 1 .
1
1
2+2
ans = i. Write the equations of operation of Layer 2, and simulate and plot
4 the response if the following bias vectors are used:
19-47
19 Adaptive Resonance Theory
b = 2 b = 2 .
+ 2 - 2
2 2
b = 3 b = 3 .
+ 2 - 2
3 3
b = 3 b = 0 .
+ 2 - 2
3 0
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 - 0
= 0.1 b = b = 2.
1 0
1
p = 1 a = 0 .
1 1
0
i. Find and plot the response of the Orienting Subsystem n t , for
= 0.5 = 4 ( = 0.125 ).
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 = iv. Check your answers to parts (i) and (ii) by writing a MATLAB M-file
4 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 pre-
sented in Chapter 15 and the Kohonen competitive learning rule in Chap-
ter 16.
0 1 1 1
p1 = 1 , p2 = 0 , p3 = 1 , p3 = 1 .
0 0 0 1
1 1 0 1
2
Use the parameter = 2 , and choose S = 3 (3 categories).
i. Train the network to convergence using = 0.3 .
ii. Repeat part (i) using = 0.6 .
iii. Repeat part (ii) using = 0.9 .
E19.6 The ART1 algorithm can be modified to add a new neuron in Layer 2 when-
ever there is no adequate match between the existing prototypes and the
1:2
input pattern. This involves creating a new row of the W matrix and a
2:1
new column of the W matrix. Describe how this would be done.
E19.7 Write a Matlab M-file to implement the ART1 algorithm (with the modifi-
2+2
cation described in Exercise E19.6). Use this M-file to train an ART1 net-
ans = work using the following input vectors (see Problem P19.7):
4
p1 p2 p3 p4
19-49
19 Adaptive Resonance Theory
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:
2+2
ans =
4
p1 p2 p3 p4 p5 p6 p7 p8 p9 p10
2
Use the parameter = 2 , and choose S = 5 (5 categories). Use the Mat-
lab 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 vigi-
lance parameter.
19-50
Objectives
20 Stability
Objectives 20-1
Theory and Examples 20-2
Recurrent Networks 20-2
Stability Concepts 20-3
Definitions 20-4
Lyapunov Stability Theorem 20-5
Pendulum Example 20-6
LaSalles Invariance Theorem 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, respec-
tively. 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 Stability
Recurrent Networks
We first discussed recurrent neural networks, which have feedback connec-
tions from their outputs to their inputs, when we introduced the Hamming
and Hopfield networks in Chapter 3. The Grossberg networks of Chapter
18 and Chapter 19 also contain recurrent connections. Recurrent networks
are potentially more powerful than feedforward networks, since they are
able to recognize and recall temporal, as well as spatial, patterns. However,
the behavior of these recurrent networks is much more complex than that
of feedforward networks.
For feedforward networks, the output is constant (for a fixed input) and is
a function only of the network input. For recurrent networks, however, the
output of the network is a function of time. For a given input and a given
initial network output, the response of the network may converge to a sta-
ble output. However, it may also oscillate, explode to infinity, or follow a
chaotic pattern. In the remainder of this chapter we want to investigate
general nonlinear recurrent networks, in order to determine their long-
term behavior.
We will consider recurrent networks that can be described by nonlinear dif-
ferential equations of the form:
d
a t = g a t ,p t ,t . (20.1)
dt
Here p t is the input to the network, and a t is the output of the network.
(See Figure 20.1.)
p .
a a
g
a(0)
20-2
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 con-
stant output a stable equilibrium point. A nonlinear system can have
many stable points. For some neural networks these stable points repre-
sent 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 dis-
sipative 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 sur-
face 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, be-
cause 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 posi-
tioned 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 bear-
ing 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 equilibri-
um 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 net-
works with large basins of attraction such as those of Case A. One can cer-
tainly 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 Stability
Case B
Complex Region of Attraction
P
Definitions
We will begin with specific mathematical definitions of the different types
of stability discussed in the previous section. In these definitions we will be
Equilibrium Point talking about the stability of an equilibrium point; a point a where the de-
rivative in Eq. (20.1) is zero. For simplicity, we will talk specifically about
the point a = 0 , which is referred to as the origin. This restriction does
not affect the generality of our discussion.
Stability 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 .
This definition says that the system output is not going to move too far
away from a given stable point, so long as it is initially close to the stable
point. Lets say that you want the system output to remain within a dis-
tance of the origin. If the origin is stable, then you can always find a dis-
tance (which may be a function of ), such that if the system output is
within of the origin at time t = 0 , then it will always remain within of
the origin. The position of the ball (with zero velocity) in the figure to the
left is stable in the sense of Lyapunov, so long as the ball bearing has fric-
tion. If the ball bearing did not have friction, then any initial velocity would
produce a trajectory a t in which the position would go to infinity. (The
vector a t in this case would consist of the position and the velocity of the
ball.)
Next, lets consider the stronger concept of asymptotic stability.
20-4
Lyapunov Stability Theorem
da
= ga . (20.2)
dt
20-5
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 opera-
tion is easy to visualize, and yet it illustrates important concepts that we
will apply to neural network design in the next chapter. The example sys-
tem we will use is the pendulum shown in Figure 20.3.
l
m
mg
Figure 20.3 Pendulum
Using Newtons second law ( F = ma ), we can write the equation of opera-
tion of the pendulum as
2
d d
ml 2
() = c mg sin , (20.3)
dt dt
20-6
Pendulum Example
or
2
d d
ml 2
+c + mg sin = 0 , (20.4)
dt dt
d
a 1 = and a 2 = . (20.5)
dt
We can write equations for the pendulum in terms of these state variables
as follows:
da 1
= a2 , (20.6)
dt
da 2 g c
= --- sin a 1 ------ a 2 . (20.7)
dt l ml
Now we want to investigate the stability of the origin ( a = 0 ) for this pen-
dulum 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 equi-
librium point. We do this by substituting a = 0 into the state equations.
da 1
= a2 = 0 , (20.8)
dt
20-7
20 Stability
da 2 g c g c
= --- sin a 1 ------ a 2 = --- sin 0 ------ 0 = 0 (20.9)
dt l ml l ml
1 2 2
V a = --- ml a 2 + mgl 1 cos a 1 (20.10)
2
In order to test the stability of the system, we need to evaluate the deriva-
tive of V with respect to time.
d T V da 1 V da 2
V a = V a g a = + (20.11)
dt a1 d t a2 d t
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
d 2
V a = cl a 2 0 . (20.13)
dt
20-8
Pendulum Example
da 1
= a2 , (20.14)
dt
da 2
= sin a 1 0.2a 2 . (20.15)
dt
2 1 2
V = 9.8 --- a 2 + 1 cos a 1 , (20.16)
2
dV 2
= 19.208 a 2 . (20.17)
dt
400
1
300
200
a2 0
100
-1
0
2
1 10
0 5 -2
a2 0
-1 a1
-5
-2 -10 -10 -5 0 5 10
a1
20-9
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
a2 0
x2
-1
-2
-10 -5 0 5 10
ax11
20-10
Pendulum Example
2 a1
-1
a2
-2
0 10 20 30 40
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 plac-
es 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 ori-
gin, then the origin is asymptotically stable.
160
120
80
Vt
40
0 10 20
t
30 40
20
Figure 20.7 Pendulum Lyapunov Function (Energy) vs. Time
The particular pendulum behavior shown in the graphs in this section de-
pends on the initial conditions of the two state variables. The choice of a dif-
ferent 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 Stability
To experiment with the pendulum, use the Neural Network Design Demon-
stration Dynamic System (nnd17ds).
Definitions
Lyapunov Function Definition 5: Lyapunov Function
n
Let V be a continuously differentiable function from to . If G is any
n
subset of , we say that V is a Lyapunov function on G for the system
da dt = g a if
dV a T
--------------- = V a g a (20.18)
dt
20-12
LaSalles Invariance Theorem
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.
If the system gets into an invariant set, then it cant get out.
This set includes all possible points at which the solution might converge.
The Lyapunov function does not change in L (because its derivative is ze-
ro), 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].
20-13
20 Stability
= a:V a . (20.20)
LaSalles theorem, and its corollary, are very powerful. Not only can they
tell us which points are stable ( L ), but they can also provide us with a par-
tial region of attraction ( G ). (Note that L is constructed differently in the
corollary than in the theorem.)
To clarify LaSalles Invariance Theorem, lets return to the pendulum ex-
ample we discussed earlier.
Example
2 Lets apply Corollary 1 to the pendulum example. The first step in using the
+2
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 .
a2 0
-1
-2
-10 -5 0 5 10
a1
20-14
LaSalles Invariance Theorem
origin, lets choose the component of 100 that contains a = 0 . The result-
ing set is shown in Figure 20.9.
a2 0
-1
-2
-10 -5 0 5 10
a1
Now that we have chosen G , we need to check that the derivative of the
Lyapunov function is less than or equal to zero on G . From Eq. (20.17) we
know that dV a dt is negative semidefinite. Therefore it will certainly be
less than or equal to zero on G .
We are now ready to determine the attractor set L . We begin with the set
L , which is the largest invariant set in Z .
Z = a: dV a dt = 0 a in the closure of G
= a: a 2 = 0, a in the closure of G .
(20.22)
This can also be written as
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 tra-
jectory will move out of Z . Therefore, the set L consists only of the origin:
L = a: a = 0 . (20.24)
20-15
20 Stability
Z
a2 0
-1
-2
-10 -5 0 5 10
a1
The set L is the closure of the intersection of L and G , which in this case
is simply L :
L = closure L G = L = a: a = 0 . (20.25)
1
Z
a2 0
-1
-2
-10 -5 0 5 10
a1
We let G = 300 , since 300 has only one component. The set Z is given by
20-16
LaSalles Invariance Theorem
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 pendu-
lum in any of these positions, with zero velocity, then the pendulum will re-
main stationary. We can show this by setting the derivatives equal to zero
in Eq. (20.14) and Eq. (20.15).
da 1
= a2 = 0 , (20.29)
dt
For this choice of G = 300 we can say very little about where the trajecto-
ry will converge. We tried to increase the size of our known region of attrac-
tion 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.
a2 0
-1
-2
-10 -5 0 5 10
a1
We cannot tell which of the equilibrium points (blue dots) will attract the
trajectory. All we can say is that if we start somewhere in 300 , one of the
equilibrium points will attract the system solution, but we cannot say for
sure which one it will be. Consider, for instance, the trajectory shown in
20-17
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 pen-
dulum had enough velocity to go over the top, and it converged to the equi-
librium 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 re-
gions of attraction for the various stable points. To experiment with the pen-
dulum, use the Neural Network Design Demonstration Dynamic System
(nnd17ds).
Contour Plot
a2 0
x2
-1
-2
-10 -5 0 5 10
ax11
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 in-
dicate 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) ev-
n
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 func-
tion, 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 attrac-
tion.
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 .
da
= ga .
dt
20-19
20 Stability
dV a T
--------------- = V a g a
dt
Definition 6: Set Z
Definition 8: Set L
L is defined as the largest invariant set in Z .
Theorem
= a:V a . (20.32)
20-20
Solved Problems
Solved Problems
P20.1 Test the stability of the origin for the following system.
2
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 defi-
nite. (The latter is a stronger condition.)
2 2
Let us try V a = a 1 + a 2 . The derivative of V a is
dV a V da 1 V da 2
--------------- = V ------ =
T da
-------- + -------- ,
dt dt a 1 dt a 2 dt
or
dV a 2 2 2
--------------- = 2a 1 a 1 + a 2 + 2a 2 a 2 a 1 + 1 = 2 a 1 2 a 2 .
dt
P20.2 Test the stability of the origin for the following system.
5
da 1 dt = a 1
7
da 2 dt = 5 a 2
2 2
Let us try V a = a 1 + a 2 . Then we have
dV a 5 7 6 8
--------------- = 2a 1 a 1 + 2a 2 5 a 2 = 2 a 1 10 a 2 .
dt
da 1 dt = a 2 ,
20-21
20 Stability
3
da 2 dt = a 1 a 2 (nonlinear spring) .
1 4 1 2
V a = --- a 1 + --- a 2 .
4 2
dV a V da 1 V da 2 3 3 2
--------------- = -------- + -------- = a 1 a 2 + a 2 a 1 a 2 = a 2 .
dt a 1 dt a 2 dt
2
Thus, dV dt does not change sign on .
Now let us define
G = = a: V a
a2 0
-2
-4
-4 -2 0 2 4
a1
20-22
Solved Problems
or
Z = a: a 2 = 0, 2 a 1 2
L = a: a 1 = 0, a 2 = 0 .
a = 0 ,
0
a2 0
x2
-2
-4
-4 -2 0 2 4
ax11
20-23
20 Stability
2 2
da 2 dt = a 1 + a 2 a 1 + a 2 4 .
a: a = 0 ,
dV a V da 1 V da 2
--------------- = -------- + -------- ,
dt a 1 dt a 2 dt
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
dV a 2 2 2 2
--------------- = 2 a 1 + a 2 a 1 + a 2 4 .
dt
2 2
Thus, dV dt is zero at a = 0 and on the circle a 1 + a 2 = 4 .
We now pick G , a region of attraction. Is there a change of sign of dV dt
2
over all ? Yes, there is. As we go from outside the circle of radius 2 to its
interior, the sign of dV dt changes from positive to negative. So dV dt is
2 2
negative semidefinite inside the circle a 1 + a 2 = 4 . Lets pick a G in-
side this circle, so that the circle will not be included. The following set will
do.
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 in-
2 2
cludes all points inside the circle a 1 + a 2 = 4 .
Figure P20.4 displays two trajectories for this system, one that begins in-
2 2
side the circle a 1 + a 2 = 4 , and one that begins outside the circle. Al-
though the circle is an invariant set, it is not an attractor. The only
attractor for this system is the origin.
Contour Plot
3
a2 0
x2
-1
-2
-3
-3 -2 -1 0 1 2 3
ax11
da t dt = a t 1 a t 2
20-25
20 Stability
2
Va = a 2
dV V da 2
------- = = 2 a 2 a 1 a 2 = 2 a 1 a 2
dt a dt
Now we let
G = = a: V a .
Z = a: a = 2 .
Now we need to find L , the largest invariant set in Z . There is only one
point in Z , and it is an equilibrium point. Thus
L = L = Z .
a: 1 a 3 .
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 con-
dition above a = 1 converges to a = 2 . Anything less than a = 1 goes to
minus infinity.
4
0
0 1 2 3 4
t
20-27
20 Stability
Epilogue
In this chapter we have presented the concept of stability, as applied to dy-
namic systems. For nonlinear dynamic systems, like recurrent neural net-
works, 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 gener-
alized 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 im-
provements 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 con-
cept 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 infor-
mation 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 re-
current 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] W. L. Brogan, Modern Control Theory, 3rd Ed., Englewood
Cliffs, NJ: Prentice-Hall, 1991.
This is a well-written book on the subject of linear systems.
The first half of the book is devoted to linear algebra. It also
has good sections on the solution of linear differential equa-
tions and the stability of linear and nonlinear systems. It
has many worked problems.
[CoGr83] M. A. Cohen and S. Grossberg, Absolute stability of global
pattern formation and parallel memory storage by compet-
itive neural networks, IEEE Transactions on Systems,
Man and Cybernetics, vol. 13, no. 5, pp. 815826, 1983.
Cohen and Grossberg apply LaSalles Invariance Theorem
to the analysis of the stability of competitive neural net-
works. The network description is very general, and the au-
thors show how their analysis can be applied to many
different types of recurrent neural networks.
[Lasa67] J. P. LaSalle, An invariance principle in the theory of sta-
bility, 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, En-
glewood 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 theo-
rems 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
i. da 1 dt = a 1 + a 2
da 2 dt = a 1 a 2
2
ii. da 1 dt = a 1 + a 2
da 2 dt = a 2 a 1 + 1
2 2
da 2 dt = a 1 2a 2 a 1 + a 2 .
da dt = a a + 1 ,
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.)
2
i. da dt = a 2 a + 1 , V a = a + 1
3 2
ii. da dt = a a + 1 , V a = 2a + 3a
3 2
iii. da dt = a a + 2 , V a = a 3 a
3 2
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
da 1 dt = a 2 ,
2
da 2 dt = a 2 1 a 2 a 1 .
da 1 dt = a 2 ,
20-31
20 Stability
3
da 2 dt = a 1 a 2 .
f (a) = 1 - (a / ) 2
20-32
Exercises
3 5 4 2
da 2 dt = a 1 3 a 2 a 1 + 2 a 2 10 .
2+2
i. Find any invariant sets. (You may want to simulate this system us-
ans = ing MATLAB in order to help identify the invariant sets.)
4
ii. Using the candidate Lyapunov function shown below and the corol-
lary to LaSalles theorem, investigate the stability of the invariant
sets you found in part (i).
4 2 2
V a = a 1 + 2 a 2 10
da
= 1 0 a + 1
dt 0 2 2
2 2
da 2 dt = a 1 + a 2 1 a 1 a 2 ,
a a = 0 ,
2
a a1 + a2 = 1 .
2 20
The following Lyapunov function is proposed:
2 2 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.
da 1 dt = cos a 2 a 1 ,
da 2 dt = a 1 .
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
Theory and Examples 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 net-
work 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 eigenvec-
tors (Chapter 6); associative memory and the Hebb rule (Chapter 7); Hes-
sian matrices, conditions for optimality, quadratic functions and surface
and contour plots (Chapter 8); steepest descent and phase plane trajecto-
ries (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 Hopfield Network
21-2
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
In keeping with his practical viewpoint, Hopfield presented his model as an
Hopfield Model electrical circuit. The basic Hopfield model (see [Hopf84]) is shown in Fig-
ure 21.1.
I1 I2 IS
R1,S
Amplifier RS,2
Inverting R2,1
Output
n1 n2 nS
C C C
Resistor
a1 a2 aS
21-3
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
1 1 1 1
-------
1
T i j = -------- , ----- = --- + -, n = f a i (or a i = f n i ), (21.2)
R i j R i R i j i
j=1
= R i C , w i j = R i T i j and b i = R i I i . (21.4)
dn(t)
------------ = n(t) + Wa(t) + b . (21.6)
dt
and
21-4
Lyapunov Function
p
W - .
Sx1 + n n a
SxS 1/ f
Sx1 Sx1
1 b
Sx1
S -1
S
f
-1
n(0) = f (p), (a(0) = p) 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 Gross-
berg 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 func-
tion:
ai
S
1 T 1
f u du b a .
T
V a = --- a Wa + (21.8)
2
i=1 0
21-5
21 Hopfield Network
d 1 T 1 T T da T da T da
--- a Wa = --- a Wa ------ = Wa ------ = a W ------ . (21.9)
dt 2 2 dt dt dt
ai ai
d 1 d 1 da i da da
dt 0
f u du =
d ai 0
f u du
1
= f ai i = ni i .
dt dt
(21.10)
d t
S ai
d 1 T da
-----
dt f u du = n -----
dt
-. (21.11)
i=1 0
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 ------ (21.12)
dt dt dt
d T da T da T da T T T da
V a = a W ------ + n ------ b ------ = a W + n b ------ . (21.13)
dt dt dt dt dt
dn i d 1 d 1 da
= f ai = f ai i . (21.16)
dt dt d ai dt
21-6
Lyapunov Function
S S
dn da da 2
V a = i i = f a i i .
d d 1
(21.17)
dt dt dt d ai dt
i=1 i=1
1
If we assume that f a i is an increasing function, as it would be for an op-
erational amplifier, then
d 1
f ai 0 . (21.18)
d ai
d
V a 0 . (21.19)
dt
1
Thus, if f a i is an increasing function, dV a dt is a negative semidefi-
nite function. Therefore, V a is a valid Lyapunov function.
Invariant Sets
Now we want to apply LaSalles Invariance Theorem to determine equilib-
rium points for the Hopfield network. The first step is to find the set Z (Eq.
(20.19)).
This set includes all points at which the derivative of the Lyapunov func-
S
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 deriv-
atives of all of the neuron outputs are zero.
da
------ = 0 (21.21)
dt
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 (21.22)
21-7
21 Hopfield Network
Example
2 Consider the following example from Hopfields original paper [Hopf84].
+2
We will examine a system having an amplifier characteristic
2 1 n
a = f n = --- tan --------- . (21.23)
2
n = ------ tan --- a .
2
(21.24)
2
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)
W = 0 1 . (21.26)
1 0
= Ri C = 1 . (21.27)
b = 0 . (21.28)
0
S ai
1 T 1
f u du b a .
T
V a = --- a Wa + (21.29)
2
i=1 0
1 T 1 a
--- a Wa = --- a 1 a 2 0 1 1 = a 1 a 2 . (21.30)
2 2 1 0 a2
21-8
Lyapunov Function
The third term is zero, because the biases are zero. The ith part of the sec-
ond term is
ai ai
ai
- tan --- u du = ------ log cos --- u ---
2 2 2
f u du = -----
1
2 2
. (21.31)
0 0 0
ai
= -------2- log cos --- a i .
4
f 1 u du 2
(21.32)
0
Finally, substituting all three terms into Eq. (21.29), we have our
Lyapunov function:
V a = a 1 a 2 ------------2- log cos --- a 1 + log cos --- a 2 .
4
(21.33)
2 2
1.4
Now lets write out the network equation (Eq. (21.6)). With = 1 and
b = 0 , it is
dn
------ = n + Wf n = n + Wa . (21.34)
dt
dn 1 dt = a 2 n 1 , (21.35)
dn 2 dt = a 1 n 2 . (21.36)
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 Fig-
ure 21.3.
21-9
21 Hopfield Network
0.5
a2 0
-0.5 1
0.5 1
0.5
a2 0 0
-1
-0.5
-0.5 a1
-1 -0.5 0 0.5 1 -1 -1
a1
0.5
0
a2
-0.5
a1
-1
0 2 4 6 8 10
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 1
0.5
0 2 4 6 8 10
0.5
a2 0
-0.5
-1
-1 -0.5 0 0.5 1
a1
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 Hopfield Network
da
------ = 0 . (21.39)
dt
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
T
V = V V ... V = 0, (21.40)
a1 a2 aS
where
S ai
1 T 1
f u du b a .
T
V a = --- a Wa + (21.41)
2
i=1 0
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 = ------------ . (21.42)
dt
dn d 1 d 1 da
V a = i = ( f a i ) = f a i i . (21.43)
ai dt dt d ai dt
1
Notice, incidentally, that if f a is linear, Eq. (21.43) implies that
da
------ = V a . (21.44)
dt
d 1
f ai 0 . (21.45)
d ai
From Eq. (21.43), this implies that those points for which
21-12
Effect of Gain
da(t)
------------ = 0 , (21.46)
dt
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 cas-
es where the amplifier gain is large. Recall that the nonlinear amplifier
characteristic for our previous example was
2 1 n
a = f n = --- tan --------- . (21.48)
2
This function is displayed in Figure 21.7 for four different gain values.
1
= 14
= 1.4
0.5
= 0.14
a 0
-0.5
-1
-5 -2.5 0 2.5 5
n
S ai
1 T 1
f u du b a .
T
V a = --- a Wa + (21.49)
2
i=1 0
21-13
21 Hopfield Network
u
f u = ------ tan ------ .
1 2
(21.50)
2
Therefore, the second term in the Lyapunov function takes the form
ai
a a
= ------ --- log cos --------i = -------2- log cos --------i .
2 2 4
f 1 u du 2 2
(21.51)
0
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
High-Gain 1 a i 1 . This allows us to eliminate that term, and the high-gain
Lyapunov Function Lyapunov function then reduces to
1 T T
V a = --- a Wa b a . (21.52)
2
1.5
= 0.14
1
= 1.4
0.5
0
= 14
-1 -0.5 0 0.5 1
a
1 T T 1 T T
V a = --- a Wa b a = --- a Aa + d a + c , (21.53)
2 2
where
2V a = A = W , d = b and c = 0 . (21.54)
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
2V a = W = 0 1 . (21.55)
1 0
2V a I = 1 2
= 1 = + 1 1 . (21.56)
1
z 1 = 1 and z 2 = 1 . (21.57)
1 1
What does the surface of the high-gain Lyapunov function look like? We
know, since the Hessian matrix has one positive and one negative eigenval-
ue, 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 con-
strained to the hypercube a: 1 a i 1 by the amplifier transfer func-
tion. Therefore, there will be constrained minima at the two corners of the
hypercube
a = 1 and a = 1 . (21.58)
1 1
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 oc-
cur at
21-15
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 sec-
tions, after we describe the Hopfield design process.
0.5
0.5
0
0
-0.5
-0.5 -1
1
0.5 1
0 0.5
0
-1 -0.5
-0.5
-1 -0.5 0 0.5 1
-1 -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 . (21.60)
2
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
In this section we will describe how a Hopfield network can be designed to
work as an associative memory. The type of associative memory we will de-
Content-Addressable sign is called a content-addressable memory, because it retrieves stored
Memory memories on the basis of part of the contents. This is in contrast to stan-
dard computer memories, where items are retrieved based on their ad-
dresses. For example, if we have a content-addressable data base that
contains names, addresses and phone numbers of employees, we can re-
trieve a complete data entry simply by providing the employee name (or
21-16
Hopfield Design
p 1 p 2 p Q . (21.61)
The second equality follows from the orthogonality of the prototype pat-
terns. 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 in-
put. The inner product will increase as the input moves closer to a proto-
21-17
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 per-
formance 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 tar-
get patterns being the same as input patterns) as
Q
pq pq
T
W = , (21.64)
q=1
b = 0, (21.65)
21-18
Hopfield Design
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 Chap-
ter 7, Problem P7.5.) The supervised Hebb rule is given by
Q
pq pq
T
W = . (21.68)
q=1
pq pq
T T
Wp j = p j = p j p j p j = Sp j , (21.69)
q=1
where the second equality holds because the prototype patterns are orthog-
onal, 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)
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
= 1 Sp 1 + 2 Sp 2 + + Q Sp Q
= S 1 p 1 + 2 p 2 + + Q p Q = Sa (21.72)
21-19
21 Hopfield Network
pq pq pq 0
T
Wa = a = = 0 = 0a. (21.75)
q=1 q=1
So X defines an eigenspace for the repeated eigenvalue = 0 .
To summarize, the weight matrix has two eigenvalues, S and 0 . The
eigenspace for the eigenvalue S is the space spanned by the prototype vec-
tors. The eigenspace for the eigenvalue 0 is the orthogonal complement of
the space spanned by the prototype vectors.
Since (from Eq. (21.54)) the Hessian matrix for the high-gain Lyapunov
function V is
2V = W , (21.76)
21-20
Hopfield Design
W = 0 1 . (21.77)
1 0
Suppose that this had been designed using the Hebb rule with one proto-
type pattern (obviously not an interesting practical case):
p1 = 1 . (21.78)
1
Then
W = p1 p1 = 1 1 1 = 1 1 .
T
(21.79)
1 1 1
Notice that
W' = W I = 0 1 (21.80)
1 0
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
(21.81) 21
The Hessian matrix for V a is
21-21
21 Hopfield Network
2V a = W = 1 1 . (21.82)
1 1
1 = S = 2 , and 2 = 0 , (21.83)
z 1 = 1 and z 2 = 1 . (21.84)
1 1
X = a: a 1 = a 2 . (21.85)
a = 1 or a = 1 , (21.87)
1 1
21-22
Hopfield Design
1
0
-0.5
0.5
-1
-1.5
0
-2
1
-0.5 0.5
-0.5 1
0.5
0
-1 -1 -0.5
-1 -0.5 0 0.5 1 -1
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 func-
tion. If we multiply this new weight matrix times one of the prototype vec-
tors we find
W'p q = W QI p q = Sp q Qp q = S Q p q . (21.89)
W'a = W QI a = 0 Qa = Qa . (21.90)
21-23
21 Hopfield Network
fore, the eigenvalues of the Hessian matrix of the modified Lyapunov func-
tion, 2V' a = W' , are S Q and Q .
This implies that the energy surface will have negative curvature in X and
positive curvature in X , in contrast with the original Lyapunov function,
which had negative curvature in X and zero curvature in X .
A comparison of Figure 21.9 and Figure 21.10 demonstrates the effect on
the Lyapunov function of setting the diagonal elements of the weight ma-
trix to zero. In terms of system performance, the change has little effect. If
the initial condition of the Hopfield network falls anywhere off of the line
a 1 = a 2 , then, in either case, the output of the network will converge to
one of the corners of the hypercube a: 1 a i 1 , which consists of the
T T
two points a = 1 1 and a = 1 1 .
If the initial condition falls exactly on the line a 1 = a 2 , and the weight
matrix W is used, then the network output will remain constant. If the ini-
tial condition falls exactly on the line a 1 = a 2 , and the weight matrix W'
is used, then the network output will converge to the saddle point at the
origin (as in Figure 21.6). Neither of these results is desirable, since the
network output does not converge to a minimum of the Lyapunov function.
Of course, the only case in which the network converges to a saddle point
is when the initial condition falls exactly on the line a 1 = a 2 , which would
be highly unlikely in practice.
21-24
Summary of Results
Summary of Results
Hopfield Model
dn(t)
------------ = n(t) + Wa(t) + b
dt
a(t) = f n(t)
p
W - .
Sx1 + n n a
SxS 1/ f
Sx1 Sx1
1 b
Sx1
S S
f -1
Lyapunov Function
ai
S
1 T 1
f u du b a
T
V a = --- a Wa +
2
i=1 0
S
da 2
V a = f a i i
d d 1
dt d ai dt
i=1
d 1 d
If f a i 0 , then V a 0 .
d ai dt
Invariant Sets 21
The Invariant Set Consists of the Equilibrium Points.
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
2V a = W
Content-Addressable Memory
Q
pq pq
T
W = and b = 0
q=1
2 = 0 , with eigenspace X .
T
X is defined such that for any vector a X , p q a = 0, q = 1 2 Q
21-26
Solved Problems
Solved Problems
P21.1 Assume the binary prototype vectors
1 1
p1 = 1 p2 = 1 .
1 1
1 1
1 1 1 1 1 1 1 1
W = p1 p1 + p2 p2 = 1 1 1 1 + 1 1 1 1 ,
T T
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
which simplifies to
2 0 0 2
W = 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 0 0 2
2V a = 0 2 2 0 .
0 2 2 0
2 0 0 2
21-27
21 Hopfield Network
T
The prototype patterns are orthogonal ( p 1 p 2 = 0 ). Thus, the eigenval-
ues are 1 = S = 4 and 2 = 0 . The eigenspace for 1 = 4 is
X = span p 1 , p 2 .
1 1
1 , 1
X = span ,
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 pro-
totype patterns will also be equilibrium points. There may be other equilib-
rium 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 .
W = 1 1 and b = 1 .
1 1 1
1 T T
V a = --- a Wa b a .
2
2V a = W = 1 1 .
1 1
21-28
Solved Problems
2V a I = 1 1 2
= 2 + 1 1 = 2 .
1 1
2V a 1 I z 1 = 0 ,
and therefore
1 1 z = 0 or z = 1 .
1 1
11 1
Similarly, for 2 = 2 ,
2V a 2 I z 2 = 0
and therefore
1 1 z = 0 or z = 1 .
2 2
1 1 1
So the term
1 T
--- a Wa
2
has zero curvature in the direction z 1 and positive curvature in the direc-
tion z 2 .
Now we have to account for the linear term. First plot the contour without
the linear term, as in Figure P21.1.
The linear term will cause a negative slope in the direction of
b = 1 .
1
T
Therefore everything will curve down toward 1 1 , as is shown in Fig-
ure P21.2.
21-29
21 Hopfield Network
1
2
1.5
0.5
0.5
0
0
1
-0.5 0.5
-0.5 1
0.5
0
-1 -1 -0.5
-1 -0.5 0 0.5 1 -1
0.5
1
0
0
-1
-2
-0.5 1
0.5 1
0 0.5
0
-0.5
-0.5
-1 -1 -1
-1 -0.5 0 0.5 1
p1 = 1 p2 = 1
1 1
21-30
Solved Problems
iii. What are the stable points for this Hopfield network (as-
sume large gain)? What are the basins of attraction?
iv. How well does this network perform the pattern recognition
problem?
i. We will use the Hebb rule to find the weight matrix.
W = p1 p1 + p2 p2 = 1 1 + 1 1 = 2 0
T T
1 1 1 1 0 2
b = 0
0
ii. The Hessian matrix of the high-gain Lyapunov function is the negative
of the weight matrix.
2V a = W = 2 0
0 2
1 = 2 = S = 2
z 1 = 1 and z 2 = 0 ,
0 1
2
or any linear combination. (The entire is the eigenspace for the eigen-
value = 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-31
21 Hopfield Network
0.5
-0.5
-1
0
-1.5
-2
-0.5 1
0.5 1
0 0.5
0
-0.5
-0.5
-1 -1
-1 -0.5 0 0.5 1 -1
0.5
-0.25
-0.5
0
-0.75
-1
-0.5 1
0.5 1
0 0.5
0
-0.5
-0.5
-1 -1
-1 -0.5 0 0.5 1 -1
21-32
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 neu-
rons, we cant expect to successfully store many patterns. Try Exercise
E21.2 for a better network.
1 2 2
V a = --- 7 a 1 + 12a 1 a 2 2 a 2 .
2
1 1 T
V a = --- 7 a 1 + 12a 1 a 2 2 a 2 = --- a 7 6 a .
2 2
2 2 6 2
W = 7 6 .
6 2
ii. Since V a is a quadratic function, we can use Eq. (8.38) to find the gra-
dient.
V a = 7 6 a
6 2
2V a = 7 6 = 7 6 .
6 2 6 2
21-33
21 Hopfield Network
2V a I = 7 6 2
= + 5 50 = + 10 5 .
6 2
2V a 1 I z 1 = 0 ,
and therefore
3 6 z = 0 or z = 2 .
1 1
6 12 1
Similarly, for 2 = 5 ,
2V a 2 I z 2 = 0
and therefore
12 6 z = 0 or z = 1 .
2 2
6 3 2
Note that this is a saddle point case, since 1 0 2 . There will be nega-
tive curvature along z 1 and positive curvature along z 2 . The contour plot
of the high-gain Lyapunov function is shown in Figure P21.5.
1
0.5
0
-4
-8
-0.5 1
0.5 1
0 0.5
0
-0.5
-0.5
-1 -1
-1 -0.5 0 0.5 1 -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 as-
sumes infinite gain. As a comparison, Figure P21.6 illustrates the
Lyapunov function, and the Hopfield trajectory, for a gain of 0.5 .
1
0.5 6
0 0
-2
-4
-6
-0.5 1
0.5 1
0 0.5
0
-0.5
-0.5
-1 -1
-1 -0.5 0 0.5 1 -1
P21.5 The Hopfield network has been used for applications other than
content-addressable memory. One of these other applications is
analog-to-digital (A/D) conversion [HoTa86]. The function of the
A/D converter is to take an analog signal y , and convert it into a se-
ries of bits (zeros and ones). For example, a two-bit A/D converter
would try to approximate the signal y as follows:
2
i 1
y ai 2 = a1 + a2 2 ,
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 Hopfield Network
2 2 2
2i 1 2 2i 1 2i 1
2 a i a i 1 = ai 2 ai 2
i=1 i=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 high-
gain Lyapunov function:
1 T T
V a = --- a Wa b a .
2
1
0 2 and b = y ---
W = 2 .
2 0
2y 2
1
f n = ----------------------
n
-.
1 e
21-36
Epilogue
Epilogue
In this chapter we have introduced the Hopfield model, one of the most in-
fluential 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 optimiza-
tion tasks, such as the traveling salesman problem [HoTa85].
One of Hopfields key contributions was the application of Lyapunov stabil-
ity theory to the analysis of his recurrent networks. He also showed that,
for high-gain amplifiers, the Lyapunov function for his network was a qua-
dratic function, which was minimized by the network. This led to several
design procedures. The idea behind the development of the design tech-
niques 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 inter-
active memory, Mathematical Biosciences, vol. 14, pp.
197220, 1972.
Anderson proposed a linear associator model for associa-
tive memory. The model was trained, using a generaliza-
tion 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] J. A. Anderson, J. W. Silverstein, S. A. Ritz and R. S. Jones,
Distinctive features, categorical perception, and probabil-
ity learning: Some applications of a neural model, Psycho-
logical Review, vol. 84, pp. 413451, 1977.
This article describes the brain-state-in-a-box neural net-
work model. It combines the linear associator network with
recurrent connections to form a more powerful autoassocia-
tive system. It uses a nonlinear transfer function to contain
the network output within a hypercube.
[CoGr83] M. A. Cohen and S. Grossberg, Absolute stability of global
pattern formation and parallel memory storage by compet-
itive neural networks, IEEE Transactions on Systems,
Man and Cybernetics, vol. 13, no. 5, pp. 815826, 1983.
Cohen and Grossberg apply LaSalles Invariance Theorem
to the analysis of the stability of competitive neural net-
works. The network description is very general, and the au-
thors show how their analysis can be applied to many
different types of recurrent neural networks.
[Gros67] S. Grossberg, Nonlinear difference-differential equations
in prediction and learning theory, Proceedings of the Na-
tional Academy of Sciences, vol. 58, pp. 13291334, 1967.
This early work of Grossbergs discusses the storage of in-
formation in dynamically stable configurations.
21-38
Further Reading
21
21-39
21 Hopfield Network
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 var-
ied from = 0.1 to = 10 .
2+2
ans = iii. Sketch the contour plot for several different values of gain in this in-
4 terval. 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 p2 = 1 .
1 1
If we use another design rule [LiMi89], we find the following weight matrix
and bias
W = 1 0 b = 0 .
0 10 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 = iii. Write a MATLAB M-file to simulate the Hopfield network. Use the
4 ode45 routine. Plot the responses of this network for several initial
conditions.
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 Hopfield Network
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
a0 = 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
W = 1 0 and b = 1 .
0 1 1
2+2
ans = E21.11 In Exercise E7.11 we asked the question: How many prototype patterns
4 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 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 p4 p5 p6 p7 p8 p9 p10
21-44
Objectives
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 va-
riety 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 post-
training analysis.
22
22-1
22 Practical Training Issues
Initialize Weights
Analyze Network &
Performance 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 net-
work, 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 accu-
rately throughout the range of the data provided (generalizes well). How-
ever, 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-3
22 Practical Training Issues
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 Net-
work Architecture section on page 22-8. Of course, we generally dont know
how complex the underlying function is before we begin training the net-
work. 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 de-
cide 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, non-
linear transformations, feature extraction, coding of discrete inputs/tar-
gets, 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 gradi-
ent 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 becom-
ing saturated. It is standard practice to normalize the inputs before apply-
ing 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 us-
ing 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 nor-
malizes the data so that they fall into a standard range typically -1 to 1.
This can be done with
n min max min
p = 2p p ./ p p 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 Practical Training Issues
n
represents an element-by-element division of two vectors, and p is the re-
sulting 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 mean std
p = p p ./p , (22.2)
mean 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, non-
Nonlinear Transformation linear transformations are sometimes also performed as part of the pre-
processing stage. Unlike normalization, which is a standard process that
can be applied to any data set, these nonlinear transformations are case-
specific. For example, many economic variables show a logarithmic depen-
dence [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 forc-
es 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 net-
work. 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 Another data preprocessing step is called feature extraction. This generally
applies to situations in which the dimension of the raw input vectors is very
large and the components of the input vector are redundant. The idea of
feature extraction is to reduce the dimension of the input space by calculat-
ing a small set of features from each input vector, and using the features
as the input to the neural network. For example, neural networks can be
used to analyze EKG (electrocardiogram) signals to identify heart prob-
lems [HeOh97]. The EKG might involve 12 or 15 signals (leads) measured
over several minutes at a high sampling rate. This is too much data to ap-
ply directly to the neural network. Instead, we would extract certain fea-
tures from the EKG signal, such as average time intervals between certain
waveforms, average amplitudes of certain waves, etc. (See Chapter 25.)
There are also certain general-purpose feature extraction methods. One of
Principal Components these is the method of principal component analysis (PCA) [Joll02]. This
method transforms the original input vectors so that the components of the
22-6
Pre-Training Steps
22
22-7
22 Practical Training Issues
The outputs of the softmax transfer function can be interpreted as the prob-
abilities 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 ap-
plication of the softmax transfer function.
Missing Data Another practical issue to consider is missing data. It is often the case, es-
pecially 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 as-
signed 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 addi-
tional flag element would be added to the input vector for every input vari-
able 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 val-
ues are not included. All known target values will contribute to the perfor-
mance index, but missing target values will not.
22-8
Pre-Training Steps
22-9
22 Practical Training Issues
p1(t) 1 2
T a (t) a (t)
1
D IW 1,1
n (t) LW 2,1
2
n (t) S2x1
L S1x1
1
S x (R d) 1
S2xS1
2
S x1
1 b
1 1
S x1 1 b 2
1 1
S2
1
R S x1 S S2x1
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 net-
work, the NARX network can be trained with static backpropagation. The
two tapped-delay-lines can be replaced with extended vectors of delayed in-
puts and targets. We can use targets, instead of feeding back the network
outputs (which would require dynamic backpropagation for training), be-
cause the output of the network should match the targets when training is
complete.This is discussed in more detail in Chapter 27.
1 1
S2
2
R S1x1 S S x1
T
1,3
D LW
L
22-11
22 Practical Training Issues
22-12
Training the Network
Input Selection venting overfitting during training. The input selection process for nonlin-
ear 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 sensitiv-
ity 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 net-
works, 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 normal-
ized 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 sat-
uration 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 func-
tion falls randomly in the input space. The details of the method are as fol-
lows (assuming the inputs to the network have been normalized to values
between -1 and 1).
1 1
Set row i of W , iw , to have a random direction and a magnitude of
1 1 1R
iw = 0.7 S .
22-13
22 Practical Training Issues
1 1
Set b i to a uniform random value between iw 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 vec-
tors 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 neigh-
borhood size is set large enough so that all neurons will have the opportu-
nity to learn during the initial stages of training. This will move all weight
vectors into the appropriate region of the input space. Training can con-
verge faster, however, if rows of the weight matrix are initially placed in
the active input region.
22-14
Training the Network
Stopping Criteria
For most applications of neural networks, the training error never converg-
es identically to zero. The error can reach zero for the perceptron network,
assuming a linearly separable problem, as we showed in Chapter 4. How-
ever, 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. How-
ever, 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 per-
formance index, this criterion will stop the algorithm when it gets close to
the minimum. Unfortunately, as we have seen in Chapter 12, the perfor-
mance 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 be-
fore 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 over-
fitting, then we will stop the training when the performance on the valida-
tion 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, sev-
eral training runs should be made for each potential network to ensure that
a global minimum has been reached.
22-15
22 Practical Training Issues
3
10
2
10
0
10
1
10
2
10
3
10
0 1 2 3
10 10 10 10
Epochs
or
22-16
Training the Network
M
Q S
1
M i q
2
F x = ----------
- t a i q . (22.5)
QS q = 1 i = 1
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 in-
dex. 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 er-
ror. 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 perfor-
mance 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
M
Q S
1
M i q
K
F x = ----------
- t a i q , (22.6)
QS q = 1 i = 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-17
22 Practical Training Issues
is generally used in the last layer of the neural network, if the cross-entro-
py 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 per-
formance index, you only need to change the initialization of the sensitivi-
ties 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 tech-
niques 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.8)
22-18
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---------------------------------------------
m
=1
-, (22.9)
Q
2
tq t
q=1
c = a m
t, (22.10)
where
Q Q
1
a = ----
Q
Q
1
a q , t = ---
- tq . (22.11)
q=1 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 ex-
Outliers ample, there are two points around t = 27 and a = 17 that seem to be out-
liers. 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 = ---------------------------------------------- , (22.12)
Q 1 s t s a
where
Q Q
st = 1
-------------
Q1
t q t and s a = 1
-------------
Q1
aq a . (22.13)
q=1 q=1
22-19
22 Practical Training Issues
50
40
30
a
20
10
0
0 5 10 15 20 25 30 35 40 45 50
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 net-
work. 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 out-
liers is a histogram of the errors, as shown in Figure 22.7. The y-axis rep-
resents 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 6 4 2 0 2 4 6 8 10 12
e = ta
Pattern Recognition
For pattern recognition problems, the regression analysis is not as useful
as it is for fitting problems, since the target values are discrete. However,
Confusion Matrix there is an analogous tool - the confusion (or misclassification) matrix. The
confusion matrix is a table whose columns represent the target class and
whose rows represent the output class. For example, Figure 22.8 shows a
sample confusion matrix in which there were 214 data points. There were
41 input vectors that belonged to Class 1 and were correctly classified as
Class 1. There were 162 input vectors that belonged to Class 2 and were
correctly classified as Class 2. The correctly classified inputs show in the
diagonal cells of the confusion matrix. The off-diagonal cells show misclas-
sified inputs. The lower left cell shows that four inputs from Class 1 were
misclassified by the network as Class 2. If Class 1 is considered a positive
False Negative outcome, then the lower left cell represents false negatives, which are also
22-21
22 Practical Training Issues
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 false positive or a Type I error.
Confusion Matrix
47 1 97.9%
1
22.0% 0.5% 2.1%
Output Class
4 162 97.6%
2
1.9% 75.7% 2.4%
1 2
Target Class
22-22
Post-Training Analysis
0.9
0.8
0.7
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
False Positive Rate
Clustering
The SOM is the most commonly used network for clustering. There are sev-
Quantization Error eral measures of SOM performance. One is quantization error. This is the
average distance between each input vector and the closest prototype vec-
tor. 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.
Topographic Error Another measure of SOM performance is topographic error. This is the pro-
portion 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 well-
trained 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.
Distortion Measure The performance of the SOM can also be assessed by the distortion mea-
sure:
Q S
h ic
2
Ed = q iw pq , (22.14)
q = 1i = 1
22
22-23
22 Practical Training Issues
2
iw jw
h ij = exp --------------------------
- , (22.16)
2
2d
Prediction
As we discussed earlier, one application of neural networks is the predic-
tion 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 predic-
tion. 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.
In order to test the correlation of the prediction errors in time, we can use
Autocorrelation Function 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 ex-
pect 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 ----------------
---------------- -. (22.18)
Q Q
22-24
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 suc-
cessfully 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 0 20 40
0.03
0.02
0.01
40 20 0 20 40
To test the correlation between the prediction errors and the input se-
Cross-correlation Function quence, we can use the sample cross-correlation function:
22-25
22 Practical Training Issues
Q
1
R pe = ------------
Q p t e t + . (22.19)
t=1
If there is no correlation between the prediction errors and the input se-
quence, then we would expect R pe to be close to zero for all . To deter-
mine 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 ---------------------------------------
--------------------------------------- -. (22.20)
Q Q
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 net-
work that has not been adequately trained. We can see that the cross-cor-
relation 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 success-
fully trained. R pe falls within the bounds for all .
0.2
0.1
0.1
40 20 0 20 40
When using a NARX network, correlation between the prediction error and
the input can suggest that the lengths of the tapped delay lines in the input
and feedback paths should be increased.
22-26
Post-Training Analysis
0.02
0.01
0.01
0.02
40 20 0 20 40
22-27
22 Practical Training Issues
If the validation, training and test errors are all similar in size, but the er-
rors 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 be-
coming 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 indi-
cates 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.
One method for detecting extrapolation is to train a companion competitive
network to cluster the input vectors in the multilayer network training set.
Then, when an input is applied to the multilayer network, the same input
is applied to the companion competitive network. When the distance of the
input vector to the nearest prototype vector of the competitive network is
larger than the distance from the prototype to the most distant member of
its cluster of inputs in the training set, we can suspect extrapolation. This
Novelty Detection technique is referred to as 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 deriva-
tives, 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 vari-
ation of the backpropagation algorithm (see Eq. (11.44) to Eq. (11.47)). Re-
call from Eq. (11.32) that
m F
s i --------m- , (22.21)
n i
We know that
R
w i j pj + b i ,
1 1 1
ni = (22.23)
j=1
F 1 T 1
------ = W s . (22.25)
p
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 irrele-
vant inputs, we retrain the network and compare the performance with the
original network. If the performance is similar, then we accept the simpli-
fied network.
22-29
22 Practical Training Issues
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 ar-
chitecture 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 va-
riety 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, Ox-
ford University Press,1995.
This well-written and well-organized textbook presents
neural networks from a statistical perspective.
[BoJe94] G.E.P. Box, G.M. Jenkins, and G.C. Reinsel, Time Series
Analysis: Forecasting and Control, 4th Edition, John Wiley
& Sons, 2008.
This is a classic text on time series analysis. It focuses on
practical aspects, rather than theoretical derivations.
[HaBo07] L. Hamm, B. W. Brorsen and M. T. Hagan, Comparison of
Stochastic Global Optimization Methods to Estimate Neu-
ral Network Weights, Neural Processing Letters, Vol. 26,
No. 3, December 2007.
This paper demonstrates that using multiple restarts of a
local optimization procedure, like steepest descent or con-
jugate gradient, produces results that are comparable to
global optimization methods, but with less computation.
[HeOh97] B. Hedn, H. hlin, R. Rittner, L. Edenbrandt, Acute My-
ocardial Infarction Detected in the 12-Lead ECG by Artifi-
cial Neural Networks, Circulation, vol. 96, pp. 17981802,
1997.
Describes the use of neural networks in detecting myocar-
dial infarctions, using the electrocardiogram.
[Joll02] I.T. Jolliffe, Principal Component Analysis, Springer Series
in Statistics, 2nd ed., Springer, NY, 2002.
The most popular text on principal component analysis.
[LeCu98] Y. LeCun, L. Bottou, G. B. Orr, K.-R. Mueller, Efficient
BackProp, Lecture Notes in Comp. Sci., vol. 1524, 1998.
This paper presents practical tips that improve the train-
ing of multilayer networks.
[Moll93] M. Moller, A scaled conjugate gradient algorithm for fast
supervised learning, Neural Networks, vol. 6, pp. 525-533,
1993.
The scaled conjugate gradient algorithm presented in this
paper converges quickly, and with a minimum amount of
memory requirements.
22
22-31
22 Practical Training Issues
22-32
Objectives
23 Case Study 1:
Function Approximation
Objectives 23-1
Theory and Examples 23-2
Description of the Smart Sensor System 23-2
Data Collection and Preprocessing 23-3
Selecting the Architecture 23-4
Training the Network 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 net-
works. 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 ap-
proximation (aka, nonlinear regression), density function estimation, pat-
tern 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 (ex-
planatory variables). The neural network learns to create a mapping be-
tween 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 pa-
rameter. 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 Case Study 1: Function Approximation
y
v1
Shadow
v2
23-2
Data Collection and Preprocessing
v2
v1
5 v2
v1
1
0
0 1 2 3
y
23-3
23 Case Study 1: Function Approximation
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 net-
work has been completely trained, we will use the testing data as an indi-
cator of future network performance.
The input vector for network training will consist of the solar cell voltages
v1
p = , (23.1)
v2
t = y. (23.2)
The data were scaled using Eq. (22.1), so that both the inputs and the tar-
gets were in the range [-1,1]. The resulting scaled data is shown in Figure
23.4
S
v2
0.5
S
0.5 v1
1 0.5 0 0.5 1
S
y
23-4
Training the Network
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 de-
pend 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.
p1 a1 a2
2x1
W1 1
S x1
W2 1x1
1
S x2
n1 1xS
1 n2
S1x1 1x1
1 b 1
1 b2
2 S1x1 S1 1x1 1
1 1 1 2 2 1 2
a = tansig(W p + b ) a = purelin(W a + b )
23-5
23 Case Study 1: Function Approximation
2
10
1
10
0
10
SSE
1
10
2
10
3
10 0 1 2
10 10 10
Iterations
1
Figure 23.6 Sum Squared Error vs. Iteration Number ( S = 10 )
Training has converged after 100 iterations, but we want to ensure that we
have not fallen into a local minimum. For this reason, we want to retrain
the network several times, using different initial weights and biases. (We
use the Nguyen-Widrow initialization method described in Chapter 22.)
Table 23.1. shows the final validation SSE for each of five different training
runs. We can see that all of the errors are similar, although the errors are
slightly smaller for runs 2, 4 and 5. Any of the weights from these five cases
would produce a satisfactory network. We will discuss this in more detail
in the next section.
Table 23.1. Final Training SSE for Five Different Initial Conditions
23-6
Validation
20
15
10
0
0 20 40 60 80 100
Iterations
1
Figure 23.7 Effective Number of Parameters ( S = 10 )
1 1 1 1 1
S = 3 S = 5 S = 8 ( S = 10 ) S = 20
Table 23.2. Final Training SSE for Five Different Hidden Layer Sizes
Validation
An important tool for network validation is a scatter plot of network out-
puts versus targets, as shown in Figure 23.8 (in normalized units). We ex-
23-7
23 Case Study 1: Function Approximation
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 fig-
ure 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 1
Training Testing
0.5 0.5
a 0 a 0
0.5 0.5
1 1
1 0.5 0 0.5 1 1 0.5 0 0.5 1
t t
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 histo-
gram, 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
n t t min
a = a + 1 .* ----------------------------- + t (23.3)
2
n
where a is the original network output, which was trained to match the
normalized target, and .* represents an element-by-element multiplica-
tion of two vectors. After the postprocessing operation of Eq. (23.3), the re-
sulting un-normalized output is subtracted from the raw targets, to
produce an error in inches. Figure 23.9 shows the distribution of these er-
rors 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
15
10
0
0.02 0.01 0 0.01 0.02
2.5
2
y 1.5
0.5
0
0
2
6
v2 4
4
2 v1
0
23-9
23 Case Study 1: Function Approximation
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 con-
cept 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 re-
gions 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 poten-
tial 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 in-
terest.
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 algo-
rithm 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 lay-
er.
23-11
23 Case Study 1: Function Approximation
Further Reading
[FoGi07] L. Fortuna, P. Giannone, S. Graziani, M. G. Xibilia, Virtu-
al Instruments Based on Stacked Neural Networks to Im-
prove 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 sen-
sors in a refinery. Measurements of reactor temperatures
and pressures are used to predict octane number in a gaso-
line product.
23-12
Objectives
24 Case Study 2:
Probability Estimation 24
Objectives 24-1
Theory and Examples 24-2
Description of the CVD Process 24-2
Data Collection and Preprocessing 24-3
Selecting the Architecture 24-5
Training the Network 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 es-
timate a probability function.
Probability estimation is a special case of function approximation. In func-
tion approximation we want the neural network to map between a set of in-
put variables and a set of response variables. However, in the case of
probability estimation the response variables correspond to a set of proba-
bilities. Since probabilities have certain special properties they must al-
ways 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 car-
bon atoms) is projected toward a diamond surface. We want to determine
the probabilities for various reactions based on characteristics of the pro-
jected dimer. The input variables consist of such properties as translational
energy and incidence angle, and the response variables consist of the prob-
abilities of the potential reactions, such as chemisorption and scattering.
24-1
24 Case Study 2: Probability Estimation
24-2
Data Collection and Preprocessing
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.
z
y
b
f
24-3
24 Case Study 2: Probability Estimation
p = b . (24.1)
v trans
v rot
MC N
P X p = -----X- , (24.2)
NT
24-4
Selecting the Architecture
MC
PC p
t = P MC p , (24.3)
S
MC
PD p
MC
or we can use three different networks, each with a different P X p as a
target. We have tried both possibilities, and the results are similar.
In this case, there is an advantage to using the single network, with three
elements in the output vector. The three targets represent probabilities.
Therefore, they are always in the range 0 to 1, and they always sum to 1.
24-5
24 Case Study 2: Probability Estimation
This is an ideal situation for using the softmax transfer function of Eq.
(22.3), which is repeated here:
S
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 trans-
fer functions, the net input n i affected only the neuron output a i .) This
does not cause any substantial difficulties in network training. The back-
propagation 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
S
a 1m a im a 1m a 1m a 2m a 1m a Smm
i = 1
m
S
F m n m = a 2m a 1m a 2 a im a 2m
m a 2m a Smm
(24.5)
i = 1
m
S
a Smm a 1m a Smm a 2m a Smm a im a Smm
i = 1
The complete network architecture is shown in Figure 24.2. The input vec-
tor 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 func-
tion 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 overfit-
ting. We will discuss this selection in the next section.
24-6
Training the Network
1 1 2
p 1
a 2
a
5x1
W S1x1
W 3x1
1
S x5
n1 3xS1
n2
S1x1 3x1
1 b 1
1 b2
5 S1x1 S1 3x1 3
1 1 1 2 2 1 2
a = tansig(W p + b ) a = softmax(W a + b )
1
10
Training
Validation
MSE
2
10
3
10 0 1 2
10 10 10
Iterations
1
Figure 24.3 Training and Validation Mean Square Error ( S = 10 )
24-7
24 Case Study 2: Probability Estimation
PC p 0.0496 0.0439
PS p 0.0634 0.0659
PD p 0.0586 0.0604
1
Table 24.1. Comparison of Training and Validation RMSE for S = 10
PC p 0.0634 0.0627
PS p 0.0669 0.0704
PD p 0.0617 0.0618
1
Table 24.2. Comparison of Training and Validation RMSE for S = 2
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 neu-
rons are sufficient for this problem. We will investigate this further in the
next section.
24-8
Validation
PC p 0.0432 0.0444
PS p 0.0603 0.0643
PD p 0.0569 0.0595
1
Table 24.3. Comparison of Training and Validation RMSE for S = 20
There is one further step that we want to make as part of the training pro-
cess. We want to ensure that we have not fallen into a local minimum. For
this reason, we want to retrain the network several times, using different
initial weights and biases. (We use the Nguyen-Widrow initialization
method described in Chapter 22.) Table 24.4. shows the final validation
MSE for each of five different training runs. We can see that all of the er-
rors are similar, so we have reached a global minimum at each run. If one
error was significantly lower than the others, then we would use the
weights that obtained the lowest error.
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 out-
puts 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 probabil-
MC
ities, P X p , but the Monte Carlo estimates P X p . There is noise in the
targets.
24-9
24 Case Study 2: Probability Estimation
1 1 1
0 0 0
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
MC MC MC
PC PS PD
MC
The relationship between P X and P X is such that ~95% of the time we ex-
pect to have
MC
P X 2 P X P X + 2 , (24.6)
where
PX 1 PX
= ---------------------------- . (24.7)
NT
0.8
0.6
MC
PX
0.4
0.2
0
0 0.2 0.4 0.6 0.8 1
PX
MC
Figure 24.5 Expected Statistical Spread of P X for N T = 50
24-10
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 net-
work is fitting the true probabilities P X p and not the statistical fluctua-
MC
tions in P X p .
1 1 1
0 0 0
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
MC MC MC
PC PS PD
After the neural network has been trained, it becomes a simple matter to
investigate the effect of the input parameters on the reaction probabilities.
In Figure 24.7, we see the effect of the impact parameter b on the reaction
probabilities, as determined by the neural network. As the impact param-
eter is increased, the probability of chemisorption decreases, while the
probabilities of scattering and desorption increase. (For this study, we have
set to 5.4 radians, to 0.3 radians, v rot to 0.004 radians per femtosecond,
and v trans to 0.004 angstroms per femtosecond.)
With standard methods, a study such as that shown in Figure 24.7 would
take thousands of simulations. The trained neural network has fully cap-
tured the relationships between the parameters in p and the reaction prob-
abilities. Therefore, we can perform arbitrary studies by simply computing
the network responses at a varying set of input points. Note that the net-
work interpolated smoothly through a noisy set of data points to capture
the true underlying function. By using the early stopping technique, we
prevented the network from overfitting the noise in the data.
24-11
24 Case Study 2: Probability Estimation
NN
PC 0.5
0
0 0.5 1 1.5 2 2.5 3 3.5
NN
PS 0.5
0
0 0.5 1 1.5 2 2.5 3 3.5
NN
PD 0.5
0
0 0.5 1 1.5 2 2.5 3 3.5
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 es-
timation on a chemical vapor deposition problem. Monte Carlo simulations
were used to provide estimates of the reaction probabilities. These esti-
24
mates 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 Case Study 2: Probability Estimation
Further Reading
[AgSa05] P.M. Agrawal, A.N.A. Samadh, L.M. Raff, M. Hagan, S. T.
Bukkapatnam, and R. Komanduri, Prediction of molecu-
lar-dynamics simulation results using feedforward neural
networks: Reaction of a C2 dimer with an activated dia-
mond (100) surface, The Journal of Chemical Physics 123,
224711, 2005.
This paper describes the details of training a neural net-
work to predict the reaction probabilities for chemical va-
por deposition of diamond.
[Mill93] M.F. Miller, A scaled conjugate gradient algorithm for fast
supervised learning, Neural Networks, vol. 6, pp. 525-533,
1993.
The scaled conjugate gradient algorithm is a fast batch
training algorithm for neural networks that requires a
minimum of memory and computation at each iteration.
[RaMa05] L.M. Raff, M. Malshe, M. Hagan, D.I. Doughan, M.G. Rock-
ley, 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
Theory and Examples 25-2
Description of Myocardial Infarction Recognition 25-2
Data Collection and Preprocessing 25-3
Selecting the Architecture 25-6
Training the Network 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 electro-
cardiogram. We will show each of the steps in the pattern recognition pro-
cess: data collection, feature extraction, architecture selection, network
training and network validation.
25-1
25 Case Study 3: Pattern Recognition
25-2
Data Collection and Preprocessing
0.6
0.4
0.2
0.2
0 0.5 1 1.5 2
Time (sec)
25-3
25 Case Study 3: Pattern Recognition
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.
R
PR ST
Segment Segment
P T
Q S
PR
Interval QRS
Duration
QT Interval
25-4
Data Collection and Preprocessing
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 Case Study 3: Pattern Recognition
1 2
p 1
a 2
a
47 x 1
W 1
S x1
W 1x1
1
S x 47
n1 1xS1
n2
S1x1 1x1
1 b 1
1 b2
47 S1x1 S1 1x1 1
1 1 1 2 2 1 2
a = tansig(W p + b ) a = tansig(W a + b )
25-6
Training the Network
1
10
0
10
Validation
MSE
1
10
Training
2
10
0 10 20 30 40 50
Iterations
1
Figure 25.4 Mean Squared Error vs. Iteration Number ( S = 10 )
Validation
As we discussed in previous chapters, an important tool for network vali-
dation in function approximation problems is a scatter plot of network out-
puts versus targets. For pattern recognition problems, the network outputs
and targets are discrete variables, so a scatter plot is not particularly use-
ful. Instead of the scatter plot, we use the confusion matrix, which was dis-
cussed 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 Case Study 3: Pattern Recognition
Confusion Matrix
13 5 72.2%
1
15.3% 5.9% 27.8%
Output Class
1 66 98.5%
2
1.2% 77.6% 1.5%
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 Re-
ceive Operating Characteristic (ROC) curve, described in Chapter 22. Fig-
ure 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.
0.9
0.8
0.7
True Positive Rate
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
False Positive Rate
25-8
Validation
times. For each division of the data, a neural network was trained with dif-
ferent 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
2.51 49.83 95.2%
2
3.9% 76.5% 4.8%
1 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 net-
works and data divisions. There were approximately 12 healthy patients
(on average) in each test set. Of these, more than 9 were correctly diag-
nosed. There were approximately 54 sick patients in each test set, and ap-
proximately 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 de-
viation of the percent error is 3.5.
25-9
25 Case Study 3: Pattern Recognition
160
120
80
40
0
0 5 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 di-
agnoses.
Most pattern recognition tasks involve a feature extraction step, in which
the original data set is reduced in dimension. The features that were ex-
tracted from the EKG data consisted of characteristics of the prototype
25
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 ini-
tial weights. The performances of all of the networks were analyzed to de-
termine 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 recog-
nition.
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 Case Study 3: Pattern Recognition
Further Reading
[Dubi00] D. Dubin, Rapid Interpretation of EKG's, Sixth Edition,
Tampa, FL: COVER, 2000.
This book describes the EKG in very clear terms, and leads
you through the interpretation in a step-by-step way.
[MoMa01] G.B. Moody, R.G. Mark, and A.L. Goldberger, PhysioNet:
a Web-based resource for the study of physiologic signals,
IEEE Transactions on Engineering in Medicine and Biolo-
gy, vol. 20, no. 3, pp: 70-75, 2001.
This paper describes the PhysioNet data base that contains
a large variety of recorded physiologic signals. The data
base can be found at http://www.physionet.org/.
[Raff06] The features in the data set described in this chapter were
designed and extracted by Dr. Lionel Raff, Regents Profes-
sor of Chemistry at Oklahoma State University.
[TeSi00] J. B. Tenenbaum, V. de Silva, J. C. Langford, A Global
Geometric Framework for Nonlinear Dimensionality Re-
duction, Science, vol. 290, pp. 2319-2323, 2000.
There are several different approaches to manifold learn-
ing, in which data is mapped from a high-dimensional
space to a lower-dimensional manifold. This paper intro-
duces a method called Isomap.
25-12
Objectives
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 simi-
larity. 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 group-
ing 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 Case Study 4: Clustering
26-2
Description of the Forest Cover Problem
The forest cover types of interest in [BlDe99] are shown in Table 26.1. The
data set we will use for this case study contains information on cover type,
but we will not use this as part of the training process. We will use it to test
the clustering ability of the SOM.
Label Name
0 Krummholz
1 Spruce/Fir
2 Lodgepole Pine
3 Ponderosa Pine
4 Cottonwood/Willow
5 Aspen
6 Douglas-fir
26-3
26 Case Study 4: Clustering
7
8000 1 1
4000 0 0
8
0 1 1
1 0 1 1 0 1 1 0 1
7 7
8
8000 1
6000 0.5
4000 0
9
2000 0.5
0 1
1 0 1 1 0 1
8
9
6000
4000
2000
0
1 0 1
26-4
Selecting the Architecture
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.
W
150 x 10
p n a
10 x 1
||dist||
150 x 1
C 150 x 1
10 150
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 deter-
mine 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 Case Study 4: Clustering
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 net-
work in a later section.
i N i d
h i i = (26.4)
0 i N i d
hi q i p q
iw k
q=1
-,
= ------------------------------------
Q
(26.5)
h i q i
q=1
26-6
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 re-
gion 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 al-
gorithm, 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 be-
tween each data vector and its winning neuron. If the average distance is
too large, then there are many input vectors that are not adequately repre-
sented 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 im-
portant 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 neigh-
boring neurons in the feature map. The u-matrix has a cell for each neuron
26-7
26 Case Study 4: Clustering
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 corre-
sponding 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
26-8
Validation
map have consistent colors. The left side has medium gray levels, corre-
sponding 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 1 1 1 1 6 6 6 3
2 0 1 0 1 5 6 6 6 3
2 0 1 1 0 1 5 6 6 4
0 0 1 1 0 5 5 3 3 4
2 2 0 1 0 2 5 3 3 4
2 0 0 0 0 5 5 3 3 4
2 2 0 0 0 0 5 5 3 4
2 2 1 0 1 0 5 5 3 4
2 2 1 0 0 0 5 5 3 4
2 2 1 0 0 0 5 5 4 4
2 2 0 0 0 0 2 5 4 4
2 2 0 0 0 1 5 6 4 4
2 2 2 0 1 0 1 5 6 4
1 2 2 1 0 2 2 5 6 4
2 2 2 2 0 0 1 5 5 5
26-9
26 Case Study 4: Clustering
1 2 3 4
0.4
0.5 0.2
0
0 0.4 0.6
0.4 0.5 0.6 0.8
5 6 7 8
0.5
0.4 0.8 0.8
0.45 0 0.6
0.4
0.5 0.5 0.4
9 10
0.4 0.5
0 0
0.5
0.4
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 abil-
ity 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
26-11
26 Case Study 4: Clustering
Further Reading
[BlDe99] J. A. Blackard and D. J. Dean, Comparative Accuracies of
Artificial Neural Networks and Discriminant Analysis in
Predicting Forest Cover Types from Cartographic Vari-
ables, Computers and Electronics in Agriculture, vol. 24,
pp. 131-151, 1999.
This study compared neural networks and discriminant
analysis for predicting forest cover types from cartographic
variables. The study evaluated four wilderness areas in the
Roosevelt National Forest, located in the Front Range of
northern Colorado.
[HeBa99] S. Hettich and S. D. Bay, The UCI KDD Archive [http://
kdd.ics.uci.edu], Irvine, CA: University of California, De-
partment of Information and Computer Science, 1999.
The UCI Knowledge Discovery in Databases Archive. This
is an online repository of large data sets which encompass-
es a wide variety of data types, analysis tasks, and applica-
tion areas. It is maintained by the University of California,
Irvine.
[Koho93] T. Kohonen, Things you haven't heard about the Self-Or-
ganizing 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] T. Kohonen, Self-Organizing Map, 2nd ed., Springer-Ver-
lag, Berlin, 1995.
This text describes the theory and practical operation of the
Self-Organizing Map in detail. It also has a chapter on the
Learning Vector Quantization algorithms.
26-12
Objectives
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 ana-
lyst might want to predict the future value of a stock, bond, or other finan-
cial 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 levita-
tion system.
27-1
27 Case Study 5: Prediction
y(t)
+
i(t)
-
27-2
Data Collection and Preprocessing
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 pre-
vious 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].
4
Current (A)
0 10 20 30 40
Position (m)
0
0 10 20 30 40
Time (Sec)
27-3
27 Case Study 5: Prediction
those pulses. Shorter width pulses explore transient operation of the sys-
tem.
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 rep-
resentative 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 vali-
dation 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 tar-
gets were in the range [-1,1]. The resulting scaled data is shown in Figure
27.3
0.5
Current
0.5
1
0 10 20 30 40
1
Position
0.5
0.5
1
0 10 20 30 40
Time (Sec)
27-4
Selecting the Architecture
y t = f y t 1 y t 2 y t n y u t 1 u t 2 u t n u , (27.2)
1 1 1 2
p (t) n (t) a (t) a (t)
T
D IW1,1 LW
2,1
2
L 1
1
S x1 1
n (t) 1x1
S x1 1xS
1x1 2
S x1
1 b1 S1x1 1 b2
1 S1x1 S1 1x1 1
T
1,3
D LW
L
27-5
27 Case Study 5: Prediction
T T
u(t) D u(t) D
L
Feed ^y(t) L
Feed ^y(t)
Forward Forward
T Network T Network
D y(t) D
L L
ut 1
p = ut 2 . (27.3)
yt 1
yt 2
t = yt . (27.4)
27-6
Training the Network
5
10
4
10
3
10
2
10
1
10
SSE
0
10
1
10
2
10
3
10
4
10 0 1 2 3
10 10 10 10
Iterations
1
Figure 27.6 Sum Squared Error vs. Iteration Number ( S = 10 )
In Figure 27.7, we can see the variation of the effective number of param-
eters during training. It eventually converges to 39. There are a total of
61 parameters in this 4-10-1 network, so we are effectively using less than
2/3 of the weights and biases. If the effective number of parameters was
close to the total number of parameters, then we would increase the num-
ber of hidden neurons and retrain the network. That is not the case here.
27-7
27 Case Study 5: Prediction
There is no need to decrease the number of neurons, since the network com-
putation 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 reg-
ularization technique. This method chooses the correct number of parame-
ters 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
Figure 27.7 Effective Number of Parameters ( S = 10 )
Validation
As we discussed in previous chapters, an important tool for network vali-
dation is a scatter plot of network outputs versus targets, as shown in Fig-
ure 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 test-
ing 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 er-
rors 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 1
Training Testing
0.5 0.5
a 0 a 0
0.5 0.5
1 1
1 0.5 0 0.5 1 1 0.5 0 0.5 1
t t
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 cor-
relation between the input and the prediction error. If there was correla-
tion, 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
27 Case Study 5: Prediction
Re 0
2 ------------- . (27.7)
Q
8
x 10
6
Re
2
50 0 50
1
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 er-
rors 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
Re 0 Ru 0
2 ------------------------------------ . (27.9)
Q
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
5
x 10
0.8
0.4
R ue 0
0.4
0.8
50 0 50
1
Figure 27.10 R ue ( n y = n u = 2 , S = 10 )
8
x 10
Re
50 0 50
1
Figure 27.11 R e ( n y = n u = 4 , S = 10 )
27-11
27 Case Study 5: Prediction
interval. There is no significant correlation between the errors and the in-
put.
6
x 10
R ue 0
50 0 50
1
Figure 27.12 R ue ( n y = n u = 4 , S = 10 )
27-12
Data Sets
4
x 10
0 10 20 30 40
Time (Sec)
1
27
0.5
Normalized Position
0.5
1
0 2 4 6
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
27 Case Study 5: Prediction
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] G. E. P. Box, G. M. Jenkins, and G. C. Reinsel, Time Series
Analysis: Forecasting and Control, Fourth Edition, Wiley,
2008.
A classic textbook on time series analysis and the develop-
ment of prediction models.
[HaDe02] M. Hagan, H. Demuth, O. De Jesus, An Introduction to the
Use of Neural Networks in Control Systems, International
Journal of Robust and Nonlinear Control, vol. 12, no. 11,
pp. 959-985, 2002.
This survey paper describes some practical aspects of using
neural networks for control systems. Three neural network
controllers are demonstrated: model predictive control,
NARMA-L2 control, and model reference control.
[NaMu97] Narendra, K.S.; Mukhopadhyay, S., Adaptive control us- 27
ing 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 control-
ler. Once the NARMA-L2 model is trained, it can be easily
inverted to form a controller for the identified system.
[NaPa90] K. S. Narendra and K. Parthasarathy, Identification and
control of dynamical systems using neural networks,
IEEE Transactions on Neural Networks, vol. 1, no. 1, pp. 4
27, 1990.
Classic early paper on the use of neural networks for the
identification and control of dynamical systems.
27-15
A Bibliography
A Bibliography
[AgSa05] P.M. Agrawal, A.N.A. Samadh, L.M. Raff, M. Hagan, S. T.
Bukkapatnam, and R. Komanduri, Prediction of molecu-
lar-dynamics simulation results using feedforward neural
networks: Reaction of a C2 dimer with an activated dia-
mond (100) surface, The Journal of Chemical Physics 123,
224711, 2005. (Chapter 24)
[Albe72] A. Albert, Regression and the Moore-Penrose Pseudoin-
verse, New York: Academic Press, 1972. (Chapter 7)
[AmMu97] S. Amari, N. Murata, K.-R. Muller, M. Finke, and H. H.
Yang, Asymptotic Statistical Theory of Overtraining and
Cross-Validation, IEEE Transactions on Neural Net-
works, vol. 8, no. 5, 1997. (Chapter 13)
[Ande72] J. A. Anderson, A simple neural network generating an in-
teractive memory, Mathematical Biosciences, vol. 14, pp.
197220, 1972. (Chapter 1, 15, 21)
[AnRo88] J. A. Anderson and E. Rosenfeld, Neurocomputing: Foun-
dations of Research, Cambridge, MA: MIT Press, 1989.
(Chapter 1, 10)
[AnSi77] J. A. Anderson, J. W. Silverstein, S. A. Ritz and R. S. Jones,
Distinctive features, categorical perception, and probabil-
ity learning: Some applications of a neural model, Psycho-
logical Review, vol. 84, pp. 413451, 1977. (Chapter 21)
[Barn92] E. Barnard, Optimization for training neural nets, IEEE
Transactions on Neural Networks, vol. 3, no. 2, pp. 232
240, 1992. (Chapter 12)
[BaSu83] A. R. Barto, R. S. Sutton and C. W. Anderson, Neuronlike
adaptive elements that can solve difficult learning control
problems, IEEE Transactions on Systems, Man, and Cy-
bernetics, vol. 13, pp. 834846, 1983. (Chapter 4)
[Batt92] R. Battiti, First and second order methods for learning:
Between steepest descent and Newtons method, Neural
Computation, vol. 4, no. 2, pp. 141166, 1992. (Chapter 9,
12)
[Bish91] C. M. Bishop, Improving the generalization properties of
radial basis function neural networks, Neural Computa-
tion, vol. 3, no. 4, pp. 579-588, 1991. (Chapter 17)
A-1
A Bibliography
A-2
A Bibliography
A-3
A Bibliography
A-4
A Bibliography
A-5
A Bibliography
A-6
A Bibliography
A-7
A Bibliography
A-8
A Bibliography
A-9
A Bibliography
A-10
A Bibliography
A-11
B Notation
B 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).
Weight Matrices
Scalar Element
k
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
k
iw t
Bias Vector
Scalar Element
k
bi t B
Vector
k
b t
B-1
B Notation
Input Vector
Scalar Element
pi t
Vector
k k
n t or n q
Output Vector
Scalar Element
k k
a i t or a i q
Vector
k k
a t or a q
Transfer Function
Scalar Element
k k k
ai = f ni
Vector
k k 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
At Iteration k
x k or x k
Norm
x
Performance Index
F x
B-3
B Notation
f n 1
m m
0 0
m m
F n =
m m 0 f n2 0
m m
0 0 f n Sm
Jacobian Matrix
Jx
Sensitivity Vector
Scalar Element
m F
s i --------m-
n i
Vector
m F
s --------m-
n
B-4
B Notation
Partial Matrix (single input vector p q ) and Full Matrix (all inputs)
m m
S q and S = S m S m S m
1 2 Q
Dynamic Networks
Sensitivity
e u
u m ak t
s k i t ----------------
m
-
n i t
Weight Matrices
m l
IW d - input weight between input l and layer m at delay d
m l
LW d - layer weight between layer l and layer m at delay d
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
L m - indices of layers that directly connect forward to layer m.
b
L m - indices of layers that are directly connected backwards to layer
m (or to which layer m connects forward) and that contain no de-
lays in the connection.
U x u
E LW x = u U LW d 0 d 0
X u x
ES u = x X S 0
u x
E S u = x S 0
X
E LW u = x X LW
x u
d 0 d 0 B
U u x
ES x = u U S 0
B-5
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.
Marquardt Parameters
and
Generalization
Regularization Parameters
, and = ---
Effective Number of Parameters
Selected Model
M
B-6
B Notation
Neighborhood
N i d = j d ij d
1 0 0 0 1 1
0 1 0 1
W = 0 1
+ 1 - 1
and W =
0 0 1 1 1 0
Time Constant
Relative Intensity
1
S
p
p i = ----i where P =
P pj
j=1
B-7
B Notation
Lyapunov Stability
Lyapunov Function
Va
Amplifier Gain
B-8
Introduction
C Software
Introduction
We have used MATLAB, a numeric computation and visualization soft-
ware package, in this text. However, MATLAB is not essential for using
this book. The computer exercises can performed with any available pro-
gramming 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 im-
plemented, and large scale problems can be tested conveniently. If MAT-
LAB 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 referenc-
es 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 cre-
ate 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 er-
rors 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.
C-2
Overview of Demonstration Files
C
C-3
C Software
C-4
Overview of Demonstration Files
C
C-5
Index
Index
A Layer 1 19-4
Abbreviated notation 2-8 Layer 2 19-10
ADALINE network 10-2 learning law
decision boundary 10-4 L1 - L2 19-17
mean square error 10-4 L2 - L1 19-20
Adaptive filtering 10-13 orienting subsystem 19-13
Adaptive noise cancellation 10-15 resonance 19-17
Adaptive resonance theory (ART) 19-2 subset/superset dilemma 19-17
Amacrine cells 18-4 summary 19-21
Amari, S. 18-2 vigilance 19-15
AND gate 4-7 ART2 19-23
Anderson, J.A. 1-2, 1-3, 15-2, 18-2 ART3 19-23
Angle 5-7 ARTMAP 19-23
Apple and Orange Example 3-2 Associative learning
Hamming network solution 3-8 Hebb rule 7-4
Hopfield solution 3-12 instar rule 15-11
perceptron 3-3 Kohonen rule 15-15
perceptron solution 3-5 outstar rule 15-17
problem statement 3-2 pseudoinverse rule 7-7
Applications of neural networks 1-5 unsupervised Hebb rule 15-5
aerospace 1-5 Associative memory 7-3
automotive 1-5 autoassociative memory 7-10
banking 1-5 Hopfield network 21-5
defense 1-6 linear associator 7-3
electronics 1-6 Associative networks 15-3
entertainment 1-6 instar 15-9
financial 1-6 outstar 15-16
insurance 1-6 Attractors 21-11
manufacturing 1-6 Autoassociative memory 7-10
medical 1-6 Autocorrelation function 22-24
oil and gas 1-6
robotics 1-7 B
securities 1-7 Backpropagation 11-7
speech 1-7 batching 12-7
telecommunications 1-7 CGBP 12-15
transportation 1-7 choice of network architecture 11-18
ART1 conjugate gradient 12-14
fast learning 19-19 convergence 11-20
Index-1
Index
delta-bar-delta 12-13 C
drawbacks 12-3, 14-3 Carpenter, G. 19-2
example 11-14 Center 17-6
generalization 11-22 CGBP 12-15
initial weights 12-6 Chain rule 11-9
Jacobian matrix 12-23 Change of basis 6-6
Levenberg-Marquardt 12-19, 12-21 similarity transformation 6-8
Jacobian calculation 12-22 Chemical vapor deposition 24-2
Marquardt sensitivity 12-24 Choice of network architecture 11-18
LMBP 12-25 Circular hollow 8-16
MOBP 12-11 Clustering 22-9
performance index 11-8 Coding the targets 22-7
performance surface 12-3 Committee of networks 22-18, 25-10
Quickprop 12-14 Competitive learning 16-7
SDBP 12-2 adaptive resonance theory 19-2
sensitivity 11-10 ART1 19-4
summary 11-13 ART2 19-23
SuperSAB 12-14 ART3 19-23
VLBP 12-12 ARTMAP 19-23
Backpropagation order 14-4 Fuzzy ARTMAP 19-23
Backpropagation-through-time (BPTT) 14-2, 14- instar rule 16-7
11, 14-22 Kohonen rule 16-7
Backward elimination 17-18 learning rate 16-9
Basis set 5-5 LVQ2 16-21
Batch SOFM learning algorithm 26-6 problems 16-9
Batch training 11-17 Competitive networks 16-5
Batching 12-7 ART1 19-4
Bayes rule 13-10 Grossberg 18-13
Bayes Theorem 13-10 Hamming network 16-3
Bayesian analysis 13-12 Lateral inhibition 16-5
effective number of parameters 13-16 learning vector quantization 16-16
evidence 13-13 self-organizing feature map 16-12
Gauss-Newton approximation to Bayesian winner-take-all 16-5
regularization 13-17 Conditioned stimulus 15-3
likelihood function 13-13 Cones 18-3
posterior density 13-13 Confusion matrix 22-21, 25-7
prior density 13-13 Conjugate directions 9-16
Bayesian regularization 13-12, 23-6 Conjugate gradient 9-15, 12-14
effective number of parameters 23-6 golden section search 12-17
Baysian analysis interval location 12-16
most probable 13-14 interval reduction 12-16
Biological inspiration of neural networks 1-8 Content-addressable memory 21-16
Bipolar cells 18-3 Contour plot 8-8
Brightness constancy 18-8 Contrast enhance 18-18
Index-2
Index
Index-3
Index
Hessian 8-5 K
eigensystem 8-13 Kohonen rule 15-15, 16-7
Hidden layer 2-11 graphical representation 16-7
High-gain Lyapunov function 21-13 Kohonen, T. 1-3, 15-2, 18-2
Hinton, G.E. 11-2
Histogram of errors 22-21 L
History of neural networks 1-2 LaSalles corollary 20-14
Hoff, M.E. 1-3, 10-2, 11-2 LaSalles invariance theorem 20-13
Hopfield model 21-3 invariant set 20-13
Hopfield network 3-12, 6-2, 21-5 Set
attractors 21-11 L 20-13
design 21-16 Z 20-12
content-addressable memory 21-16 Lateral inhibition 16-5
effect of gain 21-12 Layer 2-9
example 21-7 competitive 16-5
Hebb rule 21-18 problems 16-9
high-gain Lyapunov function 21-13 hidden 2-11
Lasalles invariance theorem 21-7 output layer 2-11
Lyapunov function 21-5 superscript 2-11
Lyapunov surface 21-22 Layer weight 14-3
spurious patterns 21-20 Layered Digital Dynamic Network (LDDN) 14-3
Hopfield, J.J. 1-4 Le Cun, Y. 11-2
Horizontal cells 18-4 Leaky integrator 18-9
Hubel, D.H. 16-2, 18-12 Learning rate 9-3, 10-8
competitive learning 16-9
I stable 9-6, 10-10
Illusions 18-4 Learning rules 4-2
Incremental training 11-17 ART1 19-21
Infinite impulse response 14-7 backpropagation 11-7
Inhibitory 18-10 competitive learning 16-7
Inner product 5-6 delta rule 7-13
Input selection 22-12 Grossberg competitive network 18-22
Input weight 14-3 Hebb rule 7-4
Instar 15-9 Hebbian learning 7-2
Instar rule 15-11, 16-7 learning vector quantization 16-16
Integrator 2-13 LMS algorithm 10-7
Interpolation 13-3 local learning 15-5
Interval location 12-16 perceptron 4-8, 4-13
Interval reduction 12-16 proof of convergence 4-15
Invariant set 20-13 performance learning 8-2
pseudoinverse rule 7-7
J reinforcement learning 4-3
Jacobian matrix 12-20 supervised learning 4-3
Jacobs, R.A. 12-13 unsupervised learning 4-3
Index-4
Index
Index-5
Index
Index-6
Index
Index-7
Index
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.
Martin T. Hagan (Ph.D. Electrical Engineering, University of Kansas) has taught and
conducted research in the areas of control systems and signal processing for the last 35 years.
For the last 25 years his research has focused on the use of neural networks for control,
filtering and prediction. He is a Professor in the School of Electrical and Computer
Engineering at Oklahoma State University and a co-author of the Neural Network Toolbox
for MATLAB.
Mark Hudson Beale (B.S. Computer Engineering, University of Idaho) is a software engineer
with a focus on artificial intelligence algorithms and software development technology. Mark
is co-author of the Neural Network Toolbox for MATLAB and provides related consulting
through his company, MHB Inc., located in Hayden, Idaho.
Orlando De Jess (Ph.D. Electrical Engineering, Oklahoma State University) has twenty-
four years of industrial experience, with AETI C.A. in Caracas, Venezuela, Halliburton in
Carrollton, Texas and is currently working as Engineering Consultant in Frisco, Texas.
Orlandos dissertation was a basis for the dynamic network training algorithms in the
Neural Network Toolbox for MATLAB.