org.joone.engine
Class Synapse

java.lang.Object
  extended by org.joone.engine.Synapse
All Implemented Interfaces:
java.io.Serializable, InputPatternListener, Learnable, LearnableSynapse, NeuralElement, OutputPatternListener, Inspectable
Direct Known Subclasses:
AbstractTeacherSynapse, BufferedSynapse, ComparisonSynapse, DelaySynapse, DirectSynapse, FullSynapse, PatternForwardedSynapse, RbfInputSynapse, StreamInputSynapse, StreamOutputSynapse

public abstract class Synapse
extends java.lang.Object
implements InputPatternListener, OutputPatternListener, LearnableSynapse, java.io.Serializable, Inspectable

The Synapse is the connection element between two Layer objects. Its connections are represented by weights that transport the patterns from a layer to another. These weights are modified in the learning cycles, and represent the 'memory' of the trained neural net.

See Also:
Serialized Form

Field Summary
protected  Matrix array
           
protected  Pattern b_pattern
           
protected  int bitems
           
protected  double[] bouts
           
protected  int count
           
protected  boolean enabled
           
protected  java.lang.Object fwdLock
           
protected  double[] inps
           
protected  int items
           
protected  boolean learnable
          Contains true if for the current Synapse must be used a Learner instead of a built-in learning algorithm.
protected  int m_batch
           
protected  Pattern m_pattern
           
protected  Learner myLearner
           
protected  boolean notFirstTime
           
protected  boolean notFirstTimeB
           
protected  double[] outs
           
protected  java.lang.Object revLock
           
 
Constructor Summary
Synapse()
          The constructor
 
Method Summary
 void addNoise(double amplitude)
          Adds a noise to the weights of the synapse
protected abstract  void backward(double[] pattern)
          Funzione di TRAIN dell'elemento.
 boolean canCountSteps()
          Returns TRUE if the synapse calls the method nextStep() on the Monitor object when the fwdGet() method is called
 java.util.TreeSet check()
          Base for check messages.
protected abstract  void forward(double[] pattern)
          Recall function
 Pattern fwdGet()
          Returns the pattern coming from the previous layer during the recall phase
 void fwdPut(Pattern pattern)
          Method to put a pattern forward to the next layer
protected  java.lang.Object getFwdLock()
          Getter for property fwdLock.
 int getIgnoreBefore()
          Returns the number of the ignored cycles at beginning of each epoch.
 int getInputDimension()
          Returns the input dimension of the synapse.
 Learner getLearner()
          Returns the appropriate Learner object for this class depending on the Monitor.learningMode property value
 double getLearningRate()
          Returns the value of the learning rate
 double getMomentum()
          Returns the value of the momentum
 Monitor getMonitor()
          Returns the Monitor object attached to the synapse
 java.lang.String getName()
          Returns the name of the synapse
 int getOutputDimension()
          Returns the output dimension of the synapse.
protected  java.lang.Object getRevLock()
          Getter for property revLock.
 Matrix getWeights()
          Getter for the internal matrix of weights
 void init()
          Synapse's initialization.
 void initLearner()
          Initialize the Learner object
 java.lang.String InspectableTitle()
          Method to get the title to show in the InspectionFrame tab.
 java.util.Collection Inspections()
          Method to get a collection of inspectable objects.
 boolean isEnabled()
          Getter for property enabled.
 boolean isInputFull()
          Getter for property inputFull.
 boolean isLoopBack()
          Getter for property loopBack.
 boolean isOutputFull()
          Getter for property outputFull.
 void randomize(double amplitude)
          Initializes all the weigths of the synapses with random values
protected  java.lang.Object readResolve()
           
 void reset()
          Resets the internal state to be ready for the next run
 Pattern revGet()
          Returns the error pattern coming from the next layer during the training phase
 void revPut(Pattern pattern)
          Method to put an error pattern backward to the previous layer
protected abstract  void setArrays(int rows, int cols)
          Insert the method's description here.
protected abstract  void setDimensions(int rows, int cols)
          Dimensiona l'elemento
 void setEnabled(boolean enabled)
          Setter for property enabled.
 void setIgnoreBefore(int newIgnoreBefore)
          Sets the number of the ignored cycles at beginning of each epoch.
 void setInputDimension(int newInputDimension)
          Sets the input dimension of the synapse
 void setInputFull(boolean inputFull)
          Setter for property inputFull.
 void setLearningRate(double newLearningRate)
          Sets the value of the learning rate
 void setLoopBack(boolean loopBack)
          Setter for property loopBack.
 void setMomentum(double newMomentum)
          Sets the value of the momentum rate
 void setMonitor(Monitor newMonitor)
          Sets the Monitor object of the synapse
 void setName(java.lang.String name)
          Sets the name of the synapse
 void setOutputDimension(int newOutputDimension)
          Sets the output dimension of the synapse
 void setOutputFull(boolean outputFull)
          Setter for property outputFull.
 void setWeights(Matrix newWeights)
          Setter for the internal matrix of weights
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

