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()
          Constructor declaration
Layer(long lID)
          Constructor declaration
 
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 addNeuronEventListener(NeuronEventListener listener)
          Adds a neuron added event listener.
 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.
 long getID()
          Returns the Layer-ID
 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.
 Network getNetwork()
          Returns the network which holds this layer
 Neuron getNeuronForID(long lID)
          Get a specific Neuron by its ID
 java.util.Vector getNeurons()
          Get the neurons for this layer.
 long getNextNeuronID()
          Returns the next neuron ID for this layer Required for castor
 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 removeNeuron(Neuron neuron)
           
 void removeNeuronEventListener(NeuronEventListener listener)
          Removes a neuron added event listener.
 void seedNeurons(java.util.Vector inputs)
          Seed the neurons with input.
 void setID(long lID)
          Sets the Layer-ID
 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 setNetwork(Network network)
          Sets the network (=parent)
 void setNextNeuronID(long lNID)
          Sets the next neuron ID for this layer Required for castor
 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
See Also:
Constant Field Values

HIDDEN_LAYER

protected static final int HIDDEN_LAYER
See Also:
Constant Field Values

OUTPUT_LAYER

protected static final int OUTPUT_LAYER
See Also:
Constant Field Values
Constructor Detail

Layer

public Layer()
Constructor declaration


Layer

public Layer(long lID)
Constructor declaration

Parameters:
lID -
Method Detail

getID

public long getID()
Returns the Layer-ID


setID

public void setID(long lID)
Sets the Layer-ID


getNextNeuronID

public long getNextNeuronID()
Returns the next neuron ID for this layer Required for castor


setNextNeuronID

public void setNextNeuronID(long lNID)
Sets the next neuron ID for this layer Required for castor


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.

net.openai.ai.nn.network.NetworkConfigurationException

getNeurons

public java.util.Vector getNeurons()
Get the neurons for this layer.

Returns:
Vector All neurons in the layer.

getNeuronForID

public final Neuron getNeuronForID(long lID)
Get a specific Neuron by its ID

Parameters:
lID - ID of the Neuron
Returns:
Neuron with the given ID, NULL if there is no Neuron with this ID

seedNeurons

public void seedNeurons(java.util.Vector inputs)
Seed the neurons with input.


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.


getTransferFunction

public TransferFunction getTransferFunction()
Get the value of transferFunction.

Returns:
Value of transferFunction.

setTransferFunction

public void setTransferFunction(TransferFunction transferFunction)
Set the value of 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.


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.


removeNeuron

public void removeNeuron(Neuron neuron)

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)

addNeuronEventListener

public void addNeuronEventListener(NeuronEventListener listener)
Adds a neuron added event listener.

Parameters:
listener - listener to add.

removeNeuronEventListener

public void removeNeuronEventListener(NeuronEventListener listener)
Removes a neuron added event listener.

Parameters:
listener - listener to remove.

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.

getNetwork

public Network getNetwork()
Returns the network which holds this layer

Returns:
Value of property network.

setNetwork

public void setNetwork(Network network)
Sets the network (=parent)



Copyright - 2001 OpenAI Labs. All Rights Reserved.