clarion.system
Class AbstractNeuralNet

java.lang.Object
  extended by clarion.system.AbstractImplicitModule
      extended by clarion.system.AbstractTrainableImplicitModule
          extended by clarion.system.AbstractNeuralNet
All Implemented Interfaces:
InterfaceTrainable
Direct Known Subclasses:
BPNet

public abstract class AbstractNeuralNet
extends AbstractTrainableImplicitModule

This class implements a three-layer, feed-forward neural network within CLARION. It extends the AbstractTrainableImplicitModule class. This class is abstract and therefore cannot be instantiated on its own.

Usage:

This class provides the framework for implementing a three-layer, feed forward neural network. If you want to define your own three-layer, feed forward network can do so by extending this class. Any classes that extend this class can be used as an implicit module on the bottom level of the CLARION subsystems.

Known Subclasses:

This class contains both global (static) and local constants. The default is to use the local constants. If you want to change any of the global constants, you need to do so before any instances of this class are initialized.

Version:
6.0.4
Author:
Nick Wilson & Xi Zang

Field Summary
static double GLOBAL_LOWER_INIT_THRESHOLD
          The low bound for the initial threshold.
static double GLOBAL_LOWER_INIT_WEIGHT
          The low bound for the initial weights.
static double GLOBAL_UPPER_INIT_THRESHOLD
          The upper bound for the initial threshold.
static double GLOBAL_UPPER_INIT_WEIGHT
          The upper bound for the initial weights.
protected  java.util.ArrayList<java.lang.Double> Hidden
          The hidden layer.
protected  java.util.ArrayList<java.lang.Double> HiddenThresholds
          The thresholds for the hidden layer.
protected  java.util.ArrayList<java.util.ArrayList<java.lang.Double>> HiddenToOutputWeights
          The hidden to output weight matrix.
protected  java.util.ArrayList<java.util.ArrayList<java.lang.Double>> InputToHiddenWeights
          The input to hidden weight matrix.
 double LOWER_INIT_THRESHOLD
          The low bound for the initial threshold.
 double LOWER_INIT_WEIGHT
          The low bound for the initial weights.
protected  java.util.ArrayList<java.lang.Double> OutputThresholds
          The thresholds for the output layer.
 double UPPER_INIT_THRESHOLD
          The upper bound for the initial threshold.
 double UPPER_INIT_WEIGHT
          The upper bound for the initial weights.
 
Fields inherited from class clarion.system.AbstractTrainableImplicitModule
DesiredOutput
 
Fields inherited from class clarion.system.AbstractImplicitModule
ACTUATION_TIME, ChosenOutput, DECISION_TIME, GLOBAL_ACTUATION_TIME, GLOBAL_DECISION_TIME, GLOBAL_PERCEPTION_TIME, InputAsCollection, Output, PERCEPTION_TIME
 
Constructor Summary
AbstractNeuralNet(java.util.Collection<Dimension> InputSpace, int NumHidden, AbstractOutputChunkCollection<? extends AbstractOutputChunk> Outputs)
          Initializes a neural network.
 
Method Summary
abstract  void backwardPass()
          Updates the neural network.
protected abstract  void computeHiddenActivation()
          Calculates the hidden derivative.
protected abstract  void computeOutputActivation()
          Calculates the output derivative.
 void forwardPass()
          Calculates the output activations based on the current input.
 java.util.List<java.lang.Double> getHiddenThresholds()
          Gets the hidden layer thresholds.
 java.util.List<java.util.List<java.lang.Double>> getHtoOWeightMatrix()
          Gets the hidden to output layer weight matrix.
 java.util.List<java.util.List<java.lang.Double>> getItoHWeightMatrix()
          Gets the input to hidden layer weight matrix.
 int getNumHidden()
          Gets the number of hidden nodes.
 java.util.List<java.lang.Double> getOutputThresholds()
          Gets the output layer thresholds.
 void hardcodeWeights(java.util.List<? extends java.util.List<java.lang.Double>> ItoH, java.util.List<? extends java.util.List<java.lang.Double>> HtoO, java.util.List<java.lang.Double> HiddenThreshold, java.util.Collection<java.lang.Double> OutputThreshold)
          Hard codes the weights of a neural net.
private  void initWeights()
          Initializes the weights to random values.
protected abstract  void modifyHiddenToOutput()
          Modifies the weights of the hidden to output layer.
protected abstract  void modifyInputToHidden()
          Modifies the weights of input to hidden layer.
private  double randomThresholds()
          Generates a random threshold.
private  double randomWeights()
          Generates a random weight.
 
Methods inherited from class clarion.system.AbstractTrainableImplicitModule
getSumSqErrors, setDesiredOutput, setDesiredOutput
 
Methods inherited from class clarion.system.AbstractImplicitModule
getChosenOutput, getInput, getNumInput, getNumOutput, getOutput, getOutput, getResponseTime, setChosenOutput, setInput, setInput, setInput
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Hidden

protected java.util.ArrayList<java.lang.Double> Hidden
The hidden layer.


HiddenThresholds

protected java.util.ArrayList<java.lang.Double> HiddenThresholds
The thresholds for the hidden layer.


OutputThresholds

protected java.util.ArrayList<java.lang.Double> OutputThresholds
The thresholds for the output layer.


InputToHiddenWeights

