Class NeuralConnection
java.lang.Object
weka.classifiers.functions.neural.NeuralConnection
- All Implemented Interfaces:
Serializable
,RevisionHandler
- Direct Known Subclasses:
NeuralNode
Abstract unit in a NeuralNetwork.
- Version:
- $Revision: 8034 $
- Author:
- Malcolm Ware (mfw4@cs.waikato.ac.nz)
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
This flag is set once the unit has a connection.static final int
This unit is an input unit.static final int
This unit is an output unit.static final int
This unit is a pure input unit.static final int
This unit is a pure output unit.static final int
This unit is not connected to any others. -
Constructor Summary
ConstructorDescriptionConstructs The unit with the basic connection information prepared for use. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Connects two units together.static boolean
Disconnects two units.void
drawHighlight
(Graphics g, int w, int h) Call this function to draw the node highlighted.void
drawInputLines
(Graphics g, int w, int h) Call this function to draw the nodes input connections.void
Call this function to draw the node.void
drawOutputLines
(Graphics g, int w, int h) Call this function to draw the nodes output connections.abstract double
errorValue
(boolean calculate) Call this to get the error value of this unit.getId()
int[]
Use this to get easy access to the input numbers.Use this to get easy access to the inputs.int
int
int[]
Use this to get easy access to the output numbers.Use this to get easy access to the outputs.int
getType()
double
getX()
double
getY()
boolean
Call this function to determine if the point at x,y is on the unit.abstract double
outputValue
(boolean calculate) Call this to get the output value of this unit.void
This function will remove all the inputs to this unit.void
This function will remove all outputs to this unit.abstract void
reset()
Call this to reset the unit for another run.abstract void
Call this to have the connection restore from the saved weights.abstract void
Call this to have the connection save the current weights.void
setType
(int t) void
setX
(double x) void
setY
(double y) 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 java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface weka.core.RevisionHandler
getRevision
-
Field Details
-
UNCONNECTED
public static final int UNCONNECTEDThis unit is not connected to any others.- See Also:
-
PURE_INPUT
public static final int PURE_INPUTThis unit is a pure input unit.- See Also:
-
PURE_OUTPUT
public static final int PURE_OUTPUTThis unit is a pure output unit.- See Also:
-
INPUT
public static final int INPUTThis unit is an input unit.- See Also:
-
OUTPUT
public static final int OUTPUTThis unit is an output unit.- See Also:
-
CONNECTED
public static final int CONNECTEDThis flag is set once the unit has a connection.- See Also:
-
-
Constructor Details
-
NeuralConnection
Constructs The unit with the basic connection information prepared for use.- Parameters:
id
- the unique id of the unit
-
-
Method Details
-
getId
- Returns:
- The identity string of this unit.
-
getType
public int getType()- Returns:
- The type of this unit.
-
setType
public void setType(int t) - Parameters:
t
- The new type of this unit.
-
reset
public abstract void reset()Call this to reset the unit for another run. It is expected by that this unit will call the reset functions of all input units to it. It is also expected that this will not be done if the unit has already been reset (or atleast appears to be). -
outputValue
public abstract double outputValue(boolean calculate) Call this to get the output value of this unit.- 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 abstract double errorValue(boolean calculate) Call this to get the error value of this unit.- 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.
-
saveWeights
public abstract void saveWeights()Call this to have the connection save the current weights. -
restoreWeights
public abstract void restoreWeights()Call this to have the connection restore from the saved weights. -
weightValue
public double weightValue(int n) Call this to get the weight value on a particular connection.- Parameters:
n
- The connection number to get the weight for, -1 if The threshold weight should be returned.- Returns:
- This function will default to return 1. If overridden, it should return 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.
-
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.- Parameters:
l
- The learning Rate to use.m
- The momentum to use.
-
getInputs
Use this to get easy access to the inputs. It is not advised to change the entries in this list (use the connecting and disconnecting functions to do that)- Returns:
- The inputs list.
-
getOutputs
Use this to get easy access to the outputs. It is not advised to change the entries in this list (use the connecting and disconnecting functions to do that)- Returns:
- The outputs list.
-
getInputNums
public int[] getInputNums()Use this to get easy access to the input numbers. It is not advised to change the entries in this list (use the connecting and disconnecting functions to do that)- Returns:
- The input nums list.
-
getOutputNums
public int[] getOutputNums()Use this to get easy access to the output numbers. It is not advised to change the entries in this list (use the connecting and disconnecting functions to do that)- Returns:
- The outputs list.
-
getX
public double getX()- Returns:
- the x coord.
-
getY
public double getY()- Returns:
- the y coord.
-
setX
public void setX(double x) - Parameters:
x
- The new value for it's x pos.
-
setY
public void setY(double y) - Parameters:
y
- The new value for it's y pos.
-
onUnit
Call this function to determine if the point at x,y is on the unit.- Parameters:
g
- The graphics context for font size info.x
- The x coord.y
- The y coord.w
- The width of the display.h
- The height of the display.- Returns:
- True if the point is on the unit, false otherwise.
-
drawNode
Call this function to draw the node.- Parameters:
g
- The graphics context.w
- The width of the drawing area.h
- The height of the drawing area.
-
drawHighlight
Call this function to draw the node highlighted.- Parameters:
g
- The graphics context.w
- The width of the drawing area.h
- The height of the drawing area.
-
drawInputLines
Call this function to draw the nodes input connections.- Parameters:
g
- The graphics context.w
- The width of the drawing area.h
- The height of the drawing area.
-
drawOutputLines
Call this function to draw the nodes output connections.- Parameters:
g
- The graphics context.w
- The width of the drawing area.h
- The height of the drawing area.
-
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. -
removeAllOutputs
public void removeAllOutputs()This function will remove all outputs to this unit. In doing so it will also terminate the connections at the other end. -
getNumInputs
public int getNumInputs()- Returns:
- The number of input connections.
-
getNumOutputs
public int getNumOutputs()- Returns:
- The number of output connections.
-
connect
Connects two units together.- Parameters:
s
- The source unit.t
- The target unit.- Returns:
- True if the units were connected, false otherwise.
-
disconnect
Disconnects two units.- Parameters:
s
- The source unit.t
- The target unit.- Returns:
- True if the units were disconnected, false if they weren't (probably due to there being no connection).
-