Package ann4j
Class Neuron
java.lang.Object
ann4j.Neuron
- All Implemented Interfaces:
Observable
-
Field Summary
Modifier and TypeFieldDescriptiondouble
double
int
int
(package private) double
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addLeftConnections
(Connection connection) This function adds a connection to the leftConnections list.void
addRightConnections
(Connection connection) This function adds a connection to the rightConnections listvoid
The neuron first sets its delta, then backpropagates through all of its left connections, and then changes its biasvoid
deregisterObserver
(NeuronObserver neuronObserver) Deregisters the observer from the observablevoid
exclude()
This function sets the value of the isIncluded variable to false, after which it wont be included in forward propagationvoid
The activation of the neuron is set to the rectified value of the weighted sum of the left connections plus the biasdouble
This function returns the activation of the neurondouble
getBias()
This function returns the bias of the neurondouble
getDelta()
This function returns the value of the delta variableint
This function returns the layer number of the neuronint
This function returns the number of neurons in the layerdouble
It calculates the weighted sum of the left connections of the neuronvoid
include()
This function sets the isIncluded variable to true after which it will be included in forward propagationvoid
notifyObservers
(String info) For each observer in the observerList, call the update function of that observer, passing in the info and this neuron, which will be typecasted later.void
registerObserver
(Observer observer) Register an observer to be notified when the data changes.void
The function `relevancePropagate()` is called on the `myBehaviour` object, which is of type `Behaviour`, and the `this` object is passed as an argumentvoid
setActivation
(double activation) This function sets the activation of the neuron to the value passed in as a parametervoid
setBehaviour
(NeuronBehaviour myBehaviour) This function sets the behaviour of the neuron to the behaviour passed in as a parameter.void
setDelta()
The delta difference of the neuron in layer has been changedvoid
setLayerNum
(int layerNum) This function sets the layer number of the neuronvoid
setNeuronNum
(int neuronNum) This function sets the number of neurons in the layertoString()
The toString() function returns a string representation of the object
-
Field Details
-
observerList
-
neuronNum
public int neuronNum -
layerNum
public int layerNum -
leftConnections
-
rightConnections
-
bias
public double bias -
delta
public double delta -
myBehaviour
-
relevance
double relevance
-
-
Constructor Details
-
Neuron
public Neuron()
-
-
Method Details
-
getActivation
public double getActivation()This function returns the activation of the neuron- Returns:
- The activation value of the neuron.
-
setActivation
public void setActivation(double activation) This function sets the activation of the neuron to the value passed in as a parameter- Parameters:
activation
- The activation of the neuron.
-
setBehaviour
This function sets the behaviour of the neuron to the behaviour passed in as a parameter.- Parameters:
myBehaviour
- The behaviour of the neuron.
-
setLayerNum
public void setLayerNum(int layerNum) This function sets the layer number of the neuron- Parameters:
layerNum
- The number of layers in the neural network.
-
getLayerNum
public int getLayerNum()This function returns the layer number of the neuron- Returns:
- The layerNum variable is being returned.
-
setNeuronNum
public void setNeuronNum(int neuronNum) This function sets the number of neurons in the layer- Parameters:
neuronNum
- The number of neurons in the layer.
-
getNeuronNum
public int getNeuronNum()This function returns the number of neurons in the layer- Returns:
- The number of neurons in the layer.
-
addLeftConnections
This function adds a connection to the leftConnections list.- Parameters:
connection
- The connection to add to the list of connections.
-
addRightConnections
This function adds a connection to the rightConnections list- Parameters:
connection
- The connection to add to the list of connections.
-
getWeightedSum
public double getWeightedSum()It calculates the weighted sum of the left connections of the neuron- Returns:
- The weighted sum of the left connections.
-
getBias
public double getBias()This function returns the bias of the neuron- Returns:
- The bias of the neuron.
-
forwardPropagate
public void forwardPropagate()The activation of the neuron is set to the rectified value of the weighted sum of the left connections plus the bias -
getDelta
public double getDelta()This function returns the value of the delta variable- Returns:
- The value of the variable delta.
-
backwardPropagate
public void backwardPropagate()The neuron first sets its delta, then backpropagates through all of its left connections, and then changes its bias -
setDelta
public void setDelta()The delta difference of the neuron in layer has been changed -
toString
The toString() function returns a string representation of the object -
relevancePropagate
public void relevancePropagate()The function `relevancePropagate()` is called on the `myBehaviour` object, which is of type `Behaviour`, and the `this` object is passed as an argument -
notifyObservers
For each observer in the observerList, call the update function of that observer, passing in the info and this neuron, which will be typecasted later.- Specified by:
notifyObservers
in interfaceObservable
- Parameters:
info
- The information that is being passed to the observers.
-
registerObserver
Description copied from interface:Observable
Register an observer to be notified when the data changes.- Specified by:
registerObserver
in interfaceObservable
- Parameters:
observer
- The observer to register.
-
exclude
public void exclude()This function sets the value of the isIncluded variable to false, after which it wont be included in forward propagation -
include
public void include()This function sets the isIncluded variable to true after which it will be included in forward propagation -
deregisterObserver
Description copied from interface:Observable
Deregisters the observer from the observable- Specified by:
deregisterObserver
in interfaceObservable
- Parameters:
neuronObserver
- The observer to be deregistered.
-