org.joone.engine
Class Monitor
- java.lang.Object
-
- org.joone.engine.Monitor
-
- All Implemented Interfaces:
- java.io.Serializable
public class Monitor extends java.lang.Object implements java.io.SerializableThe Monitor object is the controller of the behavior of the neural net. It controls the start/stop actions and permits to set the parameters of the net (learning rate, momentum, ecc.). Each component of the neural net (Layers and Synapses) are connected to a monitor object (the monitor can be different or the same for the all components).- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description intlearningMode
-
Constructor Summary
Constructors Constructor and Description Monitor()This is the default Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddLearner(int i, java.lang.String learner)Adds a new Learner to the Neural Network Usage: Monitor.addLearner(0, "org.joone.engine.BasicLearner"); Monitor.addLearner(1, "org.joone.engine.BatchLearner"); Monitor.addLearner(2, "org.joone.engine.RpropLearner");voidaddNeuralNetListener(NeuralNetListener l)adds a neural net event listener the MonitorvoidaddNeuralNetListener(NeuralNetListener l, boolean removable)adds a neural net event listener to the Monitorjava.util.TreeSetcheck()voidfireCicleTerminated()Invoked when an epoch finishesvoidfireErrorChanged()Invoked when the GlobalError changesvoidfireNetStarted()Invoked when the net startsvoidfireNetStopped()Invoked when all the epochs finishvoidfireNetStoppedError(java.lang.String errMsg)Invoked when an error occursintgetBatchSize()Getter for the property BatchSizeintgetCurrentCicle()Returns the current epochdoublegetGlobalError()Returns the actual (R)MSE of the NNjava.lang.String[]getKeys()Return all the keys of the parameters contained in this Monitor.LearnergetLearner()Gets a learner for a synapse or layer.LearnergetLearner(int index)Getter for the Learner declared at position 'index'intgetLearningMode()Getter for property learningMode.doublegetLearningRate()Returns the learning ratedoublegetMomentum()Returns the momentumintgetNumOfPatterns()java.lang.ObjectgetParam(java.lang.String key)Gets a custom parameter from the Monitor.MonitorgetParent()Getter for property parent.intgetPreLearning()Returns the initial ignored input patterns (during the training phase)intgetRun()Needed for XML savingintgetStep()Returns the actual elaborated patternintgetTotCicles()Returns the total number of epochsintgetTrainingPatterns()Returns the number of the input training patternsintgetValidationPatterns()Returns the number of the input validation patternsvoidGo()Runs the neural net in multi-thread mode.booleanisExporting()Getter for property exporting.booleanisLearning()Returns TRUE if the net is into a learning phasebooleanisLearningCicle(int num)Returns the phase of the net (learning or not) for the current patternbooleanisSingleThreadMode()booleanisSupervised()Getter for property supervised.booleanisTrainingDataForValidation()Getter for the property trainingDataForValidation, i.e.booleanisUseRMSE()Checks if we should use RMSE (true) or MSE false.booleanisValidation()Getter for property validation.booleannextStep()Returns if the next pattern must be elaboratedvoidremoveAllListeners()Removes all the NeuralNetListeners.voidremoveNeuralNetListener(NeuralNetListener l)Removes a listenervoidresetCycle()voidrunAgain()Let continue the net.voidsetBatchSize(int i)Setter for the property BatchSizevoidsetCurrentCicle(int newCurrentCicle)Not usedvoidsetExporting(boolean exporting)Setter for property exporting.voidsetGlobalError(double newGlobalError)Sets the actual error of the NNvoidsetLearnerFactory(LearnerFactory aFactory)Set learner factory.voidsetLearning(boolean newLearning)Sets the phase of the neural network: learning (true) or recall (false)voidsetLearningMode(int learningMode)Setter for property learningMode.voidsetLearningRate(double newLearningRate)Sets the learning ratevoidsetMomentum(double newMomentum)Sets the momentumvoidsetParam(java.lang.String key, java.lang.Object obj)Sets a custom parameter of the Monitor.voidsetParent(Monitor parent)Setter for property parent.voidsetPreLearning(int newPreLearning)Sets the initial ignored input patterns (during the training phase)voidsetSingleThreadMode(boolean singleThreadMode)voidsetSupervised(boolean supervised)Setter for property supervised.voidsetTotCicles(int newTotCicles)Sets the total number of epochsvoidsetTrainingDataForValidation(boolean aMode)Setter for the property trainingDataForValidation.voidsetTrainingPatterns(int newPatterns)Sets the number of the input training patternsvoidsetUseRMSE(boolean aMode)Uses the RMSE when set to true.voidsetValidation(boolean validation)Setter for property validation.voidsetValidationPatterns(int newPatterns)Sets the number of the input validation patternsvoidStop()Stops the NN when running in multi-thread mode.
-
-
-
Method Detail
-
addNeuralNetListener
public void addNeuralNetListener(NeuralNetListener l)
adds a neural net event listener the Monitor- Parameters:
l- NeuralNetListener
-
addNeuralNetListener
public void addNeuralNetListener(NeuralNetListener l, boolean removable)
adds a neural net event listener to the Monitor- Parameters:
l- the new NeuralNetListenerremovable- true if the added listener can be removed by the removeAllListeners method call
-
fireCicleTerminated
public void fireCicleTerminated()
Invoked when an epoch finishes
-
fireNetStarted
public void fireNetStarted()
Invoked when the net starts
-
fireNetStopped
public void fireNetStopped()
Invoked when all the epochs finish
-
fireNetStoppedError
public void fireNetStoppedError(java.lang.String errMsg)
Invoked when an error occurs- Parameters:
errMsg- the thrown error message
-
fireErrorChanged
public void fireErrorChanged()
Invoked when the GlobalError changes
-
getCurrentCicle
public int getCurrentCicle()
Returns the current epoch- Returns:
- int
-
getGlobalError
public double getGlobalError()
Returns the actual (R)MSE of the NN- Returns:
- double
-
getLearningRate
public double getLearningRate()
Returns the learning rate- Returns:
- double
-
getMomentum
public double getMomentum()
Returns the momentum- Returns:
- double
-
getTrainingPatterns
public int getTrainingPatterns()
Returns the number of the input training patterns- Returns:
- int
-
setTrainingPatterns
public void setTrainingPatterns(int newPatterns)
Sets the number of the input training patterns- Parameters:
newPatterns- int
-
getPreLearning
public int getPreLearning()
Returns the initial ignored input patterns (during the training phase)- Returns:
- int
-
getStep
public int getStep()
Returns the actual elaborated pattern- Returns:
- int
-
getTotCicles
public int getTotCicles()
Returns the total number of epochs- Returns:
- int
-
Go
public void Go()
Runs the neural net in multi-thread mode. WARNING: AVOID to invoke this method. Use instead NeuralNet.go()- See Also:
org.joone.net.NeuralNet.go()
-
isLearning
public boolean isLearning()
Returns TRUE if the net is into a learning phase- Returns:
- boolean
-
isLearningCicle
public boolean isLearningCicle(int num)
Returns the phase of the net (learning or not) for the current pattern- Parameters:
num- the pattern requested- Returns:
- boolean
-
resetCycle
public void resetCycle()
-
nextStep
public boolean nextStep()
Returns if the next pattern must be elaborated- Returns:
- boolean
-
removeNeuralNetListener
public void removeNeuralNetListener(NeuralNetListener l)
Removes a listener- Parameters:
l- the listener to be removed
-
runAgain
public void runAgain()
Let continue the net.
-
setCurrentCicle
public void setCurrentCicle(int newCurrentCicle)
Not used- Parameters:
newCurrentCicle- int
-
setGlobalError
public void setGlobalError(double newGlobalError)
Sets the actual error of the NN- Parameters:
newGlobalError- double
-
setLearning
public void setLearning(boolean newLearning)
Sets the phase of the neural network: learning (true) or recall (false)- Parameters:
newLearning- boolean
-
setLearningRate
public void setLearningRate(double newLearningRate)
Sets the learning rate- Parameters:
newLearningRate- double
-
setMomentum
public void setMomentum(double newMomentum)
Sets the momentum- Parameters:
newMomentum- double
-
setPreLearning
public void setPreLearning(int newPreLearning)
Sets the initial ignored input patterns (during the training phase)- Parameters:
newPreLearning- int
-
setTotCicles
public void setTotCicles(int newTotCicles)
Sets the total number of epochs- Parameters:
newTotCicles- int
-
Stop
public void Stop()
Stops the NN when running in multi-thread mode. WARNING: DO NOT INVOKE directly, use instead NeuralNet.stop()- See Also:
org.joone.net.NeuralNet.stop()
-
isExporting
public boolean isExporting()
Getter for property exporting.- Returns:
- Value of property exporting.
-
setExporting
public void setExporting(boolean exporting)
Setter for property exporting.- Parameters:
exporting- New value of property exporting.
-
getRun
public int getRun()
Needed for XML saving
-
isValidation
public boolean isValidation()
Getter for property validation.- Returns:
- Value of property validation.
-
setValidation
public void setValidation(boolean validation)
Setter for property validation.- Parameters:
validation- New value of property validation.
-
isTrainingDataForValidation
public boolean isTrainingDataForValidation()
Getter for the property trainingDataForValidation, i.e. should the training data be used for validation.- Returns:
- true if the training data should be used, false otherwise.
-
setTrainingDataForValidation
public void setTrainingDataForValidation(boolean aMode)
Setter for the property trainingDataForValidation.- Parameters:
aMode- true if the training data should be used for validation, false otherwise.
-
removeAllListeners
public void removeAllListeners()
Removes all the NeuralNetListeners. Removes only the listeners marked as removable- See Also:
addNeuralNetListener
-
getParent
public Monitor getParent()
Getter for property parent.- Returns:
- Value of property parent.
-
setParent
public void setParent(Monitor parent)
Setter for property parent.- Parameters:
parent- New value of property parent.
-
getValidationPatterns
public int getValidationPatterns()
Returns the number of the input validation patterns- Returns:
- int
-
setValidationPatterns
public void setValidationPatterns(int newPatterns)
Sets the number of the input validation patterns- Parameters:
newPatterns- int
-
getNumOfPatterns
public int getNumOfPatterns()
-
check
public java.util.TreeSet check()
-
isSupervised
public boolean isSupervised()
Getter for property supervised.- Returns:
- Value of property supervised.
-
setSupervised
public void setSupervised(boolean supervised)
Setter for property supervised. (default = false)- Parameters:
supervised- New value of property supervised.
-
getBatchSize
public int getBatchSize()
Getter for the property BatchSize- Returns:
- the size (# of cycles) of the batch mode
-
setBatchSize
public void setBatchSize(int i)
Setter for the property BatchSize- Parameters:
the- size (# of cycles) of the batch mode
-
getLearningMode
public int getLearningMode()
Getter for property learningMode. The learningMode determines the kind of learning algorithm applied to the neural network.- Returns:
- Value of property learningMode.
- See Also:
getLearners()
-
setLearningMode
public void setLearningMode(int learningMode)
Setter for property learningMode.- Parameters:
learningMode- New value of property learningMode.
-
getLearner
public Learner getLearner(int index)
Getter for the Learner declared at position 'index'- Parameters:
the- index of the Learner to get- Returns:
- the Learner at 'index' position
- See Also:
getLearners()
-
getLearner
public Learner getLearner()
Gets a learner for a synapse or layer.- Returns:
- a learner for a synapse or layer.
-
addLearner
public void addLearner(int i, java.lang.String learner)Adds a new Learner to the Neural Network Usage: Monitor.addLearner(0, "org.joone.engine.BasicLearner"); Monitor.addLearner(1, "org.joone.engine.BatchLearner"); Monitor.addLearner(2, "org.joone.engine.RpropLearner");- Parameters:
i- the index of the new Learnerlearner- a String containing the class name of the Learner to add
-
getParam
public java.lang.Object getParam(java.lang.String key)
Gets a custom parameter from the Monitor. The user is free to use the custom parameters as s/he wants. They are useful to store a whatever value that could be used by the nnet's components. It has been introduced to set the parameters of new added Learners.- Parameters:
key- The searched key- Returns:
- The value of the parameter if found, otherwise null
-
setParam
public void setParam(java.lang.String key, java.lang.Object obj)Sets a custom parameter of the Monitor. The user is free to use the custom parameters as s/he wants. They are useful to store a whatever value that could be used by the nnet's components. It has been introduced to set the parameters of new added Learners.- Parameters:
key- The key of the paramobj- The value of the param
-
getKeys
public java.lang.String[] getKeys()
Return all the keys of the parameters contained in this Monitor.- Returns:
- An array of Strings containing all the keys if found, otherwise null
-
setUseRMSE
public void setUseRMSE(boolean aMode)
Uses the RMSE when set to true. Uses MSE when set to false.- Parameters:
aMode- the mode to set true for RMSE, false for MSE.
-
isUseRMSE
public boolean isUseRMSE()
Checks if we should use RMSE (true) or MSE false.- Returns:
- true if we should use RMSE, false if we should use MSE.
-
setLearnerFactory
public void setLearnerFactory(LearnerFactory aFactory)
Set learner factory.- Parameters:
aFactory- the learner factory to set.
-
isSingleThreadMode
public boolean isSingleThreadMode()
-
setSingleThreadMode
public void setSingleThreadMode(boolean singleThreadMode)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG