The Encog Project

org.encog.neural.networks.structure
Class NeuralStructure

java.lang.Object
  extended by org.encog.neural.networks.structure.NeuralStructure
All Implemented Interfaces:
java.io.Serializable

public class NeuralStructure
extends java.lang.Object
implements java.io.Serializable

Holds "cached" information about the structure of the neural network. This is a very good performance boost since the neural network does not need to traverse itself each time a complete collection of layers or synapses is needed.

Author:
jheaton
See Also:
Serialized Form

Constructor Summary
NeuralStructure(BasicNetwork network)
          Construct a structure object for the specified network.
 
Method Summary
 void assignID()
          Assign an ID to every layer that does not already have one.
 void assignID(Layer layer)
          Assign an ID to the specified layer.
 int calculateSize()
          Calculate the size that an array should be to hold all of the weights and threshold values.
 boolean containsLayerType(java.lang.Class<?> type)
          Determine if the network contains a layer of the specified type.
 void finalizeStructure()
          Build the synapse and layer structure.
 Synapse findSynapse(Layer fromLayer, Layer toLayer, boolean required)
          Find the specified synapse, throw an error if it is required.
 java.util.List<Layer> getLayers()
           
 BasicNetwork getNetwork()
           
 int getNextID()
          Get the next layer id.
 java.util.Collection<Layer> getPreviousLayers(Layer targetLayer)
          Get the previous layers from the specified layer.
 java.util.List<Synapse> getPreviousSynapses(Layer targetLayer)
          Get the previous synapses.
 java.util.List<Synapse> getSynapses()
           
 java.util.List<java.lang.String> nameLayer(Layer layer)
          Obtain a name for the specified layer.
 void sort()
          Sort the layers and synapses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NeuralStructure

public NeuralStructure(BasicNetwork network)
Construct a structure object for the specified network.

Parameters:
network - The network to construct a structure for.
Method Detail

assignID

public void assignID()
Assign an ID to every layer that does not already have one.


assignID

public void assignID(Layer layer)
Assign an ID to the specified layer.

Parameters:
layer - The layer to get an ID assigned.

calculateSize

public int calculateSize()
Calculate the size that an array should be to hold all of the weights and threshold values.

Returns:
The size of the calculated array.

containsLayerType

public boolean containsLayerType(java.lang.Class<?> type)
Determine if the network contains a layer of the specified type.

Parameters:
type - The layer type we are looking for.
Returns:
True if this layer type is present.

finalizeStructure

public void finalizeStructure()
Build the synapse and layer structure. This method should be called after you are done adding layers to a network, or change the network's logic property.


findSynapse

public Synapse findSynapse(Layer fromLayer,
                           Layer toLayer,
                           boolean required)
Find the specified synapse, throw an error if it is required.

Parameters:
fromLayer - The from layer.
toLayer - The to layer.
required - Is this required?
Returns:
The synapse, if it exists, otherwise null.

getLayers

public java.util.List<Layer> getLayers()
Returns:
The layers in this neural network.

getNetwork

public BasicNetwork getNetwork()
Returns:
The network this structure belongs to.

getNextID

public int getNextID()
Get the next layer id.

Returns:
The next layer id.

getPreviousLayers

public java.util.Collection<Layer> getPreviousLayers(Layer targetLayer)
Get the previous layers from the specified layer.

Parameters:
targetLayer - The target layer.
Returns:
The previous layers.

getPreviousSynapses

public java.util.List<Synapse> getPreviousSynapses(Layer targetLayer)
Get the previous synapses.

Parameters:
targetLayer - The layer to get the previous layers from.
Returns:
A collection of synapses.

getSynapses

public java.util.List<Synapse> getSynapses()
Returns:
All synapses in the neural network.

nameLayer

public java.util.List<java.lang.String> nameLayer(Layer layer)
Obtain a name for the specified layer.

Parameters:
layer - The layer to name.
Returns:
The name of this layer.

sort

public void sort()
Sort the layers and synapses.


The Encog Project