dLife Home Page

dlife.nn
Class ElmanNeuralNetwork

java.lang.Object
  extended by dlife.sys.SerializationBase
      extended by dlife.nn.NeuralNetwork
          extended by dlife.nn.FFNeuralNetwork
              extended by dlife.nn.ElmanNeuralNetwork
All Implemented Interfaces:
Serializable

public class ElmanNeuralNetwork
extends FFNeuralNetwork

Implementation of a fully connected multi-layer Elman neural network. The Elman neural network contains a set of recurrent connections from the last hidden layer to the input layer. These connections allow the network to develop a sense of time, where the output is determined not only by the current input but by past inputs and outputs.

Care must be taken in training an Elman neural network as the sequence of training inputs is relevant. The actual inputs to the network for each training pattern include those in the training pattern as well as the outputs of the last hidden layer as computed for the previous training pattern.

For fuller descriptions of an Elman neural network see:

Version:
Mar 2, 2009
Author:
Lewis Flanagan
See Also:
Serialized Form

Field Summary
protected  int numInputs
           
 
Fields inherited from class dlife.nn.FFNeuralNetwork
ffweights, layerInputs, layerOutputs, nType
 
Fields inherited from class dlife.nn.NeuralNetwork
filteredInputs, filteredOutputs, rawInputs, rawOutputs
 
Constructor Summary
ElmanNeuralNetwork(double[][][] ffweights, Neuron nType)
          Construct a new ElmanNeuralNetwork by providing the weight matrix for the network.
ElmanNeuralNetwork(int[] layers, double[] weights, Neuron nType)
          Construct a new ElmanNeuralNetwork using the provided 1d array of weights.
ElmanNeuralNetwork(int[] layers, Neuron nType)
          Construct a new ElmanNeuralNetwork with the specified number of neurons in the layers and using the specified type of Neuron.
 
Method Summary
 void clearContext()
          This method clears the data stored in the context units by setting them to 0.
 int numInputs()
          Get the number of inputs that there are in this ElmanNeuralNetowrk.
 void propagate()
          Propagate the current filtered input values through the network.
 
Methods inherited from class dlife.nn.FFNeuralNetwork
getConnections, getFFWeights, getFFWeights1d, getLayerInputs, getLayerOutputs, getWeights, makeLayerInputs, makeLayerOutputs, numOutputs, randomizeWeights, read, setInputs
 
Methods inherited from class dlife.nn.NeuralNetwork
evaluate, evaluate, getFilteredInputs, getFilteredOutputs, getInputFilter, getInputFilter, getOutputFilter, getOutputFilter, getRawInputs, getRawOutputs, setInputFilter, setInputFilter, setOutputFilter, setOutputFilter, setOutputs
 
Methods inherited from class dlife.sys.SerializationBase
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numInputs

protected int numInputs
Constructor Detail

ElmanNeuralNetwork

public ElmanNeuralNetwork(int[] layers,
                          Neuron nType)
                   throws IllegalArgumentException
Construct a new ElmanNeuralNetwork with the specified number of neurons in the layers and using the specified type of Neuron.

Parameters:
layers - an array of ints specifying the number of neurons in each layer of the network.
nType - the type of neuron in the network.
Throws:
IllegalArgumenException - if the network does not have at least one hidden layer.
IllegalArgumentException

ElmanNeuralNetwork

public ElmanNeuralNetwork(double[][][] ffweights,
                          Neuron nType)
                   throws IllegalArgumentException
Construct a new ElmanNeuralNetwork by providing the weight matrix for the network. The format of the weight matrix for a ElmanNeuralNetwork is: Therfore: Note: This constructor assumes that the context units have already been created and are included in the weights matrix.

Parameters:
ffweights - the weights matrix.
nType - the type of Neuron to use for this network.
Throws:
IllegalArgumentException - if the ffweights do not specify a fully connected network.
IllegalArgumenException - if the network does not have at least one hidden layer.

ElmanNeuralNetwork

public ElmanNeuralNetwork(int[] layers,
                          double[] weights,
                          Neuron nType)
Construct a new ElmanNeuralNetwork using the provided 1d array of weights. The order of the weights in the 1d array is expected to be in the same order as that returned by the getFFWeights1d method.

Parameters:
layers - an array of ints specifying the number of neurons in each layer of the network.
weights - the weights for this network.
nType - the type of Neuron to use for this network.
Throws:
illegalArgumentException - if ffweights does not contain the correct number of weights.
IllegalArgumenException - if the network does not have at least one hidden layer.
Method Detail

numInputs

public int numInputs()
Get the number of inputs that there are in this ElmanNeuralNetowrk. This does not include context units.

Overrides:
numInputs in class FFNeuralNetwork
Returns:
the number of inputs.

propagate

public void propagate()
               throws IllegalStateException
Propagate the current filtered input values through the network. A call to this method causes the raw network outputs to be computed. Those raw outputs are then also filtered using the output filters to compute the filtered outputs. Note that the outputs of the last hidden layer from the last call to propagate will become the additional inputs to the current call.

Overrides:
propagate in class FFNeuralNetwork
Throws:
IllegalStateException - if this method is called before the inputs have been set by a call to setInputs.

clearContext

public void clearContext()
This method clears the data stored in the context units by setting them to 0.


dLife Home Page