MTBooks, IDG Books Worldwide, Inc.
Adjustment to the threshold value or bias for the
jth output neuron:
” ¸
j
= ²
o
e
j
Adjustment to the threshold value or bias for the
jth hidden layer neuron:
´¸
j
= ²
h
e
j
For use of momentum parameter ± (more on this parameter in Chapter 13), instead of equations 7.5 and 7.6,
use:
”M
2
[ i ][ j ] ( t ) = ²
o
y
i
e
j
+ ±”M
2
[ i ][ j ] ( t − 1 )
(7.7)
and
”M
1
[ i ][ j ] ( t ) = ²
h
x
i
t
j
+ ±”M
1
[ i ][ j ] (t − 1)
(7.8)
C++ Implementation of a Backpropagation Simulator
The backpropagation simulator of this chapter has the following design objectives:
1. Allow the user to specify the number and size of all layers.
2. Allow the use of one or more hidden layers.
3. Be able to save and restore the state of the network.
4. Run from an arbitrarily large training data set or test data set.
5. Query the user for key network and simulation parameters.
6. Display key information at the end of the simulation.
7. Demonstrate the use of some C++ features.
A Brief Tour of How to Use the Simulator
In order to understand the C++ code, let us have an overview of the functioning of the program.
There are two modes of operation in the simulator. The user is queried first for which mode of operation is
desired. The modes are Training mode and Nontraining mode (Test mode).
Training Mode
Here, the user provides a training file in the current directory called training.dat. This file contains exemplar
pairs, or patterns. Each pattern has a set of inputs followed by a set of outputs. Each value is separated by one
or more spaces. As a convention, you can use a few extra spaces to separate the inputs from the outputs. Here
is an example of a training.dat file that contains two patterns:
0.4 0.5 0.89 −0.4 −0.8
0.23 0.8 −0.3 0.6 0.34
C++ Neural Networks and Fuzzy Logic:Preface
C++ Implementation of a Backpropagation Simulator
122
In this example, the first pattern has inputs 0.4, 0.5, and 0.89, with an expected output of –0.4 and –0.8. The
second pattern has inputs of 0.23, 0.8, and –0.3 and outputs of 0.6 and 0.34. Since there are three inputs and
two outputs, the input layer size for the network must be three neurons and the output layer size must be two
neurons. Another file that is used in training is the weights file. Once the simulator reaches the error tolerance
that was specified by the user, or the maximum number of iterations, the simulator saves the state of the
network, by saving all of its weights in a file called weights.dat. This file can then be used subsequently in
another run of the simulator in Nontraining mode. To provide some idea of how the network has done,
information about the total and average error is presented at the end of the simulation. In addition, the output
generated by the network for the last pattern vector is provided in an output file called output.dat.
Do'stlaringiz bilan baham: