weka.classifiers.functions.neural
Class NeuralNode

java.lang.Object
  extended byweka.classifiers.functions.neural.NeuralConnection
      extended byweka.classifiers.functions.neural.NeuralNode
All Implemented Interfaces:
java.io.Serializable

public class NeuralNode
extends NeuralConnection

This class is used to represent a node in the neuralnet.

Version:
$Revision: 1.5 $
Author:
Malcolm Ware (mfw4@cs.waikato.ac.nz)
See Also:
Serialized Form

Field Summary
private  double[] m_changeInWeights
          The change in the weights.
private  NeuralMethod m_methods
          Performs the operations for this node.
private  java.util.Random m_random
           
private  double[] m_weights
          The weights for each of the input connections, and the threshold.
 
Fields inherited from class weka.classifiers.functions.neural.NeuralConnection
CONNECTED, INPUT, m_id, m_inputList, m_inputNums, m_numInputs, m_numOutputs, m_outputList, m_outputNums, m_type, m_unitError, m_unitValue, m_weightsUpdated, m_x, m_y, OUTPUT, PURE_INPUT, PURE_OUTPUT, UNCONNECTED
 
Constructor Summary
NeuralNode(java.lang.String id, java.util.Random r, NeuralMethod m)
           
 
Method Summary
protected  void allocateInputs()
          This will allocate more space for input connection information if the arrays for this have been filled up.
protected  boolean connectInput(NeuralConnection i, int n)
          This will connect the specified unit to be an input to this unit.
protected  boolean disconnectInput(NeuralConnection i, int n)
          This will disconnect the input with the specific connection number From this node (only on this end however).
 double errorValue(boolean calculate)
          Call this to get the error value of this unit.
 double[] getChangeInWeights()
          call this function to get the chnage in weights array.
 NeuralMethod getMethod()
           
 double[] getWeights()
          call this function to get the weights array.
 double outputValue(boolean calculate)
          Call this to get the output value of this unit.
 void removeAllInputs()
          This function will remove all the inputs to this unit.
 void reset()
          Call this to reset the value and error for this unit, ready for the next run.
 void setMethod(NeuralMethod m)
          Set how this node should operate (note that the neural method has no internal state, so the same object can be used by any number of nodes.
 void updateWeights(double l, double m)
          Call this function to update the weight values at this unit.
 double weightValue(int n)
          Call this to get the weight value on a particular connection.
 
Methods inherited from class weka.classifiers.functions.neural.NeuralConnection
allocateOutputs, changeInputNum, changeOutputNum, connect, connectOutput, disconnect, disconnectOutput, drawHighlight, drawInputLines, drawNode, drawOutputLines, getId, getInputNums, getInputs, getNumInputs, getNumOutputs, getOutputNums, getOutputs, getType, getX, getY, onUnit, removeAllOutputs, setType, setX, setY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_weights

private double[] m_weights
The weights for each of the input connections, and the threshold.


m_changeInWeights

private double[] m_changeInWeights
The change in the weights.


m_random

private java.util.Random m_random

m_methods

private NeuralMethod m_methods
Performs the operations for this node. Currently this defines that the node is either a sigmoid or a linear unit.

Constructor Detail

NeuralNode

public NeuralNode(java.lang.String id,
                  java.util.Random r,
                  NeuralMethod m)
Parameters:
id - The string name for this node (used to id this node).
r - A random number generator used to generate initial weights.
m - The methods this node should use to update.
Method Detail

setMethod

public void setMethod(NeuralMethod m)
Set how this node should operate (note that the neural method has no internal state, so the same object can be used by any number of nodes.

Parameters:
m - The new method.

getMethod

public NeuralMethod getMethod()

outputValue

public double outputValue(boolean calculate)
Call this to get the output value of this unit.

Specified by:
outputValue in class NeuralConnection
Parameters:
calculate - True if the value should be calculated if it hasn't been already.
Returns:
The output value, or NaN, if the value has not been calculated.

errorValue

public double errorValue(boolean calculate)
Call this to get the error value of this unit.

Specified by:
errorValue in class NeuralConnection
Parameters:
calculate - True if the value should be calculated if it hasn't been already.
Returns:
The error value, or NaN, if the value has not been calculated.

reset

public void reset()
Call this to reset the value and error for this unit, ready for the next run. This will also call the reset function of all units that are connected as inputs to this one. This is also the time that the update for the listeners will be performed.

Specified by:
reset in class NeuralConnection

weightValue

public double weightValue(int n)
Call this to get the weight value on a particular connection.

Overrides:
weightValue in class NeuralConnection
Parameters:
n - The connection number to get the weight for, -1 if The threshold weight should be returned.
Returns:
The value for the specified connection or if -1 then it should return the threshold value. If no value exists for the specified connection, NaN will be returned.

getWeights

public double[] getWeights()
call this function to get the weights array. This will also allow the weights to be updated.

Returns:
The weights array.

getChangeInWeights

public double[] getChangeInWeights()
call this function to get the chnage in weights array. This will also allow the change in weights to be updated.

Returns:
The change in weights array.

updateWeights

public void updateWeights(double l,
                          double m)
Call this function to update the weight values at this unit. After the weights have been updated at this unit, All the input connections will then be called from this to have their weights updated.

Overrides:
updateWeights in class NeuralConnection
Parameters:
l - The learning rate to use.
m - The momentum to use.

connectInput

protected boolean connectInput(NeuralConnection i,
                               int n)
This will connect the specified unit to be an input to this unit.

Overrides:
connectInput in class NeuralConnection
Parameters:
i - The unit.
n - It's connection number for this connection.
Returns:
True if the connection was made, false otherwise.

allocateInputs

protected void allocateInputs()
This will allocate more space for input connection information if the arrays for this have been filled up.

Overrides:
allocateInputs in class NeuralConnection

disconnectInput

protected boolean disconnectInput(NeuralConnection i,
                                  int n)
This will disconnect the input with the specific connection number From this node (only on this end however).

Overrides:
disconnectInput in class NeuralConnection
Parameters:
i - The unit to disconnect.
n - The connection number at the other end, -1 if all the connections to this unit should be severed (not the same as removeAllInputs).
Returns:
True if the connection was removed, false if the connection was not found.

removeAllInputs

public void removeAllInputs()
This function will remove all the inputs to this unit. In doing so it will also terminate the connections at the other end.

Overrides:
removeAllInputs in class NeuralConnection