Using the BackpropagationNet class

Features of the BackpropagationNet class

Number of neuron layers minimum: 2, maximum: N
Number of neurons in each layer minimum: 1, maximum: N
Weight matrices Automatically created and initialized. The weights are connecting the neurons of two consecutive layers
Bias values Automatically used
Number of input/target patterns minimum: 1, maximum: N
One learning step includes Forward propagation and backpropagation of all input patterns (learning-by-epoch), changing of the weights

Steps to create a Backpropagation Net

1. Object declaration

BackpropagationNet bpn;

Required. Declares the object bpn to be of type BackpropagationNet.


2. Constructor call

bpn = new BackpropagationNet();

Required. Creates an instance of BackpropagationNet. This is the only constructor of the class and takes no arguments.


3. Read conversion file


Required. Reads the ASCII-binary conversion file. See The structure of a conversion file for further explanation of conversion files.


4. Create input layer


Required. Creates the net's input layer with i neurons. The neuron layers are sequentially added to the net structure!


Create hidden layer(s)


Creates the net's hidden layer(s) with h neurons. This step is optional (if your net should have no hidden layers) or may be done one or more times (if your net has one or more hidden layers). If your net has more than one hidden layers, the number of neurons in each layer must not always be the same.


5. Create output layer


Required. Creates the net's output layer with o neurons.


6. Connect all layers


Required. Connects the neurons of all consecutive layers. All weight matrices are created and initialized with random values.


7. Read pattern file


Required. Reads the pattern file that contains the input and target patterns. See The structure of a pattern file below for further explanation of pattern files.


Set learning rate


Sets the net's learning rate to x.


Set minimum error


Sets the net's minimum error to x. The net learns, until its error is smaller than this value.


Set accuracy


Sets the net's accuracy value to x.


Set maximum learning cycles


Sets the maximum number of learning cycles to x. The default value is -1 (no maximum).


Reset learning time


Resets the learning time.


8. Perform a learning cycle


Required. Performs one learning cycle. This method is usually called within a loop, which exits, if the finishedLearning() method returns true.


Recall a pattern


Tries to recall the correct output of the input pattern inputPattern.

Information is available on:



Returns the accuracy value of the net.


Elapsed time


Returns the time that elapsed since the learning process started.


Input pattern


Returns the input pattern with number i. Pattern numbers start with zero!


Learning cycle


Returns the current learning cycle of the net.


Learning rate


Returns the learning rate of the net.


Minimum error


Returns the minimum error of the net.


Net error


Returns the current error of the net.


Neuron outputs


Returns the output values of all neurons in layer i.


Number of layers


Returns the number of neuron layers.


Number of neurons


Returns the number of neurons in layer i. Neuron layer numbers start with zero!


Number of patterns


Returns the number of input/target patterns.


Number of all weights


Returns the number of all weights.


Number of weights


Returns the number of weights in weight matrix m.


Output pattern


Returns the output pattern with number i. Pattern numbers start with zero!


Pattern error


Returns the error of the output pattern with number i. Pattern numbers start with zero!


Target pattern


Returns the target pattern with number i. Pattern numbers start with zero!


Weight values


Returns all weight values of weight matrix m. Weight matrix numbers start with zero!

Here is the source code of the BPN Application to show you an example:

Neural Net Components in an Object Oriented Class Structure