com.huguesjohnson.jail.neuralNetwork
Class Layer

java.lang.Object
  |
  +--com.huguesjohnson.jail.neuralNetwork.Layer
All Implemented Interfaces:
java.lang.Runnable, java.io.Serializable
Direct Known Subclasses:
BackPropagationLayer, KohonenLayer

public abstract class Layer
extends java.lang.Object
implements java.lang.Runnable, java.io.Serializable

class Layer

See Also:
Serialized Form

Constructor Summary
Layer()
          default constructor
 
Method Summary
 void adjustTrainingRate(double rate)
          adjusts training rates and error thresholds for every neuron in the layer values greater than 1.0 increase training rate, values between 0.0 and 1.0 decrease training rate
 void computeError()
          computes the error of the layer (desiredOutput-actualOutput)
abstract  void computeOutput()
          compute the output of the layer
 double[] getDesiredOutput()
          returns the desired output of the layer
 boolean getDoneTraining()
          returns the training status of the layer
 double getError()
          returns the error of the layer
 com.huguesjohnson.jail.neuralNetwork.Neuron getNeuron(int index)
          returns the neuron at the specified index in the layer
 double[] getOutput()
          returns the output of the layer
 double getOutput(int index)
          returns the output of a specific neuron in the layer
 int getSize()
          returns the number of neurons in the layer
 void initOutput()
          clears the output array
 void insertNeuron(int index, com.huguesjohnson.jail.neuralNetwork.Neuron neuron)
          inserts a neuron at the specified index in the layer
 void insertNeuron(com.huguesjohnson.jail.neuralNetwork.Neuron neuron)
          inserts a neuron to the bottom of the layer
 void removeNeuron(int index)
          removes a neuron at the specified index in the layer
 void run()
          run the layer
 void runComplete()
          method invoked when run is complete
 void setDesiredOutput(double[] desiredOutput)
          sets the desired output of the layer, needed for training
 void setDoneTraining(boolean doneTraining)
          sets the training status of the layer
 void setInput(double[] input)
          sets the input to the layer each neuron in the layer receives the same input
 void setNeuron(int index, com.huguesjohnson.jail.neuralNetwork.Neuron neuron)
          sets a neuron at the specified index in the layer
 void setOutput(int index, double value)
          sets the output of a specific neuron in the layer
 void start()
          begins thread execution
 void stop()
          stops thread execution
 java.lang.String toString()
          returns a string representation of the object
abstract  void train()
          train the layer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Layer

public Layer()
default constructor

Method Detail

setInput

public final void setInput(double[] input)
sets the input to the layer each neuron in the layer receives the same input

Parameters:
input - the input to the layer

setDesiredOutput

public final void setDesiredOutput(double[] desiredOutput)
                            throws LayerException
sets the desired output of the layer, needed for training

Parameters:
desiredOutput - the desired output of the layer
Throws:
LayerException - if the size of desiredOutput is not equal to the number of neurons in the layer

getDesiredOutput

public final double[] getDesiredOutput()
returns the desired output of the layer

Returns:
the desired output of the layer

insertNeuron

public final void insertNeuron(com.huguesjohnson.jail.neuralNetwork.Neuron neuron)
inserts a neuron to the bottom of the layer

Parameters:
neuron - the neuron to add

insertNeuron

public final void insertNeuron(int index,
                               com.huguesjohnson.jail.neuralNetwork.Neuron neuron)
                        throws LayerException
inserts a neuron at the specified index in the layer

Parameters:
index - the index to insert the neuron at
neuron - the neuron to add
Throws:
LayerException - if index<0 or index>=number of neurons in the layer

removeNeuron

public final void removeNeuron(int index)
                        throws LayerException
removes a neuron at the specified index in the layer

Parameters:
index - the index to remove the neuron from
Throws:
LayerException - if index<0 or index>=number of neurons in the layer

setNeuron

public final void setNeuron(int index,
                            com.huguesjohnson.jail.neuralNetwork.Neuron neuron)
                     throws LayerException
sets a neuron at the specified index in the layer

Parameters:
index - the index to set the neuron at
neuron - the neuron to set
Throws:
LayerException - if index<0 or index>=number of neurons in the layer

getNeuron

public final com.huguesjohnson.jail.neuralNetwork.Neuron getNeuron(int index)
                                                            throws LayerException
returns the neuron at the specified index in the layer

Parameters:
index - the index of the neuron to return
Returns:
the neuron at index
Throws:
LayerException - if index<0 or index>=number of neurons in the layer

getOutput

public final double[] getOutput()
returns the output of the layer

Returns:
output of the layer

computeError

public final void computeError()
computes the error of the layer (desiredOutput-actualOutput)


getError

public final double getError()
returns the error of the layer

Returns:
error of the layer

getSize

public final int getSize()
returns the number of neurons in the layer

Returns:
number of neurons in the layer

getOutput

public final double getOutput(int index)
                       throws LayerException
returns the output of a specific neuron in the layer

Parameters:
index - the index of the neuron output to return
Returns:
the output of the neuron at index
Throws:
LayerException - if index<0 or index>=number of neurons in the layer

setOutput

public final void setOutput(int index,
                            double value)
                     throws LayerException
sets the output of a specific neuron in the layer

Parameters:
index - the index of the neuron output to set
value - the new output
Throws:
LayerException - if index<0 or index>=number of neurons in the layer

initOutput

public final void initOutput()
clears the output array


getDoneTraining

public final boolean getDoneTraining()
returns the training status of the layer

Returns:
true if the layer is done training

setDoneTraining

public final void setDoneTraining(boolean doneTraining)
sets the training status of the layer

Parameters:
doneTraining - set to true if the layer is done training

adjustTrainingRate

public final void adjustTrainingRate(double rate)
adjusts training rates and error thresholds for every neuron in the layer values greater than 1.0 increase training rate, values between 0.0 and 1.0 decrease training rate

Parameters:
rate - the new training rate

start

public void start()
begins thread execution


stop

public void stop()
stops thread execution


run

public void run()
run the layer

Specified by:
run in interface java.lang.Runnable

runComplete

public void runComplete()
method invoked when run is complete


toString

public java.lang.String toString()
returns a string representation of the object

Overrides:
toString in class java.lang.Object
Returns:
string representation of the object

train

public abstract void train()
train the layer


computeOutput

public abstract void computeOutput()
compute the output of the layer