org.neuroph.core
Class Neuron
- java.lang.Object
-
- org.neuroph.core.Neuron
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
- Direct Known Subclasses:
- BiasNeuron, DelayedNeuron, InputNeuron, InputOutputNeuron, ThresholdNeuron
public class Neuron extends java.lang.Object implements java.io.Serializable, java.lang.CloneableBasic general neuron model according to McCulloch-Pitts neuron model. Different neuron models can be created by using different input and transfer functions for instances of this class, or by deriving from this class. The neuron is basic processing element of neural network. This class implements the following behaviour: output = transferFunction( inputFunction(inputConnections) )
- See Also:
InputFunction,TransferFunction, Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description Neuron()Creates an instance of Neuron with default settings: weighted sum input function and Step transfer function.Neuron(InputFunction inputFunction, TransferFunction transferFunction)Creates an instance of Neuron with the specified input and transfer functions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddInputConnection(Connection connection)Adds the specified input connectionvoidaddInputConnection(Neuron fromNeuron)Adds input connection from specified neuron.voidaddInputConnection(Neuron fromNeuron, double weightVal)Adds input connection with the given weight, from given neuronvoidcalculate()Calculates neuron's outputjava.lang.Objectclone()ConnectiongetConnectionFrom(Neuron fromNeuron)Gets input connection from the specified neuron * @param fromNeuron neuron connected to this neuron as inputdoublegetDelta()Returns delta (error) for this neuron.doublegetError()Returns error for this neuron.java.util.List<Connection>getInputConnections()Returns input connections for this neuronInputFunctiongetInputFunction()Returns input functionjava.lang.StringgetLabel()Returns label for this neurondoublegetNetInput()Returns total net inputjava.util.List<Connection>getOutConnections()Returns output connections from this neurondoublegetOutput()Returns neuron's outputLayergetParentLayer()Returns reference to parent layer for this neuronTransferFunctiongetTransferFunction()Returns transfer functionWeight[]getWeights()Returns weights vector of input connectionsbooleanhasInputConnectionFrom(Neuron neuron)booleanhasInputConnections()Returns true if there are input connections for this neuron, false otherwisebooleanhasOutputConnectionTo(Neuron toNeuron)Return true if this neuron has output connections to specified toNeuronvoidinitializeWeights(double value)Initialize weights for all input connections to specified valuevoidremoveAllConnections()voidremoveAllInputConnections()voidremoveAllOutputConnections()voidremoveInputConnectionFrom(Neuron fromNeuron)Removes input connection which is connected to specified neuronvoidremoveOutputConnectionTo(Neuron toNeuron)voidreset()Sets input and output activation levels to zerovoidsetDelta(double delta)Sets delta for this neuron.voidsetError(double error)Sets error for this neuron.voidsetInput(double input)Sets neuron's inputvoidsetInputFunction(InputFunction inputFunction)Sets input functionvoidsetLabel(java.lang.String label)Sets the label for this neuronvoidsetOutput(double output)Sets this neuron outputvoidsetParentLayer(Layer parent)Sets reference to parent layer for this neuron (layer in which the neuron is located)voidsetTransferFunction(TransferFunction transferFunction)Sets transfer function
-
-
-
Constructor Detail
-
Neuron
public Neuron()
Creates an instance of Neuron with default settings: weighted sum input function and Step transfer function. This is the basic McCulloch-Pitts neuron model.
-
Neuron
public Neuron(InputFunction inputFunction, TransferFunction transferFunction)
Creates an instance of Neuron with the specified input and transfer functions.- Parameters:
inputFunction- input function for this neurontransferFunction- transfer function for this neuron
-
-
Method Detail
-
calculate
public void calculate()
Calculates neuron's output
-
reset
public void reset()
Sets input and output activation levels to zero
-
setInput
public void setInput(double input)
Sets neuron's input- Parameters:
input- input value to set
-
getNetInput
public double getNetInput()
Returns total net input- Returns:
- total net input
-
getOutput
public double getOutput()
Returns neuron's output- Returns:
- neuron output
-
hasInputConnections
public boolean hasInputConnections()
Returns true if there are input connections for this neuron, false otherwise- Returns:
- true if there is input connection, false otherwise
-
hasOutputConnectionTo
public boolean hasOutputConnectionTo(Neuron toNeuron)
Return true if this neuron has output connections to specified toNeuron- Parameters:
toNeuron-- Returns:
- true if this neuron has output connections to specified toNeuron, false otherwise
-
hasInputConnectionFrom
public boolean hasInputConnectionFrom(Neuron neuron)
- Parameters:
neuron-- Returns:
-
addInputConnection
public void addInputConnection(Connection connection)
Adds the specified input connection- Parameters:
connection- input connection to add
-
addInputConnection
public void addInputConnection(Neuron fromNeuron)
Adds input connection from specified neuron.- Parameters:
fromNeuron- neuron to connect from
-
addInputConnection
public void addInputConnection(Neuron fromNeuron, double weightVal)
Adds input connection with the given weight, from given neuron- Parameters:
fromNeuron- neuron to connect fromweightVal- connection weight value
-
getInputConnections
public final java.util.List<Connection> getInputConnections()
Returns input connections for this neuron- Returns:
- input connections of this neuron
-
getOutConnections
public final java.util.List<Connection> getOutConnections()
Returns output connections from this neuron- Returns:
- output connections from this neuron
-
removeInputConnectionFrom
public void removeInputConnectionFrom(Neuron fromNeuron)
Removes input connection which is connected to specified neuron- Parameters:
fromNeuron- neuron which is connected as input
-
removeOutputConnectionTo
public void removeOutputConnectionTo(Neuron toNeuron)
-
removeAllInputConnections
public void removeAllInputConnections()
-
removeAllOutputConnections
public void removeAllOutputConnections()
-
removeAllConnections
public void removeAllConnections()
-
getConnectionFrom
public Connection getConnectionFrom(Neuron fromNeuron)
Gets input connection from the specified neuron * @param fromNeuron neuron connected to this neuron as input
-
setInputFunction
public void setInputFunction(InputFunction inputFunction)
Sets input function- Parameters:
inputFunction- input function for this neuron
-
setTransferFunction
public void setTransferFunction(TransferFunction transferFunction)
Sets transfer function- Parameters:
transferFunction- transfer function for this neuron
-
getInputFunction
public InputFunction getInputFunction()
Returns input function- Returns:
- input function
-
getTransferFunction
public TransferFunction getTransferFunction()
Returns transfer function- Returns:
- transfer function
-
setParentLayer
public void setParentLayer(Layer parent)
Sets reference to parent layer for this neuron (layer in which the neuron is located)- Parameters:
parent- reference on layer in which the cell is located
-
getParentLayer
public Layer getParentLayer()
Returns reference to parent layer for this neuron- Returns:
- parent layer for this neuron
-
getWeights
public Weight[] getWeights()
Returns weights vector of input connections- Returns:
- weights vector of input connections
-
getDelta
public double getDelta()
Returns delta (error) for this neuron. This is used by backpropagation learning rules.- Returns:
- error for this neuron which is set by learning rule
-
setDelta
public void setDelta(double delta)
Sets delta for this neuron. This is used by backpropagation learning rules.- Parameters:
delta- neuron delta
-
getError
public double getError()
Returns error for this neuron. This is used by supervised learing rules.- Returns:
- error for this neuron which is set by learning rule
-
setError
public void setError(double error)
Sets error for this neuron. This is used by supervised learing rules.- Parameters:
error- neuron error
-
setOutput
public void setOutput(double output)
Sets this neuron output- Parameters:
output- value to set
-
initializeWeights
public void initializeWeights(double value)
Initialize weights for all input connections to specified value- Parameters:
value- the weight value
-
getLabel
public java.lang.String getLabel()
Returns label for this neuron- Returns:
- label for this neuron
-
setLabel
public void setLabel(java.lang.String label)
Sets the label for this neuron- Parameters:
label- neuron label to set
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
-
DMelt 3.0 © DataMelt by jWork.ORG