jhpro.nnet
Class BackpropagationNet
- java.lang.Object
-
- jhpro.nnet.BackpropagationNet
-
- All Implemented Interfaces:
- java.io.Serializable
public class BackpropagationNet extends java.lang.ObjectBackpropagation is a supervised learning algorithm and is mainly used by Multi-Layer-Perceptrons to change the weights connected to the net's hidden neuron layer(s). The backpropagation algorithm uses a computed output error to change the weight values in backward direction. To get this net error, a forwardpropagation phase must have been done before. While propagating in forward direction, the neurons are being activated using the sigmoid activation function.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description BackpropagationNet()Construct Backpropagation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddNeuronLayer(int i)Adds a neuron layer with size neurons.voidconnectLayers()Connects all neuron layers with weight matrices.booleandisplayNow()voiderror(int i)booleanfinishedLearning()doublegetAccuracy()Returns the accuracy value.java.lang.StringgetAsciiValue(java.lang.String s)java.lang.StringgetElapsedTime()Returns the time that elapsed since the learning process started.doublegetError()Returns the current error of the net.java.lang.StringgetInputPattern(int i)intgetLearningCycle()Returns the current learning cycle of the net.doublegetLearningRate()Returns the current learning rate of the net.intgetMaxLearningCycles()doublegetMinimumError()Returns the minimum error of a neural net.float[]getNeuronOutputs(int i)Returns the output values of all neurons in layer iintgetNumberOfLayers()intgetNumberOfNeurons(int i)intgetNumberOfPatterns()intgetNumberOfWeights()intgetNumberOfWeights(int i)java.lang.StringgetOutputPattern(int i)Returns the output pattern with number patternNr.floatgetPatternError(int i)Returns the error of output pattern patternNr.java.lang.StringgetTargetPattern(int i)Returns the target pattern with number patternNr.float[][]getWeightValues(int i)Returns the weight values of weight matrix matrixNr.voidincLearningCycle()voidlearn()Performs one learning step.voidreadConversionFile(java.lang.String s)Reads a conversion table for ASCII-binary values from file conversionFileName.voidreadPatternFile(java.lang.String s)java.lang.Stringrecall(java.lang.String s)Tries to recall the correct output for a learned input pattern recallInput.voidresetTime()voidsetAccuracy(double d)Sets the accuracy value.voidsetDisplayStep(int i)voidsetLearningRate(double d)voidsetMaxLearningCycles(int i)Sets the maximum number of learning cycles to x.voidsetMinimumError(double d)Sets the minimum error of a neural net.doublesquare(double d)
-
-
-
Method Detail
-
addNeuronLayer
public void addNeuronLayer(int i)
Adds a neuron layer with size neurons. Note that neuron layers are sequentially added to the net.- Parameters:
i-
-
connectLayers
public void connectLayers()
Connects all neuron layers with weight matrices. Must be called after all neuron layers have been added.
-
setMinimumError
public void setMinimumError(double d)
Sets the minimum error of a neural net.- Parameters:
d-
-
getMinimumError
public double getMinimumError()
Returns the minimum error of a neural net.
-
setAccuracy
public void setAccuracy(double d)
Sets the accuracy value.- Parameters:
d-
-
getAccuracy
public double getAccuracy()
Returns the accuracy value.- Returns:
-
getWeightValues
public float[][] getWeightValues(int i)
Returns the weight values of weight matrix matrixNr. The values for matrixNr start with zero!- Parameters:
i-- Returns:
-
getNeuronOutputs
public float[] getNeuronOutputs(int i)
Returns the output values of all neurons in layer i- Parameters:
i- layer- Returns:
-
getNumberOfLayers
public int getNumberOfLayers()
-
getNumberOfNeurons
public int getNumberOfNeurons(int i)
-
getNumberOfWeights
public int getNumberOfWeights()
-
getNumberOfWeights
public int getNumberOfWeights(int i)
-
getNumberOfPatterns
public int getNumberOfPatterns()
-
getInputPattern
public java.lang.String getInputPattern(int i)
-
getTargetPattern
public java.lang.String getTargetPattern(int i)
Returns the target pattern with number patternNr.- Parameters:
i-- Returns:
-
getOutputPattern
public java.lang.String getOutputPattern(int i)
Returns the output pattern with number patternNr.- Parameters:
i-- Returns:
-
getPatternError
public float getPatternError(int i)
Returns the error of output pattern patternNr.- Parameters:
i-- Returns:
-
getError
public double getError()
Returns the current error of the net.- Returns:
-
learn
public void learn()
Performs one learning step.
-
recall
public java.lang.String recall(java.lang.String s)
Tries to recall the correct output for a learned input pattern recallInput.- Parameters:
s-- Returns:
-
readConversionFile
public void readConversionFile(java.lang.String s)
Reads a conversion table for ASCII-binary values from file conversionFileName.- Parameters:
s-
-
getAsciiValue
public java.lang.String getAsciiValue(java.lang.String s)
-
readPatternFile
public void readPatternFile(java.lang.String s)
-
finishedLearning
public boolean finishedLearning()
-
error
public void error(int i)
-
square
public double square(double d)
-
setLearningRate
public void setLearningRate(double d)
-
getLearningRate
public double getLearningRate()
Returns the current learning rate of the net.- Returns:
-
setDisplayStep
public void setDisplayStep(int i)
-
displayNow
public boolean displayNow()
-
resetTime
public void resetTime()
-
getElapsedTime
public java.lang.String getElapsedTime()
Returns the time that elapsed since the learning process started.- Returns:
-
setMaxLearningCycles
public void setMaxLearningCycles(int i)
Sets the maximum number of learning cycles to x. The default value is -1 (no maximum).- Parameters:
i-
-
getMaxLearningCycles
public int getMaxLearningCycles()
-
incLearningCycle
public void incLearningCycle()
-
getLearningCycle
public int getLearningCycle()
Returns the current learning cycle of the net.- Returns:
-
-
DMelt 3.0 © DataMelt by jWork.ORG