Class LVQ

  • All Implemented Interfaces:
    java.io.Serializable

    public class LVQ
    extends SupervisedLearning
    Learning Vector Quantization or LVQ. Is an hybrid neural network with 3 layers (1-input, 1-hidden, 1-output). The first set of weights are trained using a competitive approach, and the second set of weights are trained using a supervised approach. Therefore the first steps are taken from the competitive network. This network was proposed by Teuvo Kohonen as alternative to the standard competitive. networks.
    See Also:
    Serialized Form
    • Field Detail

      • ins

        protected int ins
      • outs

        protected int outs
      • subclasses

        protected int subclasses
    • Constructor Detail

      • LVQ

        public LVQ​(int in,
                   int subclass,
                   int out)
        Constructor. Number of inputs, number of subclasses and number of outputs.
        Parameters:
        in - Number of input to the network.
        subclass - Number of subclasses for output class. Greater subdivision provides better classification.
        out - Number of outputs for the network
      • LVQ

        public LVQ​(int in,
                   int subclass,
                   int out,
                   java.util.Random rand)
        Constructor. Number of inputs, number of subclasses and number of outputs.
        Parameters:
        in - Number of input to the network.
        subclass - Number of subclasses for output class. Greater subdivision provides better classification.
        out - Number of outputs for the network
        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 a hybrid scheme. Uses the "winner takes all" rule.
        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 in result. The result will be a row matrix fill with 0 except for the winner position.
        Specified by:
        simulate in class NeuralNetwork
        Parameters:
        pattern - Pattern to use as input.
        result - The output for the input.
      • simulateNoChange

        protected int simulateNoChange​(Matrix pattern)
      • error

        public double error​(Column[] patterns,
                            Column[] answers,
                            int offset,
                            int length)
        Calculates the number of incorrect answers over the total.
        Overrides:
        error in class NeuralNetwork
        Parameters:
        patterns - The array with the patterns to test
        answers - The array with the expected answers for the patterns.
        offset - The initial position inside the array.
        length - How many patterns must be taken from the offset.
        Returns:
        The relation between the incorrect answers and the total number of answers.
      • getWeights

        public Matrix[] getWeights()