Package libai.nn.supervised
Class Hebb
- java.lang.Object
-
- libai.nn.NeuralNetwork
-
- libai.nn.supervised.SupervisedLearning
-
- libai.nn.supervised.Hebb
-
- All Implemented Interfaces:
java.io.Serializable
public class Hebb extends SupervisedLearning
Hebbian supervised networks are good for pattern retrieval and reconstructions. These networks are only able to learn binary patterns because its output function (symmetric sign). However, they can deal with partially corrupted patterns and retrieve the original one without noise. The Hebbian networks uses the Hebb's rule for training. The Hebb's rule is one of the most important training rules in unsupervised networks. Other algorithms like Kohonen uses this rule as base.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected double
phi
protected static SymmetricSign
sign
protected Matrix
W
-
Fields inherited from class libai.nn.NeuralNetwork
plotter, progress, random
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Matrix
getWeights()
Column
simulate(Column pattern)
Calculates the output for thepattern
.void
simulate(Column pattern, Column result)
Calculate the output for the pattern and left the result on result.void
train(Column[] patterns, Column[] answers, double alpha, int epochs, int offset, int length, double minerror)
Train the network using the Hebb's rule with decay.-
Methods inherited from class libai.nn.NeuralNetwork
error, error, euclideanDistance2, euclideanDistance2, gaussian, getDefaultRandomGenerator, getPlotter, getProgressBar, initializeProgressBar, open, open, open, save, setPlotter, setProgressBar, train, train
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from class libai.nn.supervised.SupervisedLearning
validatePreconditions
-
-
-
-
Field Detail
-
sign
protected static final SymmetricSign sign
-
phi
protected double phi
-
W
protected Matrix W
-
-
Constructor Detail
-
Hebb
public Hebb(int inputs, int outputs)
Constructor. Creates a Hebbian network with the equals number of inputs and outputs. Set the decay constant to zero to eliminate it. Alias of this(inputs, 0);- Parameters:
inputs
- Number of inputs for the network.outputs
- Number of outputs for the network.
-
Hebb
public Hebb(int inputs, int outputs, double phi)
Constructor. Creates a Hebbian network with the equals number of inputs and outputs. Set the constant for decayphi
. If phi = 0 the network don't forget anything, if phi = 1 the network just remember the las pattern.- Parameters:
inputs
- Number of inputs and outputs for the networks.outputs
- Number of outputs for the network.phi
- Decay constant.
-
Hebb
public Hebb(int inputs, int outputs, double phi, java.util.Random rand)
Constructor. Creates a Hebbian network with the equals number of inputs and outputs. Set the constant for decayphi
. If phi = 0 the network don't forget anything, if phi = 1 the network just remember the las pattern.- Parameters:
inputs
- Number of inputs and outputs for the networks.outputs
- Number of outputs for the network.phi
- Decay constant.rand
- Random generator used for creating matrices
-
-
Method Detail
-
train
public void train(Column[] patterns, Column[] answers, double alpha, int epochs, int offset, int length, double minerror)
Train the network using the Hebb's rule with decay. The hebb's rule, consist on reinforce the right connections if they produce a correct answer and inhibit the others. The decay term has an influence in how much affects the previous knowledge to the reinforcement.- Specified by:
train
in classNeuralNetwork
- Parameters:
patterns
- The patterns to be learned.answers
- The expected answers.alpha
- The learning rate.epochs
- The maximum number of iterationsoffset
- The first pattern positionlength
- How many patterns will be used.minerror
- The minimal error expected.
-
simulate
public Column simulate(Column pattern)
Description copied from class:NeuralNetwork
Calculates the output for thepattern
.- Specified by:
simulate
in classNeuralNetwork
- Parameters:
pattern
- Pattern to use as input.- Returns:
- The output for the neural network.
-
simulate
public void simulate(Column pattern, Column result)
Calculate the output for the pattern and left the result on result. result = sign(W * pattern)- Specified by:
simulate
in classNeuralNetwork
- Parameters:
pattern
- The input patternresult
- The output result.
-
getWeights
public Matrix getWeights()
-
-