array

protected Matrix array

m_batch

protected int m_batch

enabled

protected boolean enabled

inps

protected transient double[] inps

outs

protected transient double[] outs

bouts

protected transient double[] bouts

items

protected transient int items

bitems

protected transient int bitems

m_pattern

protected transient Pattern m_pattern

b_pattern

protected transient Pattern b_pattern

count

protected transient int count

notFirstTime

protected transient boolean notFirstTime

notFirstTimeB

protected transient boolean notFirstTimeB

myLearner

protected transient Learner myLearner

fwdLock

protected transient volatile java.lang.Object fwdLock

revLock

protected transient volatile java.lang.Object revLock

learnable

protected boolean learnable
Contains true if for the current Synapse must be used a Learner instead of a built-in learning algorithm. Set it in the constructor of any inherited class. Used by the getLearner method.

See Also:
getLearner
Constructor Detail

Synapse

public Synapse()
The constructor

Method Detail

addNoise

public void addNoise(double amplitude)
Adds a noise to the weights of the synapse

Parameters:
amplitude - Amplitude of the noise: the value is centered around the zero. e.g.: an amplitude = 0.2 means a noise range from -0.2 to 0.2

randomize

public void randomize(double amplitude)
Initializes all the weigths of the synapses with random values

Parameters:
amplitude - Amplitude of the random values: the value is centered around the zero. e.g.: an amplitude = 0.2 means a values' range from -0.2 to 0.2

backward

protected abstract void backward(double[] pattern)
Funzione di TRAIN dell'elemento.

Parameters:
pattern - double[] - pattern di input sul quale applicare la funzione di trasferimento

canCountSteps

public boolean canCountSteps()
Returns TRUE if the synapse calls the method nextStep() on the Monitor object when the fwdGet() method is called

Returns:
boolean

forward

protected abstract void forward(double[] pattern)
Recall function

Parameters:
pattern - double[] - input pattern

fwdGet

public Pattern fwdGet()
Description copied from interface: InputPatternListener
Returns the pattern coming from the previous layer during the recall phase

Specified by:
fwdGet in interface InputPatternListener
Returns:
neural.engine.Pattern

fwdPut

public void fwdPut(Pattern pattern)
Description copied from interface: OutputPatternListener
Method to put a pattern forward to the next layer

Specified by:
fwdPut in interface OutputPatternListener
Parameters:
pattern - neural.engine.Pattern

reset

public void reset()
Resets the internal state to be ready for the next run

Specified by:
reset in interface InputPatternListener

getIgnoreBefore

public int getIgnoreBefore()
Returns the number of the ignored cycles at beginning of each epoch. During these cycles the synapse returns null on the call to the xxxGet methods

Returns:
int
See Also:
setIgnoreBefore(int)

getInputDimension

public int getInputDimension()
Returns the input dimension of the synapse.

Specified by:
getInputDimension in interface LearnableSynapse
Specified by:
getInputDimension in interface OutputPatternListener
Returns:
int

getLearningRate

public double getLearningRate()
Returns the value of the learning rate

Specified by:
getLearningRate in interface LearnableSynapse
Returns:
double

getMomentum

public double getMomentum()
Returns the value of the momentum

Specified by:
getMomentum in interface LearnableSynapse
Returns:
double

getMonitor

public Monitor getMonitor()
Returns the Monitor object attached to the synapse

Specified by:
getMonitor in interface Learnable
Specified by:
getMonitor in interface NeuralElement
Returns:
neural.engine.Monitor

getName

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

Specified by:
getName in interface NeuralElement
Returns:
String
See Also:
setName(java.lang.String)

getOutputDimension

public int getOutputDimension()
Returns the output dimension of the synapse.

Specified by:
getOutputDimension in interface InputPatternListener
Specified by:
getOutputDimension in interface LearnableSynapse
Returns:
int

readResolve

protected java.lang.Object readResolve()

revGet

public Pattern revGet()
Description copied from interface: OutputPatternListener
Returns the error pattern coming from the next layer during the training phase

Specified by:
revGet in interface OutputPatternListener
Returns:
neural.engine.Pattern

revPut

public void revPut(Pattern pattern)
Description copied from interface: InputPatternListener
Method to put an error pattern backward to the previous layer

Specified by:
revPut in interface InputPatternListener
Parameters:
pattern - neural.engine.Pattern

setArrays

protected abstract void setArrays(int rows,
                                  int cols)
Insert the method's description here. Creation date: (23/09/2000 12.52.58)


setDimensions

protected abstract void setDimensions(int rows,
                                      int cols)
