Package ann4j

Class Neuron

java.lang.Object
ann4j.Neuron
All Implemented Interfaces:
Observable

public class Neuron extends Object implements Observable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    double
     
    double
     
    int
     
     
     
    int
     
     
    (package private) double
     
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This function adds a connection to the leftConnections list.
    void
    This function adds a connection to the rightConnections list
    void
    The neuron first sets its delta, then backpropagates through all of its left connections, and then changes its bias
    void
    Deregisters the observer from the observable
    void
    This function sets the value of the isIncluded variable to false, after which it wont be included in forward propagation
    void
    The activation of the neuron is set to the rectified value of the weighted sum of the left connections plus the bias
    double
    This function returns the activation of the neuron
    double
    This function returns the bias of the neuron
    double
    This function returns the value of the delta variable
    int
    This function returns the layer number of the neuron
    int
    This function returns the number of neurons in the layer
    double
    It calculates the weighted sum of the left connections of the neuron
    void
    This function sets the isIncluded variable to true after which it will be included in forward propagation
    void
    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
    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 argument
    void
    setActivation(double activation)
    This function sets the activation of the neuron to the value passed in as a parameter
    void
    This function sets the behaviour of the neuron to the behaviour passed in as a parameter.
    void
    The delta difference of the neuron in layer has been changed
    void
    setLayerNum(int layerNum)
    This function sets the layer number of the neuron
    void
    setNeuronNum(int neuronNum)
    This function sets the number of neurons in the layer
    The toString() function returns a string representation of the object

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • observerList

      public ArrayList<Observer> observerList
    • neuronNum

      public int neuronNum
    • layerNum

      public int layerNum
    • leftConnections

      public ArrayList<Connection> leftConnections
    • rightConnections

      public ArrayList<Connection> rightConnections
    • bias

      public double bias
    • delta

      public double delta
    • myBehaviour

      public NeuronBehaviour 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

      public void setBehaviour(NeuronBehaviour myBehaviour)
      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

      public void addLeftConnections(Connection connection)
      This function adds a connection to the leftConnections list.
      Parameters:
      connection - The connection to add to the list of connections.
    • addRightConnections

      public void addRightConnections(Connection connection)
      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

      public String toString()
      The toString() function returns a string representation of the object
      Overrides:
      toString in class Object
      Returns:
      The activation of the neuron.
    • 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

      public void 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.
      Specified by:
      notifyObservers in interface Observable
      Parameters:
      info - The information that is being passed to the observers.
    • registerObserver

      public void registerObserver(Observer observer)
      Description copied from interface: Observable
      Register an observer to be notified when the data changes.
      Specified by:
      registerObserver in interface Observable
      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

      public void deregisterObserver(NeuronObserver neuronObserver)
      Description copied from interface: Observable
      Deregisters the observer from the observable
      Specified by:
      deregisterObserver in interface Observable
      Parameters:
      neuronObserver - The observer to be deregistered.