Neural Network Software

com.practicalstudies.neural
Class Neuron

java.lang.Object
  |
  +--com.practicalstudies.neural.Neuron
All Implemented Interfaces:
Node
Direct Known Subclasses:
BackpropagationNode

public class Neuron
extends java.lang.Object
implements Node

A framework class representing a neuron in an artificial neural network.

Author:
Michael Wax
See Also:
Node, WeightedConnection

Constructor Summary
Neuron(Adder adder, ActivationFunction activationFunction)
          Constructor.
 
Method Summary
 int addInputConnection(WeightedConnection inputConnection)
          Add an input connection to this neuron.
 int addOutputConnection(WeightedConnection outputConnection)
          Add an output connection to this neuron.
 double calculateActivation()
          Calculate the output of this neuron.
 void clearInputConnections()
          Remove all input connections from this neuron.
 void clearOutputConnections()
          Remove all output connections from this neuron.
 WeightedConnection getInputConnection(int index)
          Return a specific input connection to this neuron.
 java.util.List getInputConnections()
          Returns a List of WeightedConnections which are the input connections to this neuron.
 int getNumberInputConnections()
          Returns the number of input connections to this neuron.
 int getNumberOutputConnections()
          Returns the number of output connections from this neuron.
 double getOutput()
          Return the output of this neuron.
 WeightedConnection getOutputConnection(int index)
          Return a specific output connection to this neuron.
 java.util.List getOutputConnections()
          Returns a List of WeightedConnections which are the output connections to this neuron.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Neuron

public Neuron(Adder adder,
              ActivationFunction activationFunction)
Constructor.

Parameters:
adder - an Adder object for summing inputs to this neuron
activationFunction - an ActivationFunction for calculating the output of this neuron based on the inputs
Method Detail

getNumberInputConnections

public final int getNumberInputConnections()
Returns the number of input connections to this neuron.

Specified by:
getNumberInputConnections in interface Node

clearInputConnections

public final void clearInputConnections()
Remove all input connections from this neuron.

Specified by:
clearInputConnections in interface Node

addInputConnection

public int addInputConnection(WeightedConnection inputConnection)
Add an input connection to this neuron.

Specified by:
addInputConnection in interface Node
Parameters:
inputConnection - a WeightedConnection that will serve as an additional input connection to this neuron
Returns:
the number of input connections to this neuron, after the additional connection is added

getInputConnection

public WeightedConnection getInputConnection(int index)
Return a specific input connection to this neuron.

Specified by:
getInputConnection in interface Node
Parameters:
index - the ordinal number of the input connection, based on the order in which connections were to this neuron
Returns:
the WeightedConnection representing the connection requested

getInputConnections

public java.util.List getInputConnections()
Returns a List of WeightedConnections which are the input connections to this neuron.

Specified by:
getInputConnections in interface Node

getNumberOutputConnections

public final int getNumberOutputConnections()
Returns the number of output connections from this neuron.

Specified by:
getNumberOutputConnections in interface Node

clearOutputConnections

public final void clearOutputConnections()
Remove all output connections from this neuron.

Specified by:
clearOutputConnections in interface Node

addOutputConnection

public int addOutputConnection(WeightedConnection outputConnection)
Add an output connection to this neuron.

Specified by:
addOutputConnection in interface Node
Parameters:
outputConnection - a WeightedConnection that will serve as an additional output connection to this node
Returns:
the number of output connections to this node, after the additional connection is added

getOutputConnection

public WeightedConnection getOutputConnection(int index)
Return a specific output connection to this neuron.

Specified by:
getOutputConnection in interface Node
Parameters:
index - the ordinal number of the output connection, based on the order in which connections were to this neuron
Returns:
the WeightedConnection representing the connection requested

getOutputConnections

public java.util.List getOutputConnections()
Returns a List of WeightedConnections which are the output connections to this neuron.

Specified by:
getOutputConnections in interface Node

calculateActivation

public double calculateActivation()

Calculate the output of this neuron.

This method performs three actions:

Returns:
the output of this neuron

getOutput

public double getOutput()

Return the output of this neuron.

This method will not calculate the output; {@link #calculateActivation() calculateActivation should be called first to ensure that the output is correct. This method exists to avoid the need for repetitive (possibly costly) calculation of the output.

Specified by:
getOutput in interface Node
Returns:
the output of this neuron

PracticalStudies.com