Dimensiona l'elemento

Parameters:
int - rows - righe
int - cols - colonne

setIgnoreBefore

public void setIgnoreBefore(int newIgnoreBefore)
Sets the number of the ignored cycles at beginning of each epoch. During these cycles the synapse is disabled. Useful when the synapse is attached as the Input2 of a SwitchSynapse

Parameters:
newIgnoreBefore - int
See Also:
SwitchSynapse

setInputDimension

public void setInputDimension(int newInputDimension)
Sets the input dimension of the synapse

Specified by:
setInputDimension in interface OutputPatternListener
Parameters:
newInputDimension - int

setLearningRate

public void setLearningRate(double newLearningRate)
Sets the value of the learning rate

Parameters:
newLearningRate - double

setMomentum

public void setMomentum(double newMomentum)
Sets the value of the momentum rate

Parameters:
newMomentum - double

setMonitor

public void setMonitor(Monitor newMonitor)
Sets the Monitor object of the synapse

Specified by:
setMonitor in interface NeuralElement
Parameters:
newMonitor - neural.engine.Monitor

setName

public void setName(java.lang.String name)
Sets the name of the synapse

Specified by:
setName in interface NeuralElement
Parameters:
name - The name of the component.
See Also:
getName()

setOutputDimension

public void setOutputDimension(int newOutputDimension)
Sets the output dimension of the synapse

Specified by:
setOutputDimension in interface InputPatternListener
Parameters:
newOutputDimension - int

isEnabled

public boolean isEnabled()
Getter for property enabled.

Specified by:
isEnabled in interface NeuralElement
Returns:
Value of property enabled.

setEnabled

public void setEnabled(boolean enabled)
Setter for property enabled.

Specified by:
setEnabled in interface NeuralElement
Parameters:
enabled - New value of property enabled.

isLoopBack

public boolean isLoopBack()
Getter for property loopBack.

Returns:
Value of property loopBack.

setLoopBack

public void setLoopBack(boolean loopBack)
Setter for property loopBack.

Parameters:
loopBack - New value of property loopBack.

check

public java.util.TreeSet check()
Base for check messages. Subclasses should call this method from thier own check method.

Specified by:
check in interface NeuralElement
Returns:
validation errors.
See Also:
InputPaternListener, OutputPaternListener

Inspections

public java.util.Collection Inspections()
Description copied from interface: Inspectable
Method to get a collection of inspectable objects.

Specified by:
Inspections in interface Inspectable
Returns:
list of Inspectable objects
See Also:
org.joone.Inspection

InspectableTitle

public java.lang.String InspectableTitle()
Description copied from interface: Inspectable
Method to get the title to show in the InspectionFrame tab.

Specified by:
InspectableTitle in interface Inspectable
Returns:
title of the class.
See Also:
org.joone.InspectionFrame

isInputFull

public boolean isInputFull()
Getter for property inputFull.

Specified by:
isInputFull in interface InputPatternListener
Returns:
Value of property inputFull.

setInputFull

public void setInputFull(boolean inputFull)
Setter for property inputFull.

Specified by:
setInputFull in interface InputPatternListener
Parameters:
inputFull - New value of property inputFull.

isOutputFull

public boolean isOutputFull()
Getter for property outputFull.

Specified by:
isOutputFull in interface OutputPatternListener
Returns:
Value of property outputFull.

setOutputFull

public void setOutputFull(boolean outputFull)
Setter for property outputFull.

Specified by:
setOutputFull in interface OutputPatternListener
Parameters:
outputFull - New value of property outputFull.

getWeights

public Matrix getWeights()
Getter for the internal matrix of weights

Specified by:
getWeights in interface LearnableSynapse
Returns:
the Matrix containing the 2D array of weights

setWeights

public void setWeights(Matrix newWeights)
Setter for the internal matrix of weights

Specified by:
setWeights in interface LearnableSynapse
Parameters:
the - Matrix containing the 2D array of weights

getLearner

public Learner getLearner()
Returns the appropriate Learner object for this class depending on the Monitor.learningMode property value

Specified by:
getLearner in interface Learnable
Returns:
the Learner object if applicable, otherwise null
See Also:
Learnable.getLearner()

initLearner

public void initLearner()
Initialize the Learner object

Specified by:
initLearner in interface Learnable
See Also:
Learnable.initLearner()

getFwdLock

protected java.lang.Object getFwdLock()
Getter for property fwdLock.

Returns:
Value of property fwdLock.

getRevLock

protected java.lang.Object getRevLock()
Getter for property revLock.

Returns:
Value of property revLock.

init

public void init()
Synapse's initialization. It needs to be invoked at the starting of the neural network It's called within the Layer.init() method

Specified by:
init in interface NeuralElement


Submit Feedback to pmarrone@users.sourceforge.net