org.joone.structure
Class NetworkLayer

java.lang.Object
  extended by org.joone.engine.Layer
      extended by org.joone.structure.NetworkLayer
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable, Learnable, LearnableLayer, NeuralLayer, Inspectable

public class NetworkLayer
extends Layer

Wraps an existing joone network into a single layer. Probably should use something like a Synapse subclass in stead. Will probably run into trouble using Layer, which has a fixed number of input and output rows. Synapse at least has different input and outputs. Maybe should just implement input and output pattern listener.... Will revisit at some stage in the future, for now, Layer at least allows for easy testing. Joone treats input layers funny in that it adds a randomly initialised bias to the input before passing it on. Thus if you use a tanh layer and have say 3 inputs, y1, y2 and y3, then the values passed on to the next (hidden) layer will be [ tanh( y1 + b1 ), tanh( y2 + b2 ), tanh( y3 + b3 ) ] where b1 .. b3 are (random) biases. At the node level, we need more nodes to properly cater for this. New nodes z1 .. z3 are formed where z1 = y1 + b1 or, if e.g. a tanh layer, then z1 = tanh( y1 + b1 ). Thus z1 is a new node, fed from two connections, the first to the actual input and the next to the bias.

Author:
mg
See Also:
Serialized Form

Field Summary
protected  java.util.List<ContextNode> contextNodes
          List of all context nodes
protected  boolean fixed
          True if context node are in fixed state - useful when simulating
protected  java.util.List<InputNode> inputNodes
          List of input nodes
protected  DirectSynapse inputSynapse
          Synapse used to interrogate network
protected  java.util.List<Node> nodeList
          List of all nodes
protected  java.util.List<java.util.List<Node>> orderedNodes
          Ordered nodes
protected  java.util.List<Node> outputNodes
          List of output nodes
protected  int patternCount
          Pattern counter
 
Fields inherited from class org.joone.engine.Layer
bias, gradientInps, gradientOuts, inps, inputPatternListeners, learnable, learning, m_batch, monitor, myLearner, outputPatternListeners, outs, running, step, STOP_FLAG
 
Constructor Summary
NetworkLayer(NeuralNet network)
          Constructor
 
Method Summary
protected  void backward(double[] pattern)
          Reverse transfer function of the component.
protected  void forward(double[] pattern)
          Transfer function to recall a result on a trained net
 java.util.List<ContextNode> getContextNodes()
          Return a list of all context nodes
 double getDefaultState()
          Return the default state of a node in this layer, such as 0 for a tanh or 0.5 for a sigmoid layer
 double getDerivative(int i)
          Return the derivative with respect to the function value at a given index.
 java.util.List<InputNode> getInputNodes()
          Return a list of all input nodes
 double getMaximumState()
          Return maximum value of a node in this layer
 double getMinimumState()
          Return minimum value of a node in this layer
 java.util.List<Node> getNodeList()
          Return a list of all nodes
 java.util.List<java.util.List<Node>> getOrderedNodes()
          Return the ordered nodes
 java.util.List<Node> getOutputNodes()
          Return a list of output nodes
 double[] interrogate(double[] pattern)
          Interrogate the net
 boolean isFixed()
          See if the network is currently in fixed state
static void main(java.lang.String[] args)
          Test
protected  void setDimensions()
          Sets the dimension of the layer.
 void setFixed(boolean fixed)
          Set state of context nodes.
 
