org.encog.neural.networks.synapse.neat
Class NEATSynapse

java.lang.Object
  extended by org.encog.neural.networks.synapse.neat.NEATSynapse
All Implemented Interfaces:
Serializable, ContextClearable, Synapse, EncogPersistedObject

public class NEATSynapse
extends Object
implements Synapse, ContextClearable, Serializable

Implements a NEAT network as a synapse between two layers. In Encog, a NEAT network is created by using a NEATSynapse between an input and output layer. NEAT networks only have an input and an output layer. There are no actual hidden layers. Rather this synapse will evolve many hidden neurons that have connections that are not easily defined by layers. Connections can be feedforward, recurrent, or self-connected. NEAT networks relieve the programmer of the need to define the hidden layer structure of the neural network. The output from the neural network can be calculated normally or using a snapshot. The snapshot mode is slower, but it can be more accurate. The snapshot handles recurrent layers better, as it takes the time to loop through the network multiple times to "flush out" the recurrent links. NeuroEvolution of Augmenting Topologies (NEAT) is a genetic algorithm for the generation of evolving artificial neural networks. It was developed by Ken Stanley while at The University of Texas at Austin. http://www.cs.ucf.edu/~kstanley/

See Also:
Serialized Form

Constructor Summary
NEATSynapse()
          Default constructor.
NEATSynapse(BasicLayer fromLayer, BasicLayer toLayer, List<NEATNeuron> neurons, ActivationFunction activationFunction, int networkDepth)
          Construct a NEAT synapse.
NEATSynapse(Layer fromLayer, Layer toLayer)
          Construct a NEAT synapse.
 
Method Summary
 void clearContext()
          Clear any context from previous runs.
 Object clone()
           
 NeuralData compute(NeuralData input)
          Compute the output from this synapse.
 Persistor createPersistor()
          Create a persistor for this object.
 ActivationFunction getActivationFunction()
           
 EncogCollection getCollection()
           
 String getDescription()
           
 Layer getFromLayer()
           
 int getFromNeuronCount()
           
 Matrix getMatrix()
          Get the weight matrix.
 int getMatrixSize()
          Get the size of the matrix, or zero if one is not defined.
 String getName()
           
 int getNetworkDepth()
           
 List<NEATNeuron> getNeurons()
           
 Layer getToLayer()
           
 int getToNeuronCount()
           
 SynapseType getType()
           
 boolean isSelfConnected()
           
 boolean isSnapshot()
           
 boolean isTeachable()
           
 void setActivationFunction(ActivationFunction activationFunction)
          Set the activation function.
 void setCollection(EncogCollection collection)
           
 void setDescription(String description)
          Not used.
 void setFromLayer(Layer fromLayer)
          Set the from layer for this synapse.
 void setMatrix(Matrix matrix)
          Assign a new weight matrix to this layer.
 void setName(String name)
          Not used.
 void setSnapshot(boolean snapshot)
          Sets if snapshot is used.
 void setToLayer(Layer toLayer)
          Set the target layer from this synapse.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NEATSynapse

public NEATSynapse()
Default constructor.


NEATSynapse

public NEATSynapse(BasicLayer fromLayer,
                   BasicLayer toLayer,
                   List<NEATNeuron> neurons,
                   ActivationFunction activationFunction,
                   int networkDepth)
Construct a NEAT synapse.

Parameters:
fromLayer - The input layer.
toLayer - The output layer.
neurons - The neurons in this synapse.
activationFunction - The activation function to use.
networkDepth - The depth of the network.

NEATSynapse

public NEATSynapse(Layer fromLayer,
                   Layer toLayer)
Construct a NEAT synapse.

Parameters:
fromLayer - The input layer.
toLayer - The output layer.
Method Detail

clearContext

public void clearContext()
Clear any context from previous runs. This sets the activation of all neurons to zero.

Specified by:
clearContext in interface ContextClearable

clone

