org.jscience.computing.ai.neurocomputing
Class KohonenNN

java.lang.Object
  extended by org.jscience.computing.ai.neurocomputing.NeuralNetwork
      extended by org.jscience.computing.ai.neurocomputing.KohonenNN
All Implemented Interfaces:
Visualizable

public class KohonenNN
extends NeuralNetwork

This class provides a simple implementation of a two-dimensional Kohonen self- organizing map. KohonenNN.train only implements one iteration of the training algorithm, and as such does not handle the learning rate and neighbourhood alterations. KohonenTrainer provides the necessary implementation for that.

See Also:
train(double[], double[]), KohonenTrainer, KohonenTrainer.doStep()

Field Summary
protected  int featureVectors
          The number of feature vectors
protected  int height
          The height of the network.
protected  double k
          The learning constant.
protected  int neighbourhoodRadius
          The neighbourhood radius used during learning.
protected  double[][][] weights
          The network's weights.
protected  int width
          The width of the network.
 
Fields inherited from class org.jscience.computing.ai.neurocomputing.NeuralNetwork
activation, visualization
 
Constructor Summary
KohonenNN()
          Creates a new instance of KohonenNN
KohonenNN(int w, int h)
          Create a new instance of the network with additional size information.
KohonenNN(int w, int h, int v)
          Creates a new KohonenNN object.
 
Method Summary
 int[] getClosestNeuron(double[] input)
          Retrieves the closest neuron to the input point.
 int getFeatureVectors()
          DOCUMENT ME!
 int getHeight()
          Return the height of the network.
 double getK()
          Retrieve the K-value.
 int getNeighbourhoodRadius()
          Retrieve the neighbourhood radius.
 double[][][] getWeights()
          Return the array of PlotPoints used to store the weights.
 int getWidth()
          Return the width of the network.
 void initialize()
          Initialize the network.
 void initialize(double min, double max)
          Initialize the network.
 void reduceK(double kd)
          Reduce the learning constant by a specified amount.
 void reduceNeighbourhoodRadius(int nrd)
          Reduces the neighbourhood radius by the specified amount.
 double run(double[] inputData)
          Run the network for a given input.
 void setDimensions(int w, int h, int v)
          Set the dimensions of the network.
 void setK(double nk)
          Set k, the learning constant.
 void setNeighbourhoodRadius(int nr)
          Set the neighbourhood radius used during training.
 double train(double[] inputData, double[] expectedOutput)
          Train the network using KohonenData.
 
Methods inherited from class org.jscience.computing.ai.neurocomputing.NeuralNetwork
getVisualization, render, setActivation, setVisualization, train, train, writeImage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

width

protected int width
The width of the network.


height

protected int height
The height of the network.


featureVectors

protected int featureVectors
The number of feature vectors


k

protected double k
The learning constant.


weights

protected double[][][] weights
The network's weights. Weights are a 3-dimensional array, or a 2-dimensional array of feature vectors.


neighbourhoodRadius

protected int neighbourhoodRadius
The neighbourhood radius used during learning.

Constructor Detail

KohonenNN

public KohonenNN()
Creates a new instance of KohonenNN


KohonenNN

public KohonenNN(int w,
                 int h)
Create a new instance of the network with additional size information.

Parameters:
w - the width of the network.
h - the height of the network.

KohonenNN

public KohonenNN(int w,
                 int h,
                 int v)
Creates a new KohonenNN object.

Parameters:
w - DOCUMENT ME!
h - DOCUMENT ME!
v - DOCUMENT ME!
Method Detail

setDimensions

public void setDimensions(int w,
                          int h,
                          int v)
Set the dimensions of the network.

Parameters:
w - the width of the network.
h - the height of the network.
v - DOCUMENT ME!

getWidth

public int getWidth()
Return the width of the network.

Returns:
the width of the network.

getHeight

public int getHeight()
Return the height of the network.

Returns:
the height of the network.

getFeatureVectors

public int getFeatureVectors()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setNeighbourhoodRadius

public void setNeighbourhoodRadius(int nr)
Set the neighbourhood radius used during training. The new radius must be greater than zero.

Parameters:
nr - the new neighbourhood radius.

getNeighbourhoodRadius

public int getNeighbourhoodRadius()
Retrieve the neighbourhood radius.

Returns:
the neighbourhood radius.

reduceNeighbourhoodRadius

public void reduceNeighbourhoodRadius(int nrd)
Reduces the neighbourhood radius by the specified amount.

Parameters:
nrd - the neighbourhood radius delta. The delta is subtracted from the current neighbourhood radius.

setK

public void setK(double nk)
Set k, the learning constant. The new constant must be greater than, or equal to, zero.

Parameters:
nk - the new value of k.

getK

public double getK()
Retrieve the K-value.

Returns:
the k-value of the network.

reduceK

public void reduceK(double kd)
Reduce the learning constant by a specified amount.

Parameters:
kd - the k delta. This value will be subtracted from the current k.

initialize

public void initialize()
Initialize the network. All weights are initialized to random values between -0.5 and 0.5.

Specified by:
initialize in class NeuralNetwork

initialize

public void initialize(double min,
                       double max)
Initialize the network. All weights are initialized to random values between the specified values.

Parameters:
min - the minimum value.
max - the maximum value.
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

getClosestNeuron

public int[] getClosestNeuron(double[] input)
Retrieves the closest neuron to the input point.

Parameters:
input - input x
Returns:
the neuron (PlotPoint) closest in distance to the inputs.

run

public double run(double[] inputData)
Run the network for a given input. (Currently does not return anything meaningful.)

Specified by:
run in class NeuralNetwork
Parameters:
inputData - the input data.
Returns:
the network output (0.0).

train

public double train(double[] inputData,
                    double[] expectedOutput)
Train the network using KohonenData. This implementation of the training algorithm only trains for one iteration, using the given learning rate and neighbourhood size. See the main function for a complete training cycle.

Specified by:
train in class NeuralNetwork
Parameters:
inputData - the input data.
expectedOutput - unused.
Returns:
nothing.

getWeights

public double[][][] getWeights()
Return the array of PlotPoints used to store the weights. Useful for plotting the weights on a grid.

Returns:
a two-dimensional array of PlotPoints.
See Also:
org.jscience.computing.ai.util.PlotGrid#setGridPoints(PlotPoint[][])