org.neuroph.core
Class Layer

java.lang.Object
  extended by org.neuroph.core.Layer
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CompetitiveLayer, InputLayer

public class Layer
extends Object
implements Serializable

 Layer of neurons in a neural network. The Layer is basic neuron container (a collection of neurons),
 and it provides methods for manipulating neurons (add, remove, get, set, calculate, randomize).
 

Author:
Zoran Sevarac
See Also:
Neuron, Serialized Form

Field Summary
protected  Neuron[] neurons
          Array of neurons (Neuron instances)
 
Constructor Summary
Layer()
          Creates an instance of empty Layer
Layer(int neuronsCount, NeuronProperties neuronProperties)
          Creates an instance of Layer with the specified number of neurons with specified neuron properties
 
Method Summary
 void addNeuron(int index, Neuron neuron)
          Adds specified neuron to this layer,at specified index position
 void addNeuron(Neuron neuron)
          Adds specified neuron to this layer
 void calculate()
          Performs calculaton for all neurons in this layer
 String getLabel()
          Get layer label
 Neuron getNeuronAt(int index)
          Returns neuron at specified index position in this layer
 Neuron[] getNeurons()
          Returns array of neurons in this layer
 int getNeuronsCount()
          Returns number of neurons in this layer
 NeuralNetwork getParentNetwork()
          Returns reference to parent network
 int indexOf(Neuron neuron)
          Returns the index position in layer for the specified neuron
 void initializeWeights(double value)
          Initialize connection weights for the whole layer to to specified value
 void randomizeWeights()
          Randomize input connection weights for all neurons in this layer
 void randomizeWeights(double minWeight, double maxWeight)
          Randomize input connection weights for all neurons in this layer within specified value range
 void randomizeWeights(Random generator)
          Initialize connection weights for all neurons in this layer using a random number generator
 void removeAllNeurons()
           
 void removeNeuron(Neuron neuron)
          Removes neuron from layer
 void removeNeuronAt(int index)
          Removes neuron at specified index position in this layer
 void reset()
          Resets the activation and input levels for all neurons in this layer
 void setLabel(String label)
          Set layer label
 void setNeuron(int index, Neuron neuron)
          Sets (replace) the neuron at specified position in layer
 void setParentNetwork(NeuralNetwork parent)
          Sets reference on parent network
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

neurons

protected Neuron[] neurons
Array of neurons (Neuron instances)

Constructor Detail

Layer

public Layer()
Creates an instance of empty Layer


Layer

public Layer(int neuronsCount,
             NeuronProperties neuronProperties)
Creates an instance of Layer with the specified number of neurons with specified neuron properties

Parameters:
neuronsCount - number of neurons in layer
neuronProperties - properties of neurons in layer
Method Detail

setParentNetwork

public void setParentNetwork(NeuralNetwork parent)
Sets reference on parent network

Parameters:
parent - parent network

getParentNetwork

public NeuralNetwork getParentNetwork()
Returns reference to parent network

Returns:
reference on parent neural network

getNeurons

public final Neuron[] getNeurons()
Returns array of neurons in this layer

Returns:
array of neurons in this layer

addNeuron

public final void addNeuron(Neuron neuron)
Adds specified neuron to this layer

Parameters:
neuron - neuron to add

addNeuron

public final void addNeuron(int index,
                            Neuron neuron)
Adds specified neuron to this layer,at specified index position

Parameters:
neuron - neuron to add
index - index position at which neuron should be added

setNeuron

public void setNeuron(int index,
                      Neuron neuron)
Sets (replace) the neuron at specified position in layer

Parameters:
index - index position to set/replace
neuron - new Neuron object to set

removeNeuron

public void removeNeuron(Neuron neuron)
Removes neuron from layer

Parameters:
neuron - neuron to remove

removeNeuronAt

public void removeNeuronAt(int index)
Removes neuron at specified index position in this layer

Parameters:
index - index position of neuron to remove

removeAllNeurons

public void removeAllNeurons()

getNeuronAt

public Neuron getNeuronAt(int index)
Returns neuron at specified index position in this layer

Parameters:
index - neuron index position
Returns:
neuron at specified index position

indexOf

public int indexOf(Neuron neuron)
Returns the index position in layer for the specified neuron

Parameters:
neuron - neuron object
Returns:
index position of specified neuron

getNeuronsCount

public int getNeuronsCount()
Returns number of neurons in this layer

Returns:
number of neurons in this layer

calculate

public void calculate()
Performs calculaton for all neurons in this layer


reset

public void reset()
Resets the activation and input levels for all neurons in this layer


randomizeWeights

public void randomizeWeights()
Randomize input connection weights for all neurons in this layer


randomizeWeights

public void randomizeWeights(double minWeight,
                             double maxWeight)
Randomize input connection weights for all neurons in this layer within specified value range


randomizeWeights

public void randomizeWeights(Random generator)
Initialize connection weights for all neurons in this layer using a random number generator

Parameters:
generator - the random number generator

initializeWeights

public void initializeWeights(double value)
Initialize connection weights for the whole layer to to specified value

Parameters:
value - the weight value

getLabel

public String getLabel()
Get layer label

Returns:
layer label

setLabel

public void setLabel(String label)
Set layer label

Parameters:
label - layer label to set


Copyright © 2012. All Rights Reserved.