public Object clone()
Specified by:
clone in interface Synapse
Overrides:
clone in class Object
Returns:
A clone of this object.

compute

public NeuralData compute(NeuralData input)
Compute the output from this synapse.

Specified by:
compute in interface Synapse
Parameters:
input - The input to this synapse.
Returns:
The output from this synapse.

createPersistor

public Persistor createPersistor()
Description copied from interface: EncogPersistedObject
Create a persistor for this object.

Specified by:
createPersistor in interface EncogPersistedObject
Returns:
A persistor to load/save this type of synapse.

getActivationFunction

public ActivationFunction getActivationFunction()
Returns:
The activation function.

getDescription

public String getDescription()
Specified by:
getDescription in interface EncogPersistedObject
Returns:
null, this is not used.

getFromLayer

public Layer getFromLayer()
Specified by:
getFromLayer in interface Synapse
Returns:
The from layer.

getFromNeuronCount

public int getFromNeuronCount()
Specified by:
getFromNeuronCount in interface Synapse
Returns:
The neuron count from the "from layer".

getMatrix

public Matrix getMatrix()
Get the weight matrix. Not used for a NEAT synapse.

Specified by:
getMatrix in interface Synapse
Returns:
The weight matrix.

getMatrixSize

public int getMatrixSize()
Get the size of the matrix, or zero if one is not defined.

Specified by:
getMatrixSize in interface Synapse
Returns:
The size of the matrix.

getName

public String getName()
Specified by:
getName in interface EncogPersistedObject
Returns:
null, this is not used.

getNetworkDepth

public int getNetworkDepth()
Returns:
The network depth.

getNeurons

public List<NEATNeuron> getNeurons()
Returns:
The NEAT neurons.

getToLayer

public Layer getToLayer()
Specified by:
getToLayer in interface Synapse
Returns:
The "to layer".

getToNeuronCount

public int getToNeuronCount()
Specified by:
getToNeuronCount in interface Synapse
Returns:
The neuron count from the "to layer".

getType

public SynapseType getType()
Specified by:
getType in interface Synapse
Returns:
The type of synapse that this is.

isSelfConnected

public boolean isSelfConnected()
Specified by:
isSelfConnected in interface Synapse
Returns:
True if this is a self-connected synapse. That is, the from and to layers are the same.

isSnapshot

public boolean isSnapshot()
Returns:
True if snapshot is being used.

isTeachable

public boolean isTeachable()
Specified by:
isTeachable in interface Synapse
Returns:
True if the weights for this synapse can be modified.

setActivationFunction

public void setActivationFunction(ActivationFunction activationFunction)
Set the activation function.

Parameters:
activationFunction - The activation function.

setDescription

public void setDescription(String description)
Not used.

Specified by:
setDescription in interface EncogPersistedObject
Parameters:
description - Not used.

setFromLayer

public void setFromLayer(Layer fromLayer)
Set the from layer for this synapse.

Specified by:
setFromLayer in interface Synapse
Parameters:
fromLayer - The from layer for this synapse.

setMatrix

public void setMatrix(Matrix matrix)
Assign a new weight matrix to this layer. Not used by a NEAT network.

Specified by:
setMatrix in interface Synapse
Parameters:
matrix - The new matrix.

setName

public void setName(String name)
Not used.

Specified by:
setName in interface EncogPersistedObject
Parameters:
name - not used.

setSnapshot

public void setSnapshot(boolean snapshot)
Sets if snapshot is used.

Parameters:
snapshot - True if snapshot is used.

setToLayer

public void setToLayer(Layer toLayer)
Set the target layer from this synapse.

Specified by:
setToLayer in interface Synapse
Parameters:
toLayer - The target layer from this synapse.

getCollection

public EncogCollection getCollection()
Specified by:
getCollection in interface EncogPersistedObject

setCollection

public void setCollection(EncogCollection collection)
Specified by:
setCollection in interface EncogPersistedObject


Copyright © 2011. All Rights Reserved.