The Encog Project

org.encog.neural.networks.layers
Class ContextLayer

java.lang.Object
  extended by org.encog.neural.networks.layers.BasicLayer
      extended by org.encog.neural.networks.layers.ContextLayer
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Layer, EncogPersistedObject

public class ContextLayer
extends BasicLayer

Implements a context layer. A context layer is used to implement a simple recurrent neural network, such as an Elman or Jordan neural network. The context layer has a short-term memory. The context layer accept input, and provide the same data as output on the next cycle. This continues, and the context layer's output "one step" out of sync with the input.

Author:
jheaton
See Also:
Serialized Form

Constructor Summary
ContextLayer()
          Default constructor, mainly so the workbench can easily create a default layer.
ContextLayer(ActivationFunction thresholdFunction, boolean hasThreshold, int neuronCount)
          Construct a context layer with the parameters specified.
ContextLayer(int neuronCount)
          Construct a default context layer that has the TANH activation function and the specified number of neurons.
 
Method Summary
 Persistor createPersistor()
          Create a persistor for this layer.
 NeuralData getContext()
           
 void process(NeuralData pattern)
          Called to process input from the previous layer.
 NeuralData recur()
          Called to get the output from this layer when called in a recurrent manor.
 
Methods inherited from class org.encog.neural.networks.layers.BasicLayer
addNext, addNext, addSynapse, clone, compute, getActivationFunction, getDescription, getName, getNeuronCount, getNext, getNextLayers, getThreshold, getThreshold, getX, getY, hasThreshold, isConnectedTo, isSelfConnected, setActivationFunction, setDescription, setName, setNeuronCount, setThreshold, setThreshold, setX, setY, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ContextLayer

public ContextLayer()
Default constructor, mainly so the workbench can easily create a default layer.


ContextLayer

public ContextLayer(ActivationFunction thresholdFunction,
                    boolean hasThreshold,
                    int neuronCount)
Construct a context layer with the parameters specified.

Parameters:
thresholdFunction - The threshold function to use.
hasThreshold - Does this layer have thresholds?
neuronCount - The neuron count to use.

ContextLayer

public ContextLayer(int neuronCount)
Construct a default context layer that has the TANH activation function and the specified number of neurons. Use threshold values.

Parameters:
neuronCount - The number of neurons on this layer.
Method Detail

createPersistor

public Persistor createPersistor()
Create a persistor for this layer.

Specified by:
createPersistor in interface EncogPersistedObject
Overrides:
createPersistor in class BasicLayer
Returns:
The new persistor.

getContext

public NeuralData getContext()
Returns:
The context, or memory of this layer. These will be the values that were just output.

process

public void process(NeuralData pattern)
Called to process input from the previous layer. Simply store the output in the context.

Specified by:
process in interface Layer
Overrides:
process in class BasicLayer
Parameters:
pattern - The pattern to store in the context.

recur

public NeuralData recur()
Called to get the output from this layer when called in a recurrent manor. Simply return the context that was kept from the last iteration.

Specified by:
recur in interface Layer
Overrides:
recur in class BasicLayer
Returns:
The recurrent output.

The Encog Project