com.penguinwerks.jodene
Class Neuron

java.lang.Object
  extended bycom.penguinwerks.jodene.Neuron
All Implemented Interfaces:
java.io.Serializable

public class Neuron
extends java.lang.Object
implements java.io.Serializable

A neuron is a basic processing unit in the network. It maintains inputs, weights, and the feedback from training. When all the inputs have arrived at the neuron, it sends a signal down all its output axons. When all the necessary feedback arrives at the neuron, the neuron propagates the feedback to its input neurons.

Author:
Paul Hoehne
See Also:
Serialized Form

Constructor Summary
protected Neuron()
           
  Neuron(java.lang.String name)
          Constructor - requires a name which needs to be unique for the network.
 
Method Summary
 void addInputAxon(Axon axon)
          Add a new input axon to the neuron.
 void addOutputAxon(Axon axon)
          Adds a new output axon to the neuron.
 void adjustWeights()
          Adjust the weights.
 java.lang.String getName()
          Returns the name of this neuron.
 double getOutputValue()
          Returns the output value for this neuron.
 NeuronTraining getTrainer()
          Returns the affiliated neuron trainer.
 void receiveFeedback(double val, Axon source)
          Receives feedback from subsequent layer neurons.
 void receiveSignal(Axon firingAxon, double val)
          This receives an input signal from the input axon.
 void setActivationFunction(ActivationFunction function)
          Sets the activation function used by this neuron.
 void setError(java.lang.Double actual, java.lang.Double expected)
          Set the error using the actual and expected values.
 void setInput(double val)
          If this neuron is an input neuron, then the output value is set by the neural network and the results are propagated to the output axons.
 void setNeuralTrainer(NeuronTraining trainer)
          Set the neuron trainer for this neuron.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Neuron

protected Neuron()

Neuron

public Neuron(java.lang.String name)
Constructor - requires a name which needs to be unique for the network.

Parameters:
name - The name of this neuron.
Method Detail

getName

public java.lang.String getName()
Returns the name of this neuron.

Returns:
Returns the name.

addInputAxon

public void addInputAxon(Axon axon)
Add a new input axon to the neuron. This will adjust the weights and inputs appropriately. Since this is normally used in neural construction - it re-randomizes the weights.

Parameters:
axon - The new input Axon.

setActivationFunction

public void setActivationFunction(ActivationFunction function)
Sets the activation function used by this neuron. The default activation function is the Sigmoid activation function. The activation function must implement the ActivationFunction interface.

Parameters:
function - The activation function.

addOutputAxon

public void addOutputAxon(Axon axon)
Adds a new output axon to the neuron. When the neuron fires, all the output axons are fired with the output value.

Parameters:
axon - The new axon.

receiveSignal

public void receiveSignal(Axon firingAxon,
                          double val)
This receives an input signal from the input axon. It then initializes the set of missing inputs (if necessary) with the ids of the input axons. If the axon is one of the axons that has not sent its signal, it is removed from the set of missing axons and the input value is stored. If the size of the missing input set drops to zero, the output value is calculate, and the neuron is fired.

Parameters:
firingAxon - The axon sending signal.
val - The value firing into this neuron.

setInput

public void setInput(double val)
If this neuron is an input neuron, then the output value is set by the neural network and the results are propagated to the output axons.

Parameters:
val - The input value.

getOutputValue

public double getOutputValue()
Returns the output value for this neuron. Usually called for output neurons by the neural network.

Returns:
The output value.

setError

public void setError(java.lang.Double actual,
                     java.lang.Double expected)
Set the error using the actual and expected values. This operates on the output nodes.

Parameters:
actual - The actual values obtained.
expected - The expected values from an example.

receiveFeedback

public void receiveFeedback(double val,
                            Axon source)
Receives feedback from subsequent layer neurons. As error information percolates back, the neuron will calculate its delta and partials.

Parameters:
val - The feedback value.
source - The axon sending the feedback.

setNeuralTrainer

public void setNeuralTrainer(NeuronTraining trainer)
Set the neuron trainer for this neuron.

Parameters:
trainer - The neuron trainer.

getTrainer

public NeuronTraining getTrainer()
Returns the affiliated neuron trainer.

Returns:
The neuron trainer attached to this neuron.

adjustWeights

public void adjustWeights()
Adjust the weights.