backpropagation
Class Backpropagation

java.lang.Object
  |
  +--backpropagation.Backpropagation

public class Backpropagation
extends java.lang.Object

Implementation of the well-known backpropagation algorithm with optional number of layers.

Author: Richard Szabo
Last modification: 02/Mar/2001


Field Summary
 double absoluteError
          Summed absolute error on the components of the output vector.
protected  double calmingRate
          Calming rate of the learning rate: 1.0 means constant learning rate.
protected  double elasticity
          Elasticity of the sigmoid function.
protected  double elasticityRate
          Changing rate of the elasticity.
protected  backpropagation.Neuron[][] layers
          Layers of the network.
protected  double learningRate
          Learning rate of the network.
protected  double momentum
          Constant determining the influence of the previous weight change on the actual.
protected  int numberOfLayers
          Number of the layers, must be at least 2.
protected  int[] numberOfNeurons
          Number of the neurons in layers, must be at least 1.
protected  double theta
          Threshold of the sigmoid function.
 
Constructor Summary
protected Backpropagation()
          Hidden constructor of the class to be used in the loadNeuro static method.
  Backpropagation(int numberOfLayers, int[] numberOfNeurons)
          Basic constructor.
  Backpropagation(int numberOfLayers, int[] numberOfNeurons, double learningRate, double theta, double elasticity, double calmingRate, double momentum, double elasticityRate)
          Creation of a new BackProp network with lots of parameters.
 
Method Summary
 void alterWeights()
          Alteration of the network with Gaussian.
protected  double d1sigmoid(double x)
          First derivative of the sigmoid function.
 double getCalmingRate()
          Returns the calming rate.
 double getElasticity()
          Returns the actual elasticity.
 double getElasticityRate()
          Returns the elasticity rate.
 double getLearningRate()
          Returns the actual learning rate.
 double getMomentum()
          Returns the momentum.
 double getTheta()
          Returns the theta.
 double hidden(int i, int j)
          Returns the output value of the jth hidden neuron in the ith layer.
protected  void init()
          Initialization of the network with random weights.
 void learn(double[] input, double[] output)
          Teaches the network according to the input-output value pair.
static Backpropagation loadNeuro(java.lang.String path, java.lang.String name)
          Loads a previously learned network.
 double output(int i)
          Returns network output of a given neuron.
 void propagate(double[] input)
          Propagates the network input to get the output.
 void saveNeuro(java.lang.String path, java.lang.String name)
          Saves the learned network weights.
 void setCalmingRate(double calmingRate)
          Sets the calming rate.
 void setElasticity(double elasticity)
          Sets the elasticity.
 void setElasticityRate(double elasticityRate)
          Sets the elasticity rate.
 void setLearningRate(double learningRate)
          Sets the learning rate.
 void setMomentum(double momentum)
          Sets the momentum.
 void setTheta(double theta)
          Sets the theta.
protected  double sigmoid(double x)
          Sigmoid function working in the (-1,1) interval.
 java.lang.String toString()
          String representation of the network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

learningRate

protected double learningRate
Learning rate of the network.

theta

protected double theta
Threshold of the sigmoid function.

elasticity

protected double elasticity
Elasticity of the sigmoid function.

calmingRate

protected double calmingRate
Calming rate of the learning rate: 1.0 means constant learning rate.

momentum

protected double momentum
Constant determining the influence of the previous weight change on the actual. 0.0 means no influence.

elasticityRate

protected double elasticityRate
Changing rate of the elasticity. It must be in the [0.0,1.0].

numberOfLayers

protected int numberOfLayers
Number of the layers, must be at least 2.

numberOfNeurons

protected int[] numberOfNeurons
Number of the neurons in layers, must be at least 1.

layers

protected backpropagation.Neuron[][] layers
Layers of the network.

absoluteError

public double absoluteError
Summed absolute error on the components of the output vector.
Constructor Detail

Backpropagation

public Backpropagation(int numberOfLayers,
                       int[] numberOfNeurons)
Basic constructor.

Backpropagation

public Backpropagation(int numberOfLayers,
                       int[] numberOfNeurons,
                       double learningRate,
                       double theta,
                       double elasticity,
                       double calmingRate,
                       double momentum,
                       double elasticityRate)
Creation of a new BackProp network with lots of parameters.

Backpropagation

protected Backpropagation()
Hidden constructor of the class to be used in the loadNeuro static method.
Method Detail

propagate

public void propagate(double[] input)
Propagates the network input to get the output. Output is in the (-1,1) interval.

learn

public void learn(double[] input,
                  double[] output)
Teaches the network according to the input-output value pair. Output is in the (-1,1) interval.

alterWeights

public void alterWeights()
Alteration of the network with Gaussian.

saveNeuro

public void saveNeuro(java.lang.String path,
                      java.lang.String name)
Saves the learned network weights.

loadNeuro

public static Backpropagation loadNeuro(java.lang.String path,
                                        java.lang.String name)
Loads a previously learned network.

toString

public java.lang.String toString()
String representation of the network.
Overrides:
toString in class java.lang.Object

output

public double output(int i)
Returns network output of a given neuron.

hidden

public double hidden(int i,
                     int j)
Returns the output value of the jth hidden neuron in the ith layer. This function is necessary for the example of Mitchell.

getLearningRate

public double getLearningRate()
Returns the actual learning rate.

setLearningRate

public void setLearningRate(double learningRate)
Sets the learning rate.

getTheta

public double getTheta()
Returns the theta.

setTheta

public void setTheta(double theta)
Sets the theta.

getElasticity

public double getElasticity()
Returns the actual elasticity.

setElasticity

public void setElasticity(double elasticity)
Sets the elasticity.

getCalmingRate

public double getCalmingRate()
Returns the calming rate.

setCalmingRate

public void setCalmingRate(double calmingRate)
Sets the calming rate.

getMomentum

public double getMomentum()
Returns the momentum.

setMomentum

public void setMomentum(double momentum)
Sets the momentum.

getElasticityRate

public double getElasticityRate()
Returns the elasticity rate.

setElasticityRate

public void setElasticityRate(double elasticityRate)
Sets the elasticity rate.

sigmoid

protected double sigmoid(double x)
Sigmoid function working in the (-1,1) interval.

d1sigmoid

protected double d1sigmoid(double x)
First derivative of the sigmoid function.

init

protected void init()
Initialization of the network with random weights.