org.jscience.computing.ai.neurocomputing
Class KohonenTrainer

java.lang.Object
  extended by org.jscience.computing.ai.neurocomputing.NeuralNetworkTrainer
      extended by org.jscience.computing.ai.neurocomputing.KohonenTrainer
All Implemented Interfaces:
Steppable

public abstract class KohonenTrainer
extends NeuralNetworkTrainer

This class implements the Kohonen training algorithm. The class implements the training algorithm as a two-stage process: phase one reduces the neighbourhood radius slowly to one, while the learning constant k is reduced from 0.9 to 0.1. Phase two increases the number of training points slightly, keeps the neighbourhood size constant at one, and reduces the learning rate from 0.1 to 0.


Field Summary
protected  int currentIteration
          The current training iteration.
protected  double deltaK
          The amount at which k should be reduced.
protected  boolean hasFinished
          Denotes whether the network has finished training.
protected  KohonenNN kohonenNN
          The Kohonen network.
protected  int phaseOne
          The number of phase one training iterations.
protected  int phaseTwo
          The number of phase two training iterations.
protected  int reductionStep
          The number of iterations to train before reducing the neighbourhood size.
protected  double[] trainData
          The training data.
protected  int trainingSteps
          The training steps per iteration.
 
Fields inherited from class org.jscience.computing.ai.neurocomputing.NeuralNetworkTrainer
notifier
 
Constructor Summary
KohonenTrainer()
          Creates a new instance of KohonenTrainer
 
Method Summary
 void doStep()
          Iterates one step of the Kohonen training algorithm.
 int getCurrentIteration()
          Returns the current iteration.
 NeuralNetwork getNetwork()
          Return the network being used.
 int getPhase()
          Return the phase being used by the Kohonen network (1 or 2).
abstract  double[] getTrainingPoint()
          Abstract method to allow a deriving class to return a valid training point.
 void init()
          Initializes the trainer.
 boolean isComplete()
          Returns whether the training is complete (hasFinished).
 void setNetwork(NeuralNetwork net)
          Set the Kohonen network to use in the trainer.
 void setPhases(int p1, int p2)
          Set the number of iterations for the two training phases.
 
Methods inherited from class org.jscience.computing.ai.neurocomputing.NeuralNetworkTrainer
reset, run, setNotifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

phaseOne

protected int phaseOne
The number of phase one training iterations.


phaseTwo

protected int phaseTwo
The number of phase two training iterations.


trainingSteps

protected int trainingSteps
The training steps per iteration.


reductionStep

protected int reductionStep
The number of iterations to train before reducing the neighbourhood size.


currentIteration

protected int currentIteration
The current training iteration.


deltaK

protected double deltaK
The amount at which k should be reduced.


trainData

protected double[] trainData
The training data.


hasFinished

protected boolean hasFinished
Denotes whether the network has finished training.


kohonenNN

protected KohonenNN kohonenNN
The Kohonen network.

Constructor Detail

KohonenTrainer

public KohonenTrainer()
Creates a new instance of KohonenTrainer

Method Detail

setPhases

public void setPhases(int p1,
                      int p2)
Set the number of iterations for the two training phases.

Parameters:
p1 - the number of phase one iterations.
p2 - the number of phase two iterations.

getTrainingPoint

public abstract double[] getTrainingPoint()
Abstract method to allow a deriving class to return a valid training point.

Returns:
Returns a random training point.

doStep

public void doStep()
Iterates one step of the Kohonen training algorithm. Nofitications are set up to fire after every iteration (ID = 0), and once training has completed (ID = 1). For more information about the training algorithm itself, see the class description.

Specified by:
doStep in interface Steppable
Specified by:
doStep in class NeuralNetworkTrainer

init

public void init()
Initializes the trainer.

Specified by:
init in interface Steppable
Specified by:
init in class NeuralNetworkTrainer

setNetwork

public void setNetwork(NeuralNetwork net)
Set the Kohonen network to use in the trainer.

Specified by:
setNetwork in class NeuralNetworkTrainer
Parameters:
net - the Kohonen network to use.

getNetwork

public NeuralNetwork getNetwork()
Return the network being used.

Specified by:
getNetwork in class NeuralNetworkTrainer
Returns:
the network being used.

isComplete

public boolean isComplete()
Returns whether the training is complete (hasFinished).

Specified by:
isComplete in class NeuralNetworkTrainer
Returns:
true if training has completeld, otherwise false.
See Also:
hasFinished

getCurrentIteration

public int getCurrentIteration()
Returns the current iteration.

Returns:
the current iteration.

getPhase

public int getPhase()
Return the phase being used by the Kohonen network (1 or 2).

Returns:
the phase the Kohonen training algorithm is in.