The Encog Project

org.encog.neural.networks.layers
Interface Layer

All Superinterfaces:
java.lang.Cloneable, EncogPersistedObject, java.io.Serializable
All Known Implementing Classes:
BasicLayer, ContextLayer, RadialBasisFunctionLayer

public interface Layer
extends java.lang.Cloneable, EncogPersistedObject

This interface defines all necessary methods for a neural network layer.

Author:
jheaton

Method Summary
 void addNext(Layer next)
          Add a layer to this layer.
 void addNext(Layer next, SynapseType type)
          Add a layer to this layer.
 void addSynapse(Synapse synapse)
          This method adds a synapse to the neural network.
 java.lang.Object clone()
           
 NeuralData compute(NeuralData pattern)
          Compute the output for this layer.
 ActivationFunction getActivationFunction()
           
 int getNeuronCount()
           
 java.util.List<Synapse> getNext()
          Get a list of all of the outbound synapse connections from this layer.
 java.util.Collection<Layer> getNextLayers()
           
 double[] getThreshold()
           
 double getThreshold(int index)
          Get an idividual threshold value.
 int getX()
           
 int getY()
           
 boolean hasThreshold()
           
 boolean isConnectedTo(Layer layer)
          Determine if this layer is connected to another.
 void process(NeuralData pattern)
          Process the data before it is modified by this layer.
 NeuralData recur()
          Called on recurrent layers to provide recurrent output.
 void setActivationFunction(ActivationFunction activationFunction)
          Set a new activation function for this layer.
 void setNeuronCount(int neuronCount)
          Set the neuron count, this will NOT adjust the synapses, or thresholds other code must do that.
 void setThreshold(double[] d)
          Set the threshold array for this layer.
 void setThreshold(int index, double d)
          Set an individual threshold value.
 void setX(int x)
          Set the x coordinate.
 void setY(int y)
          Set the y coordinate.
 
Methods inherited from interface org.encog.persist.EncogPersistedObject
createPersistor, getDescription, getName, setDescription, setName
 

Method Detail

addNext

void addNext(Layer next)
Add a layer to this layer. The "next" layer being added will receive input from this layer. You can also add a layer to itself, this will create a self-connected layer. This method will create a weighted synapse connection between this layer and the next.

Parameters:
next - The layer that is to be added.

addNext

void addNext(Layer next,
             SynapseType type)
Add a layer to this layer. The "next" layer being added will receive input from this layer. You can also add a layer to itself, this will create a self-connected layer.

Parameters:
next - The layer that is to be added.
type - The type of synapse to add.

addSynapse

void addSynapse(Synapse synapse)
This method adds a synapse to the neural network. Usually you will want to use the addNext method rather than directly adding synapses.

Parameters:
synapse - The synapse to add.

clone

java.lang.Object clone()
Specified by:
clone in interface EncogPersistedObject
Returns:
A clone of this object.

compute

NeuralData compute(NeuralData pattern)
Compute the output for this layer.

Parameters:
pattern - The input pattern.
Returns:
The output from this layer.

getActivationFunction

ActivationFunction getActivationFunction()
Returns:
The activation function used for this layer.

getNeuronCount

int getNeuronCount()
Returns:
The neuron count.

getNext

java.util.List<Synapse> getNext()
Get a list of all of the outbound synapse connections from this layer.

Returns:
The outbound connections.

getNextLayers

java.util.Collection<Layer> getNextLayers()
Returns:
The outbound layers from this layer.

getThreshold

double[] getThreshold()
Returns:
This layer's threshold values, if present, otherwise this function returns null.

getThreshold

double getThreshold(int index)
Get an idividual threshold value.

Parameters:
index - The threshold value to get.
Returns:
The threshold value.

getX

int getX()
Returns:
The x-coordinate that this layer should be displayed at in a GUI.

getY

int getY()
Returns:
The y-coordinate that this layer should be displayed at in a GUI.

hasThreshold

boolean hasThreshold()
Returns:
True if this layer has threshold values.

isConnectedTo

boolean isConnectedTo(Layer layer)
Determine if this layer is connected to another.

Parameters:
layer - The second layer, checked to see if it is connected to this layer.
Returns:
True if the two layers are connected.

process

void process(NeuralData pattern)
Process the data before it is modified by this layer. This method is useful for the context layer to remember the pattern it was presented with.

Parameters:
pattern - The pattern.

recur

NeuralData recur()
Called on recurrent layers to provide recurrent output. This is where the context layer will return the patter that it previously remembered.

Returns:
The recurrent output.

setNeuronCount

void setNeuronCount(int neuronCount)
Set the neuron count, this will NOT adjust the synapses, or thresholds other code must do that.

Parameters:
neuronCount - The new neuron count

setThreshold

void setThreshold(double[] d)
Set the threshold array for this layer.

Parameters:
d - The new threshold array.

setThreshold

void setThreshold(int index,
                  double d)
Set an individual threshold value.

Parameters:
index - The index of the threshold value.
d - The new threshold value.

setX

void setX(int x)
Set the x coordinate. The x&y coordinates are used to display the level on a GUI.

Parameters:
x - The x-coordinate.

setY

void setY(int y)
Set the y coordinate. The x&y coordinates are used to display the level on a GUI.

Parameters:
y - The y-coordinate.

setActivationFunction

void setActivationFunction(ActivationFunction activationFunction)
Set a new activation function for this layer.

Parameters:
activationFunction - The new activation function.

The Encog Project