Class 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
    • 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 decay phi. 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 decay phi. 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 class NeuralNetwork
        Parameters:
        patterns - The patterns to be learned.
        answers - The expected answers.
        alpha - The learning rate.
        epochs - The maximum number of iterations
        offset - The first pattern position
        length - 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 the pattern.
        Specified by:
        simulate in class NeuralNetwork
        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 class NeuralNetwork
        Parameters:
        pattern - The input pattern
        result - The output result.
      • getWeights

        public Matrix getWeights()