The Encog Project

org.encog.neural.networks.layers
Class BasicLayer

java.lang.Object
  extended by org.encog.neural.networks.layers.BasicLayer
All Implemented Interfaces:
java.io.Serializable, Layer, EncogPersistedObject
Direct Known Subclasses:
FeedforwardLayer, HopfieldLayer, SOMLayer

public class BasicLayer
extends java.lang.Object
implements Layer, EncogPersistedObject, java.io.Serializable

Basic functionality that most of the neural layers require.

Author:
jheaton
See Also:
Serialized Form

Constructor Summary
BasicLayer(int neuronCount)
          Construct a basic layer with the specified neuron count.
 
Method Summary
 NeuralData compute(NeuralData pattern)
          This layer is too basic to know how to compute a pattern, it simply passes the pattern on.
 Persistor createPersistor()
          Create a persistor for this layer.
 java.lang.String getDescription()
           
 NeuralData getFire()
          Get the output array from the last time that the output of this layer was calculated.
 double getFire(int index)
          Get the output from an individual neuron.
 Matrix getMatrix()
          Get the weight and threshold matrix.
 int getMatrixSize()
          Get the size of the matrix, or zero if one is not defined.
 java.lang.String getName()
           
 int getNeuronCount()
          Get the neuron count for this layer.
 Layer getNext()
           
 Layer getPrevious()
           
 boolean hasMatrix()
          Determine if this layer has a matrix.
 boolean isHidden()
          Determine if this is a hidden layer.
 boolean isInput()
          Determine if this is an input layer.
 boolean isOutput()
          Determine if this is an output layer.
 void reset()
          Reset the weight matrix and threshold values to random numbers between -1 and 1.
 void setDescription(java.lang.String description)
           
 void setFire(int index, double f)
          Set the last output value for the specified neuron.
 void setFire(NeuralData fire)
          Set the fire data.
 void setMatrix(Matrix matrix)
          Assign a new weight and threshold matrix to this layer.
 void setName(java.lang.String name)
           
 void setNeuronCount(int count)
          Set the neuron count.
 void setNext(Layer next)
          Set the next layer.
 void setPrevious(Layer previous)
          Set the previous layer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicLayer

public BasicLayer(int neuronCount)
Construct a basic layer with the specified neuron count.

Parameters:
neuronCount - How many neurons does this layer have.
Method Detail

compute

public NeuralData compute(NeuralData pattern)
This layer is too basic to know how to compute a pattern, it simply passes the pattern on.

Specified by:
compute in interface Layer
Parameters:
pattern - The pattern to compute against.
Returns:
The input pattern is returned.

createPersistor

public Persistor createPersistor()
Create a persistor for this layer.

Specified by:
createPersistor in interface EncogPersistedObject
Returns:
The new persistor.

getDescription

public java.lang.String getDescription()
Specified by:
getDescription in interface EncogPersistedObject
Returns:
the description

getFire

public NeuralData getFire()
Get the output array from the last time that the output of this layer was calculated.

Specified by:
getFire in interface Layer
Returns:
The output array.

getFire

public double getFire(int index)
Get the output from an individual neuron.

Parameters:
index - The neuron specified.
Returns:
The output from the specified neuron.

getMatrix

public Matrix getMatrix()
Get the weight and threshold matrix.

Specified by:
getMatrix in interface Layer
Returns:
The weight and threshold matrix.

getMatrixSize

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

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

getName

public java.lang.String getName()
Specified by:
getName in interface EncogPersistedObject
Returns:
the name

getNeuronCount

public int getNeuronCount()
Get the neuron count for this layer.

Specified by:
getNeuronCount in interface Layer
Returns:
the neuronCount

getNext

public Layer getNext()
Specified by:
getNext in interface Layer
Returns:
the next layer.

getPrevious

public Layer getPrevious()
Specified by:
getPrevious in interface Layer
Returns:
the previous layer.

hasMatrix

public boolean hasMatrix()
Determine if this layer has a matrix.

Specified by:
hasMatrix in interface Layer
Returns:
True if this layer has a matrix.

isHidden

public boolean isHidden()
Determine if this is a hidden layer.

Specified by:
isHidden in interface Layer
Returns:
True if this is a hidden layer.

isInput

public boolean isInput()
Determine if this is an input layer.

Specified by:
isInput in interface Layer
Returns:
True if this is an input layer.

isOutput

public boolean isOutput()
Determine if this is an output layer.

Specified by:
isOutput in interface Layer
Returns:
True if this is an output layer.

reset

public void reset()
Reset the weight matrix and threshold values to random numbers between -1 and 1.

Specified by:
reset in interface Layer

setDescription

public void setDescription(java.lang.String description)
Specified by:
setDescription in interface EncogPersistedObject
Parameters:
description - the description to set

setFire

public void setFire(int index,
                    double f)
Set the last output value for the specified neuron.

Specified by:
setFire in interface Layer
Parameters:
index - The specified neuron.
f - The fire value for the specified neuron.

setFire

public void setFire(NeuralData fire)
Set the fire data.

Specified by:
setFire in interface Layer
Parameters:
fire - The fire data.

setMatrix

public void setMatrix(Matrix matrix)
Assign a new weight and threshold matrix to this layer.

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

setName

public void setName(java.lang.String name)
Specified by:
setName in interface EncogPersistedObject
Parameters:
name - the name to set

setNeuronCount

public void setNeuronCount(int count)
Set the neuron count.

Parameters:
count - How many neurons on this layer.

setNext

public void setNext(Layer next)
Set the next layer.

Specified by:
setNext in interface Layer
Parameters:
next - the next layer.

setPrevious

public void setPrevious(Layer previous)
Set the previous layer.

Specified by:
setPrevious in interface Layer
Parameters:
previous - the previous layer.

The Encog Project