uchicago.src.sim.adaptation.neural
Class NeuralUtils

java.lang.Object
  extended by uchicago.src.sim.adaptation.neural.NeuralUtils

public class NeuralUtils
extends java.lang.Object

Some utility functions for creating neural networks.

Version:
$Revision: 1.3 $ $Date: 2005/08/12 16:13:29 $
Author:
Jerry Vos
See Also:
RepastNeuralWrapper

Method Summary
static RepastNeuralWrapper buildNetwork(int[] nodesPerLayer, java.lang.Class[] layerTypes, java.lang.Class[] synapseTypes)
          This builds a neural network using the specified parameters.
static RepastNeuralWrapper buildNetwork(int[] nodesPerLayer, java.lang.Class layerType, java.lang.Class synapseType)
          This builds a neural network with nodesPerLayer.length layers, each layer being an instance of layerType, and each layer connected by a synapse of type synapseType.
static org.joone.engine.Synapse linkLayers(org.joone.engine.Layer outLayer, org.joone.engine.Layer inLayer, java.lang.Class synapseType)
          Links two layers using the specified synapse type.
static RepastNeuralWrapper loadNetFromFile(java.lang.String fileName)
          This method creates a RepastNeuralWrapper that is wrapping a serialized Joone NeuralNet.
static void saveNetToFile(org.joone.net.NeuralNet net, java.lang.String fileName)
          Saves a NeuralNet to the specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

buildNetwork

public static RepastNeuralWrapper buildNetwork(int[] nodesPerLayer,
                                               java.lang.Class layerType,
                                               java.lang.Class synapseType)
                                        throws NeuralException
This builds a neural network with nodesPerLayer.length layers, each layer being an instance of layerType, and each layer connected by a synapse of type synapseType.

Parameters:
nodesPerLayer - the number of nodes in the layers
layerType - the type to make the layers
synapseType - the type to make the synapses
Returns:
the created network
Throws:
NeuralException - when there is an error creating the network
See Also:
buildNetwork(int[], Class[], Class[])

buildNetwork

public static RepastNeuralWrapper buildNetwork(int[] nodesPerLayer,
                                               java.lang.Class[] layerTypes,
                                               java.lang.Class[] synapseTypes)
                                        throws NeuralException,
                                               java.lang.IllegalArgumentException
This builds a neural network using the specified parameters. This network will have all the layers connected using the synapse types passed in. No input or output synapses will be attached to the layer, so you still must do this yourself.
This network will also have a teacher added to it, however, this teacher will NOT be attached as an output layer; it only will be added to the network.

Parameters:
nodesPerLayer - the number of nodes in each layer
layerTypes - the types to make the layers
synapseTypes - the types of the synapses connecting the layers
Returns:
the created network
Throws:
NeuralException - when there is an error instantiating the layers/synapses
java.lang.IllegalArgumentException - when (nodesPerLayer.length != layerTypes.length || layerTypes.length -1 != synapseTypes.length)

linkLayers

public static org.joone.engine.Synapse linkLayers(org.joone.engine.Layer outLayer,
                                                  org.joone.engine.Layer inLayer,
                                                  java.lang.Class synapseType)
                                           throws NeuralException
Links two layers using the specified synapse type.

Parameters:
outLayer - the layer the synapse is coming out of
inLayer - the layer the synapse is going into
synapseType - the type of the synapse
Returns:
the created synapse instance
Throws:
NeuralException - when there is an error instantiating the synapse

saveNetToFile

public static void saveNetToFile(org.joone.net.NeuralNet net,
                                 java.lang.String fileName)
                          throws NeuralException
Saves a NeuralNet to the specified file.

Parameters:
net - the neural network to save
fileName - the name of the file to save the network to
Throws:
NeuralException - when there is an error saving the network
See Also:
RepastNeuralWrapper.saveNetToFile(String), RepastNeuralWrapper#loadNetFromFile(String)

loadNetFromFile

public static RepastNeuralWrapper loadNetFromFile(java.lang.String fileName)
                                           throws NeuralException
This method creates a RepastNeuralWrapper that is wrapping a serialized Joone NeuralNet. In other words, this creates a wrapper around a predesigned NeuralNet.

Parameters:
fileName - the name of the serialized NeuralNet
Returns:
the created wrapper
Throws:
NeuralException - when there is an error loading the specified network