Package libai.nn.supervised
Class LVQ
- java.lang.Object
-
- libai.nn.NeuralNetwork
-
- libai.nn.supervised.SupervisedLearning
-
- libai.nn.supervised.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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
error(Column[] patterns, Column[] answers, int offset, int length)
Calculates the number of incorrect answers over the total.Matrix[]
getWeights()
Column
simulate(Column pattern)
Calculates the output for thepattern
.void
simulate(Column pattern, Column result)
Calculate the output for thepattern
and left the result inresult
.protected int
simulateNoChange(Matrix pattern)
void
train(Column[] patterns, Column[] answers, double alpha, int epochs, int offset, int length, double minerror)
Train the network using a hybrid scheme.-
Methods inherited from class libai.nn.NeuralNetwork
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
-
-
-
-
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 networkrand
- 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 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 thepattern
and left the result inresult
. The result will be a row matrix fill with 0 except for the winner position.- Specified by:
simulate
in classNeuralNetwork
- 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 classNeuralNetwork
- Parameters:
patterns
- The array with the patterns to testanswers
- 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()
-
-