Package ann4j
Class Neuron
java.lang.Object
ann4j.Neuron
- All Implemented Interfaces:
Observable
-
Field Summary
FieldsModifier and TypeFieldDescriptiondoubledoubleintint(package private) double -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLeftConnections(Connection connection) This function adds a connection to the leftConnections list.voidaddRightConnections(Connection connection) This function adds a connection to the rightConnections listvoidThe neuron first sets its delta, then backpropagates through all of its left connections, and then changes its biasvoidderegisterObserver(NeuronObserver neuronObserver) Deregisters the observer from the observablevoidexclude()This function sets the value of the isIncluded variable to false, after which it wont be included in forward propagationvoidThe activation of the neuron is set to the rectified value of the weighted sum of the left connections plus the biasdoubleThis function returns the activation of the neurondoublegetBias()This function returns the bias of the neurondoublegetDelta()This function returns the value of the delta variableintThis function returns the layer number of the neuronintThis function returns the number of neurons in the layerdoubleIt calculates the weighted sum of the left connections of the neuronvoidinclude()This function sets the isIncluded variable to true after which it will be included in forward propagationvoidnotifyObservers(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.voidregisterObserver(Observer observer) Register an observer to be notified when the data changes.voidThe function `relevancePropagate()` is called on the `myBehaviour` object, which is of type `Behaviour`, and the `this` object is passed as an argumentvoidsetActivation(double activation) This function sets the activation of the neuron to the value passed in as a parametervoidsetBehaviour(NeuronBehaviour myBehaviour) This function sets the behaviour of the neuron to the behaviour passed in as a parameter.voidsetDelta()The delta difference of the neuron in layer has been changedvoidsetLayerNum(int layerNum) This function sets the layer number of the neuronvoidsetNeuronNum(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:
notifyObserversin interfaceObservable- Parameters:
info- The information that is being passed to the observers.
-
registerObserver
Description copied from interface:ObservableRegister an observer to be notified when the data changes.- Specified by:
registerObserverin 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:ObservableDeregisters the observer from the observable- Specified by:
deregisterObserverin interfaceObservable- Parameters:
neuronObserver- The observer to be deregistered.
-