protected java.util.ArrayList<java.util.ArrayList<java.lang.Double>> InputToHiddenWeights
The input to hidden weight matrix.


HiddenToOutputWeights

protected java.util.ArrayList<java.util.ArrayList<java.lang.Double>> HiddenToOutputWeights
The hidden to output weight matrix.


GLOBAL_UPPER_INIT_WEIGHT

public static double GLOBAL_UPPER_INIT_WEIGHT
The upper bound for the initial weights.


GLOBAL_LOWER_INIT_WEIGHT

public static double GLOBAL_LOWER_INIT_WEIGHT
The low bound for the initial weights.


GLOBAL_UPPER_INIT_THRESHOLD

public static double GLOBAL_UPPER_INIT_THRESHOLD
The upper bound for the initial threshold.


GLOBAL_LOWER_INIT_THRESHOLD

public static double GLOBAL_LOWER_INIT_THRESHOLD
The low bound for the initial threshold.


UPPER_INIT_WEIGHT

public double UPPER_INIT_WEIGHT
The upper bound for the initial weights.


LOWER_INIT_WEIGHT

public double LOWER_INIT_WEIGHT
The low bound for the initial weights.


UPPER_INIT_THRESHOLD

public double UPPER_INIT_THRESHOLD
The upper bound for the initial threshold.


LOWER_INIT_THRESHOLD

public double LOWER_INIT_THRESHOLD
The low bound for the initial threshold.

Constructor Detail

AbstractNeuralNet

public AbstractNeuralNet(java.util.Collection<Dimension> InputSpace,
                         int NumHidden,
                         AbstractOutputChunkCollection<? extends AbstractOutputChunk> Outputs)
Initializes a neural network.

If this is being used as an implicit module in the ACS and you are using goals or specialized working memory chunks, remember that the input space must also contain all dimension-value pairs within those chunks that differ from the sensory information space.

Parameters:
InputSpace - A collection of dimension-value pairs to set as the input nodes.
NumHidden - The number of hidden nodes.
Outputs - The chunks to associate with the output layer.
Method Detail

getNumHidden

public int getNumHidden()
Gets the number of hidden nodes.

Returns:
The number of hidden nodes.

getItoHWeightMatrix

public java.util.List<java.util.List<java.lang.Double>> getItoHWeightMatrix()
Gets the input to hidden layer weight matrix. This is usually only used to collect the weights so the network can be hard coded at a later date. The list returned is unmodifiable and is meant for reporting the internal state only.

Returns:
the input to hidden layer weight matrix as an unmodifiable list containing unmodifiable lists (i.e. a 2x2 read only matrix).

getHtoOWeightMatrix

public java.util.List<java.util.List<java.lang.Double>> getHtoOWeightMatrix()
Gets the hidden to output layer weight matrix. This is usually only used to collect the weights so the network can be hard coded at a later date. The list returned is unmodifiable and is meant for reporting the internal state only.

Returns:
the hidden to output layer weight matrix as a list containing unmodifiable lists (i.e. a 2x2 read only matrix).

getHiddenThresholds

public java.util.List<java.lang.Double> getHiddenThresholds()
Gets the hidden layer thresholds. This is usually only used to collect the weights so the network can be hard coded at a later date. The list returned is unmodifiable and is meant for reporting the internal state only.

Returns:
An unmodifiable list representing the hidden layer thresholds for the network.

getOutputThresholds

public java.util.List<java.lang.Double> getOutputThresholds()
Gets the output layer thresholds. This is usually only used to collect the weights so the network can be hard coded at a later date. The list returned is unmodifiable and is meant for reporting the internal state only.

Returns:
An unmodifiable list representing the output layer thresholds for the network.

hardcodeWeights

public void hardcodeWeights(java.util.List<? extends java.util.List<java.lang.Double>> ItoH,
                            java.util.List<? extends java.util.List<java.lang.Double>> HtoO,
                            java.util.List<java.lang.Double> HiddenThreshold,
                            java.util.Collection<java.lang.Double> OutputThreshold)
Hard codes the weights of a neural net.

Parameters:
ItoH - The Input to Hidden layer weights.
HtoO - The Hidden to Output layer weights.
HiddenThreshold - The thresholds for the hidden layer.
OutputThreshold - The thresholds for the output layer.

forwardPass

public void forwardPass()
Calculates the output activations based on the current input. This method should not be called until the setInput method has been called setting the input activations to the current state.

Specified by:
forwardPass in class AbstractImplicitModule

initWeights

private void initWeights()
Initializes the weights to random values.


randomWeights

private double randomWeights()
Generates a random weight.

Returns:
A randomly selected weight.

randomThresholds

private double randomThresholds()
Generates a random threshold.

Returns:
A randomly selected threshold.

computeHiddenActivation

protected abstract void computeHiddenActivation()
Calculates the hidden derivative.


computeOutputActivation

protected abstract void computeOutputActivation()
Calculates the output derivative.


modifyHiddenToOutput

protected abstract void modifyHiddenToOutput()
Modifies the weights of the hidden to output layer.


modifyInputToHidden

protected abstract void modifyInputToHidden()
Modifies the weights of input to hidden layer.


backwardPass

public abstract void backwardPass()
Updates the neural network. This method should not be called until the setDesiredOutput method has been called.

Specified by:
backwardPass in interface InterfaceTrainable
Specified by:
backwardPass in class AbstractTrainableImplicitModule