net.openai.ai.nn.network
Class Layer

java.lang.Object
  |
  +--net.openai.ai.nn.network.Layer
All Implemented Interfaces:
java.io.Serializable

public class Layer
extends java.lang.Object
implements java.io.Serializable

This class is a container for neurons and keeps state information for this layer.

See Also:
Serialized Form

Field Summary
protected static int HIDDEN_LAYER
           
protected static int INPUT_LAYER
           
protected static int OUTPUT_LAYER
           
 
Constructor Summary
Layer()
           
 
Method Summary
 void addBias()
          Add the bias neuron.
 void addNeuron()
          Creates and adds a single neuron to the layer.
 void addNeuron(Neuron neuron)
          Adds a single neuron to the layer.
 void calculate()
          Processes this layer, calling the input function, then the transfer function and sets all variables for the learning process to be completed.
 void clear()
          Clears all the existing neurons.
 InputFunction getInputFunction()
          Get the value of inputFunction.
 int getLayerType()
          Get the layer type.
 LearningRule getLearningRule()
          Get the value of learningRule.
 java.lang.String getName()
          Gets the name for this layer.
 java.util.Vector getNeurons()
          Get the neurons for this layer.
 int getSize()
          Returns the number of neurons in this layer.
 TransferFunction getTransferFunction()
          Get the value of transferFunction.
 void learn(TrainingElement trainingElement)
          The learning method for the layer.
 boolean readyToLearn()
          Calls the learning rule to see if it's ready to process this layer.
 void seedNeurons(java.util.Vector inputs)
          Seed the neurons with input.
 void setInputFunction(InputFunction inputFunction)
          Set the value of inputFunction.
 void setLayerType(int layerType)
          Set the layer type.
 void setLearningRule(LearningRule learningRule)
          Set the value of learningRule.
 void setName(java.lang.String name)
          Sets the name for this layer.
 void setSize(int i)
          Sets the number of neurons in this layer, this should behave much like the Vector.setSize() in that, if i > current Size, new neurons are added to the layer and if i < current Size then any neuron at index i or greater are discarded.
 void setTransferFunction(TransferFunction transferFunction)
          Set the value of transferFunction.
 java.lang.String toString()
          Returns a String representation of this layer.\
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INPUT_LAYER

protected static final int INPUT_LAYER

HIDDEN_LAYER

protected static final int HIDDEN_LAYER

OUTPUT_LAYER

protected static final int OUTPUT_LAYER
Constructor Detail

Layer

public Layer()
Method Detail

calculate

public void calculate()
Processes this layer, calling the input function, then the transfer function and sets all variables for the learning process to be completed.

readyToLearn

public boolean readyToLearn()
Calls the learning rule to see if it's ready to process this layer.
Returns:
boolean Tells whether this layer is ready to be processed for learning.

learn

public void learn(TrainingElement trainingElement)
           throws net.openai.ai.nn.network.NetworkConfigurationException
The learning method for the layer. This method just handles higher level concerns and leaves the implementation of the learning to the learning rule.

getNeurons

public java.util.Vector getNeurons()
Get the neurons for this layer.
Returns:
Vector All neurons in the layer.

seedNeurons

public void seedNeurons(java.util.Vector inputs)
Seed the neurons with input.
Parameters:
Vector - A collection of values to seed the neurons with...

addBias

public void addBias()
Add the bias neuron.

getLearningRule

public LearningRule getLearningRule()
Get the value of learningRule.
Returns:
Value of learningRule.

setLearningRule

public void setLearningRule(LearningRule learningRule)
Set the value of learningRule.
Parameters:
v - Value to assign to learningRule.

getTransferFunction

public TransferFunction getTransferFunction()
Get the value of transferFunction.
Returns:
Value of transferFunction.

setTransferFunction

public void setTransferFunction(TransferFunction transferFunction)
Set the value of transferFunction.
Parameters:
v - Value to assign to transferFunction.

getInputFunction

public InputFunction getInputFunction()
Get the value of inputFunction.
Returns:
Value of inputFunction.

setInputFunction

public void setInputFunction(InputFunction inputFunction)
Set the value of inputFunction.
Parameters:
v - Value to assign to inputFunction.

getSize

public int getSize()
Returns the number of neurons in this layer.
Returns:
number of neurons in this layer.

setSize

public void setSize(int i)
Sets the number of neurons in this layer, this should behave much like the Vector.setSize() in that, if i > current Size, new neurons are added to the layer and if i < current Size then any neuron at index i or greater are discarded.
Parameters:
i - The number of neurons to be held in this layer.

addNeuron

public void addNeuron()
Creates and adds a single neuron to the layer.

addNeuron

public void addNeuron(Neuron neuron)
Adds a single neuron to the layer.

clear

public void clear()
Clears all the existing neurons.

getName

public java.lang.String getName()
Gets the name for this layer.
Returns:
String - The name of this layer.

setName

public void setName(java.lang.String name)
Sets the name for this layer.
Parameters:
name - The name for this layer.

getLayerType

public int getLayerType()
Get the layer type.
Returns:
int - layer type

setLayerType

public void setLayerType(int layerType)
Set the layer type.
Parameters:
layerType - The type of this layer (input, hidden, output)

toString

public java.lang.String toString()
Returns a String representation of this layer.\
Overrides:
toString in class java.lang.Object
Returns:
String A representation of this layer.