Back-Propagation Algorithm implementation. More...
Public Member Functions | |
BackPropagationAlgo (NeuralNet *n_n, UpdatableList update_order, double l_r=0.1) | |
Constructor. More... | |
BackPropagationAlgo () | |
Default Constructor. More... | |
~BackPropagationAlgo () | |
Destructor. More... | |
virtual double | calculateMSE (const Pattern &) |
Calculate the Mean Square Error respect to Pattern passed. More... | |
virtual void | configure (ConfigurationParameters ¶ms, QString prefix) |
Configures the object using a ConfigurationParameters object. More... | |
void | disableMomentum () |
Disable momentum. More... | |
void | enableMomentum () |
Enable the momentum. More... | |
DoubleVector | getError (Cluster *) |
This method returns the deltas calculated by the Back-propagation Algorithm. More... | |
virtual void | learn () |
a single step of learning algorithm More... | |
virtual void | learn (const Pattern &) |
Starts a single training step. More... | |
double | momentum () const |
return the momentum More... | |
double | rate () const |
return the learning rate More... | |
virtual void | save (ConfigurationParameters ¶ms, QString prefix) |
Save the actual status of parameters into the ConfigurationParameters object passed. More... | |
void | setMomentum (double newmom) |
Set the momentum value. More... | |
void | setRate (double newrate) |
Set the learning rate. More... | |
void | setTeachingInput (Cluster *output, const DoubleVector &ti) |
Set the teaching input for Cluster passed. More... | |
void | setUpdateOrder (const UpdatableList &update_order) |
Set the order on which the error is backpropagated through the NeuralNet. More... | |
UpdatableList | updateOrder () const |
Return the order on which the error is backpropaget through the NeuralNet. More... | |
Public Member Functions inherited from LearningAlgorithm | |
LearningAlgorithm (NeuralNet *net) | |
Constructor. More... | |
LearningAlgorithm () | |
Constructor. More... | |
virtual | ~LearningAlgorithm () |
Destructor. More... | |
virtual double | calculateMSEOnSet (const PatternSet &set) |
Calculate the Mean Square Error respect to all Patterns passed. More... | |
double | calculateRMSD (const Pattern &p) |
Calculate the Root Mean Square Deviation, i.e. More... | |
double | calculateRMSDOnSet (const PatternSet &p) |
Calculate the Root Mean Square Deviation, i.e. More... | |
virtual void | learnOnSet (const PatternSet &set) |
Modify the object tring to learn all patterns present into PatternSet passed. More... | |
PatternSet | loadPatternSet (ConfigurationParameters ¶ms, QString path, QString prefix) |
Utility function for loading a PatternSet from a ConfigurationParameters. More... | |
NeuralNet * | neuralNet () |
Return the NeuralNet setted. More... | |
void | savePatternSet (PatternSet &set, ConfigurationParameters ¶ms, QString prefix) |
Utility function for saving a PatternSet to a ConfigurationParameters. More... | |
void | setNeuralNet (NeuralNet *net) |
Set the NeuralNet to learn. More... | |
Public Member Functions inherited from ParameterSettable | |
void | addObserver (RuntimeParameterObserver *obs) |
T | getRuntimeParameter (QString paramName) |
virtual ParameterSettableUI * | getUIManager () |
virtual void | postConfigureInitialization () |
void | removeObserver (RuntimeParameterObserver *obs) |
void | setRuntimeParameter (QString paramName, T newvalue) |
QString | typeName () const |
Static Public Member Functions | |
static void | describe (QString type) |
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups. More... | |
Static Public Member Functions inherited from ParameterSettable | |
static void | describe (QString type) |
static QString | fullParameterDescriptionPath (QString type, QString param) |
static QString | fullSubgroupDescriptionPath (QString type, QString sub) |
Protected Member Functions | |
virtual void | neuralNetChanged () |
Configure internal data for backpropagation on NeuralNet setted. More... | |
Protected Member Functions inherited from ParameterSettable | |
void | notifyChangesToParam (QString paramName) |
Additional Inherited Members | |
Public Types inherited from ParameterSettable | |
enum | Property |
Public Attributes inherited from ParameterSettable | |
AllowMultiple | |
Default | |
IsList | |
IsMandatory | |
Static Public Attributes inherited from ParameterSettable | |
static const double | Infinity |
static const int | MaxInteger |
static const int | MinInteger |
Static Protected Member Functions inherited from ParameterSettable | |
static Descriptor | addTypeDescription (QString type, QString shortHelp, QString longHelp=QString("")) |
static void | setGraphicalEditor (QString type) |
Detailed Description
Back-Propagation Algorithm implementation.
Definition at line 35 of file backpropagationalgo.h.
Constructor & Destructor Documentation
BackPropagationAlgo | ( | NeuralNet * | n_n, |
UpdatableList | update_order, | ||
double | l_r = 0.1 |
||
) |
Constructor.
- Parameters
-
neural_network the BaseNeuralNet neural network to train update_order the UpdatableList for the backpropagation sequence learn_rate the double learning rate factor
Definition at line 27 of file backpropagationalgo.cpp.
References BackPropagationAlgo::neuralNetChanged().
Default Constructor.
Definition at line 34 of file backpropagationalgo.cpp.
References BackPropagationAlgo::neuralNetChanged().
~BackPropagationAlgo | ( | ) |
Destructor.
Definition at line 41 of file backpropagationalgo.cpp.
Member Function Documentation
|
virtual |
Calculate the Mean Square Error respect to Pattern passed.
Implements LearningAlgorithm.
Definition at line 193 of file backpropagationalgo.cpp.
References NeuralNet::inputClusters(), Pattern::inputsOf(), LearningAlgorithm::neuralNet(), NeuralNet::outputClusters(), Pattern::outputsOf(), and NeuralNet::step().
|
virtual |
Configures the object using a ConfigurationParameters object.
From the file you can configure the parameters of the BackPropagation in this way:
As you can note, there is no configuration parameters for loading the learning set from here. This is intended. You need to load separately the learning set and call the method learn on the loaded learning set.
You can do that creating groups like the following (see class Pattern):
And call the method LearningAlgorithm::loadPatternSet( params, "learningSet" )
- Parameters
-
params the configuration parameters object with parameters to use prefix the prefix to use to access the object configuration parameters. This is guaranteed to end with the separator character when called by the factory, so you don't need to add one
Implements ParameterSettableWithConfigureFunction.
Definition at line 247 of file backpropagationalgo.cpp.
References ConfigurationParameters::getObjectFromGroup(), ConfigurationParameters::getObjectFromParameter(), ConfigurationParameters::getValue(), LearningAlgorithm::setNeuralNet(), ConfigurationParameters::startRememberingGroupObjectAssociations(), and ConfigurationParameters::stopRememberingGroupObjectAssociations().
|
static |
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups.
Definition at line 286 of file backpropagationalgo.cpp.
References ParameterSettable::addTypeDescription(), and ParameterSettable::IsMandatory.
|
inline |
Disable momentum.
Definition at line 97 of file backpropagationalgo.h.
void enableMomentum | ( | ) |
Enable the momentum.
Definition at line 95 of file backpropagationalgo.cpp.
DoubleVector getError | ( | Cluster * | cl | ) |
This method returns the deltas calculated by the Back-propagation Algorithm.
These deltas are set every time new targets are defined for the output layer(s), which are then used to update network weights when the method learn() is called.
They are also useful to calculate the network performance, but for that it must be used outside the learning cycle (a full learning iteration, that corresponds to present the network with all the patterns of the train data set). For that you must call getError( Cluster * anyOutputCluster ) for each line of your training set (you'll get a DoubleVector with the deltas for each unit of the cluster considered).
Then you can use those values to calculate your desired performance measure.
For instance: if you use it to calculate the Mean Square Error (MSE) of the network for your train data set you must accumulate the square of the the getError( anyOutputCluster ) output for each line of the set, and at the end divide it by the length of that same set (by definition the MSE is the sum of the squared differences between the target and actual output of a sequence of values). Getting the Root Mean Squared Error (RMSE) from this is trivial (you just need to calculate the square root of the MSE).
- Warning
- The data returned by getError( Cluster * ) is computed every time you set a new output target, which means every time you call the setTeachingInput( Cluster * anyOutputCluster, const DoubleVector & teaching_input ) method. If your network has more than one output layer you have to call setTeachingInput() for all the output clusters before calling getError() for any of the clusters.
Definition at line 86 of file backpropagationalgo.cpp.
|
virtual |
a single step of learning algorithm
Implements LearningAlgorithm.
Definition at line 132 of file backpropagationalgo.cpp.
Referenced by BackPropagationAlgo::learn().
|
virtual |
Starts a single training step.
Implements LearningAlgorithm.
Definition at line 177 of file backpropagationalgo.cpp.
References NeuralNet::inputClusters(), Pattern::inputsOf(), BackPropagationAlgo::learn(), LearningAlgorithm::neuralNet(), NeuralNet::outputClusters(), Pattern::outputsOf(), BackPropagationAlgo::setTeachingInput(), and NeuralNet::step().
|
inline |
return the momentum
Definition at line 89 of file backpropagationalgo.h.
|
protectedvirtual |
Configure internal data for backpropagation on NeuralNet setted.
Implements LearningAlgorithm.
Definition at line 45 of file backpropagationalgo.cpp.
References LearningAlgorithm::neuralNet(), and NeuralNet::outputClusters().
Referenced by BackPropagationAlgo::BackPropagationAlgo(), and BackPropagationAlgo::setUpdateOrder().
|
inline |
return the learning rate
Definition at line 79 of file backpropagationalgo.h.
|
virtual |
Save the actual status of parameters into the ConfigurationParameters object passed.
- Parameters
-
params the configuration parameters object on which save actual parameters prefix the prefix to use to access the object configuration parameters.
Implements ParameterSettable.
Definition at line 270 of file backpropagationalgo.cpp.
References ConfigurationParameters::createParameter(), Updatable::name(), LearningAlgorithm::neuralNet(), NeuralNet::save(), and ConfigurationParameters::startObjectParameters().
|
inline |
Set the momentum value.
Definition at line 84 of file backpropagationalgo.h.
|
inline |
Set the learning rate.
Definition at line 74 of file backpropagationalgo.h.
void setTeachingInput | ( | Cluster * | output, |
const DoubleVector & | ti | ||
) |
Set the teaching input for Cluster passed.
- Parameters
-
teach_input the DoubleVector teaching input
Definition at line 77 of file backpropagationalgo.cpp.
References Cluster::outputs().
Referenced by BackPropagationAlgo::learn().
void setUpdateOrder | ( | const UpdatableList & | update_order | ) |
Set the order on which the error is backpropagated through the NeuralNet.
- Warning
- Calling this method will also clean any previous data about previous processing and re-initialize all datas
Definition at line 72 of file backpropagationalgo.cpp.
References BackPropagationAlgo::neuralNetChanged().
|
inline |
Return the order on which the error is backpropaget through the NeuralNet.
Definition at line 57 of file backpropagationalgo.h.
The documentation for this class was generated from the following files:
- nnfw/include/backpropagationalgo.h
- nnfw/src/backpropagationalgo.cpp