Methods inherited from class org.joone.engine.Layer
addInputSynapse, addNoise, addOutputSynapse, adjustSizeToFwdPattern, adjustSizeToRevPattern, check, checkInputEnabled, checkInputs, checkOutputs, copyInto, finalize, fireFwdGet, fireFwdPut, fireRevGet, fireRevPut, fwdRun, getAllInputs, getAllOutputs, getBias, getDimension, getLastGradientInps, getLastGradientOuts, getLastInputs, getLastOutputs, getLayerName, getLearner, getMonitor, getRows, getThreadMonitor, hasStepCounter, init, initLearner, InspectableTitle, Inspections, isInputLayer, isOutputLayer, isRunning, join, randomize, randomizeBias, randomizeWeights, removeAllInputs, removeAllOutputs, removeInputSynapse, removeListener, removeOutputSynapse, resetInputListeners, revRun, run, setAllInputs, setAllOutputs, setBias, setConnDimensions, setInputDimension, setInputSynapses, setLastInputs, setLastOutputs, setLayerName, setMonitor, setOutputDimension, setOutputSynapses, setRows, start, stop, sumBackInput, sumInput, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nodeList

protected java.util.List<Node> nodeList
List of all nodes


inputNodes

protected java.util.List<InputNode> inputNodes
List of input nodes


outputNodes

protected java.util.List<Node> outputNodes
List of output nodes


contextNodes

protected java.util.List<ContextNode> contextNodes
List of all context nodes


orderedNodes

protected java.util.List<java.util.List<Node>> orderedNodes
Ordered nodes


fixed

protected boolean fixed
True if context node are in fixed state - useful when simulating


patternCount

protected int patternCount
Pattern counter


inputSynapse

protected DirectSynapse inputSynapse
Synapse used to interrogate network

Constructor Detail

NetworkLayer

public NetworkLayer(NeuralNet network)
Constructor

Method Detail

getDefaultState

public double getDefaultState()
Description copied from class: Layer
Return the default state of a node in this layer, such as 0 for a tanh or 0.5 for a sigmoid layer

Specified by:
getDefaultState in class Layer

getMinimumState

public double getMinimumState()
Description copied from class: Layer
Return minimum value of a node in this layer

Specified by:
getMinimumState in class Layer

getMaximumState

public double getMaximumState()
Description copied from class: Layer
Return maximum value of a node in this layer

Specified by:
getMaximumState in class Layer

backward

protected void backward(double[] pattern)
                 throws JooneRuntimeException
Description copied from class: Layer
Reverse transfer function of the component.

Specified by:
backward in class Layer
Parameters:
pattern - input pattern on which to apply the transfer function
Throws:
JooneRuntimeException

forward

protected void forward(double[] pattern)
                throws JooneRuntimeException
Description copied from class: Layer
Transfer function to recall a result on a trained net

Specified by:
forward in class Layer
Parameters:
pattern - input pattern to which to apply the rtransfer function
Throws:
JooneRuntimeException

setDimensions

protected void setDimensions()
Description copied from class: Layer
Sets the dimension of the layer. Override to define how the internal buffers must be sized.

Specified by:
setDimensions in class Layer

getDerivative

public double getDerivative(int i)
Description copied from class: Layer
Return the derivative with respect to the function value at a given index. MG: Added for RTRL purposes

Specified by:
getDerivative in class Layer

setFixed

public void setFixed(boolean fixed)
Set state of context nodes. Context nodes are normally not fixed, so as new data passes through them they will update their internal state with that. If one wants to fix the network to a point in time and examine, without changing the internal state, the impact of different inputs, then one should fix the network. This message allows for that.


isFixed

public boolean isFixed()
See if the network is currently in fixed state


interrogate

public double[] interrogate(double[] pattern)
Interrogate the net


main

public static void main(java.lang.String[] args)
Test


getNodeList

public java.util.List<Node> getNodeList()
Return a list of all nodes


getInputNodes

public java.util.List<InputNode> getInputNodes()
Return a list of all input nodes


getOutputNodes

public java.util.List<Node> getOutputNodes()
Return a list of output nodes


getContextNodes

public java.util.List<ContextNode> getContextNodes()
Return a list of all context nodes


getOrderedNodes

public java.util.List<java.util.List<Node>> getOrderedNodes()
Return the ordered nodes



Submit Feedback to pmarrone@users.sourceforge.net