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:
Serializable, Comparable<Layer>, ContextClearable, Layer, EncogPersistedObject

public class ContextLayer
extends BasicLayer
implements ContextClearable

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

Field Summary
static String ERROR
           
 
Constructor Summary
ContextLayer()
          Default constructor, mainly so the workbench can easily create a default layer.
ContextLayer(ActivationFunction activationFunction, 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
 void clearContext()
          Reset the context values back to zero.
 Persistor createPersistor()
          Create a persistor for this layer.
 double getBiasWeight(int index)
          Get one weight bias value.
 double[] getBiasWeights()
           
 NeuralData getContext()
           
 int getFlatContextIndex()
           
 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.
 void setBiasWeight(int index, double d)
          Set a bias weight.
 void setBiasWeights(double[] d)
          Set the bias weights.
 void setFlatContextIndex(int flatContextIndex)
          Set the flat context index.
 
Methods inherited from class org.encog.neural.networks.layers.BasicLayer
addNext, addNext, addSynapse, compareTo, compute, getActivationFunction, getBiasActivation, getCollection, getDescription, getID, getName, getNetwork, getNeuronCount, getNext, getNextLayers, getX, getY, hasBias, isConnectedTo, isSelfConnected, setActivationFunction, setBiasActivation, setCollection, setDescription, setID, setName, setNetwork, setNeuronCount, setX, setY, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ERROR

public static final String ERROR
See Also:
Constant Field Values
Constructor Detail

ContextLayer

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


ContextLayer

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

Parameters:
activationFunction - The activation function to use.
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 bias 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.

clearContext

public void clearContext()
Reset the context values back to zero.

Specified by:
clearContext in interface ContextClearable

getBiasWeights

public double[] getBiasWeights()
Specified by:
getBiasWeights in interface Layer
Overrides:
getBiasWeights in class BasicLayer
Returns:
The weight biases.

getBiasWeight

public double getBiasWeight(int index)
Get one weight bias value.

Specified by:
getBiasWeight in interface Layer
Overrides:
getBiasWeight in class BasicLayer
Parameters:
index - The index to get.
Returns:
The bias value.

setBiasWeights

public void setBiasWeights(double[] d)
Set the bias weights.

Specified by:
setBiasWeights in interface Layer
Overrides:
setBiasWeights in class BasicLayer
Parameters:
d - The bias weights.

setBiasWeight

public void setBiasWeight(int index,
                          double d)
Set a bias weight.

Specified by:
setBiasWeight in interface Layer
Overrides:
setBiasWeight in class BasicLayer
Parameters:
index - The index of the value to set.
d - The new value.

getFlatContextIndex

public int getFlatContextIndex()
Returns:
The index, in the flat network, where the context is stored.

setFlatContextIndex

public void setFlatContextIndex(int flatContextIndex)
Set the flat context index.

Parameters:
flatContextIndex - The index, in the flat network, where the context is stored.


Copyright © 2011. All Rights Reserved.