org.neuroph.core
Class Layer
- java.lang.Object
-
- org.neuroph.core.Layer
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Iterable<Neuron>
- Direct Known Subclasses:
- CompetitiveLayer, FeatureMapLayer, FeatureMapsLayer, InputLayer
public class Layer extends java.lang.Object implements java.lang.Iterable<Neuron>, java.io.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, ...).
- See Also:
Neuron, Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description Layer()Creates an instance of empty LayerLayer(int neuronsCount)Creates an instance of empty Layer for specified number of neuronsLayer(int neuronsCount, NeuronProperties neuronProperties)Creates an instance of Layer with the specified number of neurons with specified neuron properties
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddNeuron(int index, Neuron neuron)Adds specified neuron to this layer,at specified index position Throws IllegalArgumentException if neuron is null, or index is illegal value (index<0 or index>neuronsCount)voidaddNeuron(Neuron neuron)Adds specified neuron to this layervoidcalculate()Performs calculaton for all neurons in this layerjava.lang.StringgetLabel()Get layer labelNeurongetNeuronAt(int index)Returns neuron at specified index position in this layerjava.util.List<Neuron>getNeurons()Returns array neurons in this layer as arrayintgetNeuronsCount()Returns number of neurons in this layerNeuralNetworkgetParentNetwork()Returns reference to parent networkintindexOf(Neuron neuron)Returns the index position in layer for the specified neuronvoidinitializeWeights(double value)Initialize connection weights for the whole layer to to specified valuebooleanisEmpty()java.util.Iterator<Neuron>iterator()voidremoveAllNeurons()voidremoveNeuron(Neuron neuron)Removes neuron from layervoidremoveNeuronAt(int index)Removes neuron at specified index position in this layervoidreset()Resets the activation and input levels for all neurons in this layervoidsetLabel(java.lang.String label)Set layer labelvoidsetNeuron(int index, Neuron neuron)Sets (replace) the neuron at specified position in layervoidsetParentNetwork(NeuralNetwork parent)Sets reference on parent network
-
-
-
Constructor Detail
-
Layer
public Layer()
Creates an instance of empty Layer
-
Layer
public Layer(int neuronsCount)
Creates an instance of empty Layer for specified number of neurons- Parameters:
neuronsCount- number of neurons in this 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 layerneuronProperties- properties of neurons in layer
-
-
Method Detail
-
setParentNetwork
public final void setParentNetwork(NeuralNetwork parent)
Sets reference on parent network- Parameters:
parent- parent network
-
getParentNetwork
public final NeuralNetwork getParentNetwork()
Returns reference to parent network- Returns:
- reference on parent neural network
-
getNeurons
public final java.util.List<Neuron> getNeurons()
Returns array neurons in this layer as array- 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 Throws IllegalArgumentException if neuron is null, or index is illegal value (index<0 or index>neuronsCount)- Parameters:
neuron- neuron to addindex- index position at which neuron should be added
-
setNeuron
public final void setNeuron(int index, Neuron neuron)Sets (replace) the neuron at specified position in layer- Parameters:
index- index position to set/replaceneuron- new Neuron object to set
-
removeNeuron
public final void removeNeuron(Neuron neuron)
Removes neuron from layer- Parameters:
neuron- neuron to remove
-
removeNeuronAt
public final void removeNeuronAt(int index)
Removes neuron at specified index position in this layer- Parameters:
index- index position of neuron to remove
-
removeAllNeurons
public final 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
-
initializeWeights
public void initializeWeights(double value)
Initialize connection weights for the whole layer to to specified value- Parameters:
value- the weight value
-
getLabel
public java.lang.String getLabel()
Get layer label- Returns:
- layer label
-
setLabel
public void setLabel(java.lang.String label)
Set layer label- Parameters:
label- layer label to set
-
isEmpty
public boolean isEmpty()
-
-
DMelt 3.0 © DataMelt by jWork.ORG