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

bpn.readConversionFile("fileName");

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

 

4. Create input layer

bpn.addNeuronLayer(i);

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

 

Create hidden layer(s)

bpn.addNeuronLayer(h);

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

bpn.addNeuronLayer(o);

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

 

6. Connect all layers

bpn.connectLayers();

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

 

7. Read pattern file

bpn.readPatternFile("fileName");

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

bpn.setLearningRate(x);

Sets the net's learning rate to x.

 

Set minimum error

bpn.setMinimumError(x);

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

 

Set accuracy

bpn.setAccuracy(x);

Sets the net's accuracy value to x.

 

Set maximum learning cycles

bpn.setMaxLearningCycles(x);

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

 

Reset learning time

bpn.resetTime();

Resets the learning time.

 

8. Perform a learning cycle

bpn.learn();

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

 

Recall a pattern

bpn.recall("inputPattern");

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

Information is available on:

Accuracy

bpn.getAccuracy();

Returns the accuracy value of the net.

 

Elapsed time

bpn.getElapsedTime();

Returns the time that elapsed since the learning process started.

 

Input pattern

bpn.getInputPattern(i);

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

 

Learning cycle

bpn.getLearningCycle();

Returns the current learning cycle of the net.

 

Learning rate

bpn.getLearningRate();

Returns the learning rate of the net.

 

Minimum error

bpn.getMinimumError();

Returns the minimum error of the net.

 

Net error

bpn.getError();

Returns the current error of the net.

 

Neuron outputs

bpn.getNeuronOutputs(i);

Returns the output values of all neurons in layer i.

 

Number of layers

bpn.getNumberOfLayers();

Returns the number of neuron layers.

 

Number of neurons

bpn.getNumberOfNeurons(i);

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

 

Number of patterns

bpn.getNumberOfPatterns();

Returns the number of input/target patterns.

 

Number of all weights

bpn.getNumberOfWeights();

Returns the number of all weights.

 

Number of weights

bpn.getNumberOfWeights(m);

Returns the number of weights in weight matrix m.

 

Output pattern

bpn.getOutputPattern(i);

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

 

Pattern error

bpn.getPatternError(i);

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

 

Target pattern

bpn.getTargetPattern(i);

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

 

Weight values

bpn.getWeightValues(m);

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: BPN.java

Neural Net Components in an Object Oriented Class Structure