|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.encog.neural.networks.layers.BasicLayer
public class BasicLayer
Basic functionality that most of the neural layers require. The basic layer is often used by itself to implement forward or recurrent layers. Other layer types are based on the basic layer as well. The following summarizes how basic layers calculate the output for a neural network. Example of a simple XOR network. Input: BasicLayer: 2 Neurons, null biasWeights, null biasActivation Hidden: BasicLayer: 2 Neurons, 2 biasWeights, 1 biasActivation Output: BasicLayer: 1 Neuron, 1 biasWeights, 1 biasActivation Input1Output and Input2Output are both provided. Synapse 1: Input to Hidden Hidden1Activation = (Input1Output * Input1->Hidden1Weight) + (Input2Output * Input2->Hidden1Weight) + (HiddenBiasActivation * Hidden1BiasWeight) Hidden1Output = calculate(Hidden1Activation, HiddenActivationFunction) Hidden2Activation = (Input1Output * Input1->Hidden2Weight) + (Input2Output * Input2->Hidden2Weight) + (HiddenBiasActivation * Hidden2BiasWeight) Hidden2Output = calculate(Hidden2Activation, HiddenActivationFunction) Synapse 2: Hidden to Output Output1Activation = (Hidden1Output * Hidden1->Output1Weight) + (Hidden2Output * Hidden2->Output1Weight) + (OutputBiasActivation * Output1BiasWeight) Output1Output = calculate(Output1Activation, OutputActivationFunction)
| Constructor Summary | |
|---|---|
BasicLayer()
Default constructor, mainly so the workbench can easily create a default layer. |
|
BasicLayer(ActivationFunction activationFunction,
boolean hasBias,
int neuronCount)
Construct this layer with a non-default activation function, also determine if a bias is desired or not. |
|
BasicLayer(int neuronCount)
Construct this layer with a sigmoid activation function. |
|
| Method Summary | |
|---|---|
void |
addNext(Layer next)
Add a layer as the next layer. |
void |
addNext(Layer next,
SynapseType type)
Add a layer to this layer. |
void |
addSynapse(Synapse synapse)
Add a synapse to the list of outbound synapses. |
int |
compareTo(Layer other)
|
NeuralData |
compute(NeuralData pattern)
Compute the outputs for this layer given the input pattern. |
Persistor |
createPersistor()
Create a persistor for this layer. |
ActivationFunction |
getActivationFunction()
|
double |
getBiasActivation()
Most layer types will default this value to one. |
double |
getBiasWeight(int index)
Get an bias weight value. |
double[] |
getBiasWeights()
|
EncogCollection |
getCollection()
|
String |
getDescription()
|
int |
getID()
|
String |
getName()
|
BasicNetwork |
getNetwork()
|
int |
getNeuronCount()
Get the neuron count for this layer. |
List<Synapse> |
getNext()
Get a list of all of the outbound synapse connections from this layer. |
Collection<Layer> |
getNextLayers()
|
int |
getX()
|
int |
getY()
|
boolean |
hasBias()
|
boolean |
isConnectedTo(Layer layer)
Determine if this layer is connected to another layer. |
boolean |
isSelfConnected()
|
void |
process(NeuralData pattern)
Process the input pattern. |
NeuralData |
recur()
Get the output from this layer when called in a recurrent manor. |
void |
setActivationFunction(ActivationFunction f)
Set the activation function for this layer. |
void |
setBiasActivation(double activation)
Set the bias activation. |
void |
setBiasWeight(int index,
double d)
Set an individual bias weight value. |
void |
setBiasWeights(double[] d)
Set the bias array. |
void |
setCollection(EncogCollection collection)
Not used, layers do not belong to collections. |
void |
setDescription(String description)
Set the description of this object. |
void |
setID(int id)
Set the id for this layer. |
void |
setName(String name)
Set the name of this object. |
void |
setNetwork(BasicNetwork network)
Set the network for this layer. |
void |
setNeuronCount(int neuronCount)
Set the neuron count. |
void |
setX(int x)
Set the x coordinate for this layer. |
void |
setY(int y)
Set the y coordinate for this layer. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public BasicLayer()
public BasicLayer(ActivationFunction activationFunction,
boolean hasBias,
int neuronCount)
activationFunction - The activation function to use.neuronCount - How many neurons in this layer.hasBias - True if this layer has a bias.public BasicLayer(int neuronCount)
neuronCount - How many neurons in this layer.| Method Detail |
|---|
public void addNext(Layer next)
addNext in interface Layernext - THe next layer.
public void addNext(Layer next,
SynapseType type)
Layer
addNext in interface Layernext - The next layer to add.type - The synapse type to use for this layer.public void addSynapse(Synapse synapse)
addSynapse in interface Layersynapse - The synapse to add.public int compareTo(Layer other)
compareTo in interface Comparable<Layer>public NeuralData compute(NeuralData pattern)
compute in interface Layerpattern - The input pattern.
public Persistor createPersistor()
createPersistor in interface EncogPersistedObjectpublic ActivationFunction getActivationFunction()
getActivationFunction in interface Layerpublic String getDescription()
getDescription in interface EncogPersistedObjectpublic int getID()
getID in interface Layerpublic String getName()
getName in interface EncogPersistedObjectpublic BasicNetwork getNetwork()
getNetwork in interface Layerpublic int getNeuronCount()
getNeuronCount in interface Layerpublic List<Synapse> getNext()
Layer
getNext in interface Layerpublic Collection<Layer> getNextLayers()
getNextLayers in interface Layerpublic double[] getBiasWeights()
getBiasWeights in interface Layerpublic double getBiasWeight(int index)
getBiasWeight in interface Layerindex - The bias value to get.
public int getX()
getX in interface Layerpublic int getY()
getY in interface Layerpublic boolean hasBias()
hasBias in interface Layerpublic boolean isConnectedTo(Layer layer)
isConnectedTo in interface Layerlayer - A layer to check and see if this layer is connected to.
public boolean isSelfConnected()
public void process(NeuralData pattern)
process in interface Layerpattern - The input to this layer.public NeuralData recur()
recur in interface Layerpublic void setActivationFunction(ActivationFunction f)
setActivationFunction in interface Layerf - The activation function.public void setDescription(String description)
EncogPersistedObject
setDescription in interface EncogPersistedObjectdescription - the description to setpublic void setID(int id)
setID in interface Layerid - The id for this layer.public void setName(String name)
EncogPersistedObject
setName in interface EncogPersistedObjectname - the name to setpublic void setNetwork(BasicNetwork network)
setNetwork in interface Layernetwork - The network for this layer.public void setNeuronCount(int neuronCount)
setNeuronCount in interface LayerneuronCount - The new neuron count.public void setBiasWeights(double[] d)
setBiasWeights in interface Layerd - The new bias weight array.
public void setBiasWeight(int index,
double d)
setBiasWeight in interface Layerindex - The index of the bias weight value.d - The new bias weight value.public void setX(int x)
setX in interface Layerx - The x-coordinate.public void setY(int y)
setY in interface Layery - The y-coordinate.public String toString()
toString in class Objectpublic double getBiasActivation()
Layer
getBiasActivation in interface Layerpublic void setBiasActivation(double activation)
setBiasActivation in interface Layeractivation - The activation.public EncogCollection getCollection()
getCollection in interface EncogPersistedObjectpublic void setCollection(EncogCollection collection)
setCollection in interface EncogPersistedObjectcollection - Not used.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||