OpenNN
2.2
Open Neural Networks Library
|
#include <training_rate_algorithm.h>
Classes | |
struct | Triplet |
Public Types | |
enum | TrainingRateMethod { Fixed, GoldenSection, BrentMethod } |
Public Member Functions | |
TrainingRateAlgorithm (void) | |
TrainingRateAlgorithm (PerformanceFunctional *) | |
TrainingRateAlgorithm (const tinyxml2::XMLDocument &) | |
virtual | ~TrainingRateAlgorithm (void) |
PerformanceFunctional * | get_performance_functional_pointer (void) const |
bool | has_performance_functional (void) const |
const TrainingRateMethod & | get_training_rate_method (void) const |
std::string | write_training_rate_method (void) const |
const double & | get_bracketing_factor (void) const |
const double & | get_training_rate_tolerance (void) const |
const double & | get_warning_training_rate (void) const |
const double & | get_error_training_rate (void) const |
const bool & | get_display (void) const |
void | set (void) |
void | set (PerformanceFunctional *) |
void | set_performance_functional_pointer (PerformanceFunctional *) |
void | set_training_rate_method (const TrainingRateMethod &) |
void | set_training_rate_method (const std::string &) |
void | set_bracketing_factor (const double &) |
void | set_training_rate_tolerance (const double &) |
void | set_warning_training_rate (const double &) |
void | set_error_training_rate (const double &) |
void | set_display (const bool &) |
virtual void | set_default (void) |
double | calculate_golden_section_training_rate (const Triplet &) const |
double | calculate_Brent_method_training_rate (const Triplet &) const |
Triplet | calculate_bracketing_triplet (const double &, const Vector< double > &, const double &) const |
Vector< double > | calculate_fixed_directional_point (const double &, const Vector< double > &, const double &) const |
Vector< double > | calculate_golden_section_directional_point (const double &, const Vector< double > &, const double &) const |
Vector< double > | calculate_Brent_method_directional_point (const double &, const Vector< double > &, const double &) const |
Vector< double > | calculate_directional_point (const double &, const Vector< double > &, const double &) const |
tinyxml2::XMLDocument * | to_XML (void) const |
void | from_XML (const tinyxml2::XMLDocument &) |
Protected Attributes | |
PerformanceFunctional * | performance_functional_pointer |
TrainingRateMethod | training_rate_method |
double | bracketing_factor |
double | training_rate_tolerance |
double | warning_training_rate |
double | error_training_rate |
bool | display |
This class is used by many different training algorithms to calculate the training rate given a training direction. It implements the golden section method and the Brent's methods.
Definition at line 42 of file training_rate_algorithm.h.
|
explicit |
Default constructor. It creates a training rate algorithm object not associated to any performance functional object. It also initializes the class members to their default values.
Definition at line 27 of file training_rate_algorithm.cpp.
|
explicit |
General constructor. It creates a training rate algorithm associated to a performance functional. It also initializes the class members to their default values.
new_performance_functional_pointer | Pointer to a performance functional object. |
Definition at line 41 of file training_rate_algorithm.cpp.
|
explicit |
XML constructor. It creates a training rate algorithm object not associated to any performance functional object. It also loads the class members from a XML document.
document | Pointer to a TinyXML document-> |
Definition at line 55 of file training_rate_algorithm.cpp.
TrainingRateAlgorithm::Triplet OpenNN::TrainingRateAlgorithm::calculate_bracketing_triplet | ( | const double & | performance, |
const Vector< double > & | training_direction, | ||
const double & | initial_training_rate | ||
) | const |
Returns bracketing triplet. This algorithm is used by line minimization algorithms.
performance | Initial performance function performance. |
training_direction | Initial training direction. |
initial_training_rate | Initial training rate to start the algorithm. |
Definition at line 543 of file training_rate_algorithm.cpp.
Vector< double > OpenNN::TrainingRateAlgorithm::calculate_Brent_method_directional_point | ( | const double & | performance, |
const Vector< double > & | training_direction, | ||
const double & | initial_training_rate | ||
) | const |
Returns the training rate by searching in a given direction to locate the minimum of the performance function in that direction. It uses the Brent's method.
performance | Neural network performance value. |
training_direction | Training direction vector. |
initial_training_rate | Initial training rate in line minimization. |
Definition at line 772 of file training_rate_algorithm.cpp.
double OpenNN::TrainingRateAlgorithm::calculate_Brent_method_training_rate | ( | const Triplet & | triplet | ) | const |
Returns the minimimal training rate of a parabola defined by three directional points.
triplet | Triplet containing a minimum. |
Definition at line 944 of file training_rate_algorithm.cpp.
Vector< double > OpenNN::TrainingRateAlgorithm::calculate_directional_point | ( | const double & | performance, |
const Vector< double > & | training_direction, | ||
const double & | initial_training_rate | ||
) | const |
Returns a vector with two elements: (i) the training rate calculated by means of the corresponding algorithm, and (ii) the performance for that training rate.
performance | Initial performance function performance. |
training_direction | Initial training direction. |
initial_training_rate | Initial training rate to start the algorithm. |
Definition at line 467 of file training_rate_algorithm.cpp.
Vector< double > OpenNN::TrainingRateAlgorithm::calculate_fixed_directional_point | ( | const double & | , |
const Vector< double > & | training_direction, | ||
const double & | initial_training_rate | ||
) | const |
Returns a vector with two elements, a fixed training rate, and the performance for that training rate.
training_direction | Training direction for the directional point. |
initial_training_rate | Training rate for the directional point. |
Definition at line 643 of file training_rate_algorithm.cpp.
Vector< double > OpenNN::TrainingRateAlgorithm::calculate_golden_section_directional_point | ( | const double & | performance, |
const Vector< double > & | training_direction, | ||
const double & | initial_training_rate | ||
) | const |
Returns the training rate by searching in a given direction to locate the minimum of the objective function in that direction. It uses the golden section method.
performance | Neural multilayer_perceptron_pointer's performance value. |
training_direction | Training direction vector. |
initial_training_rate | Initial training rate in line minimization. |
Definition at line 663 of file training_rate_algorithm.cpp.
double OpenNN::TrainingRateAlgorithm::calculate_golden_section_training_rate | ( | const Triplet & | triplet | ) | const |
Calculates the golden section point within a minimum interval defined by three points.
triplet | Triplet containing a minimum. |
Definition at line 894 of file training_rate_algorithm.cpp.
void OpenNN::TrainingRateAlgorithm::from_XML | ( | const tinyxml2::XMLDocument & | document | ) |
Loads a training rate algorithm object from a XML-type file. Please mind about the file format, wich is specified in the manual.
document | TinyXML document with the training rate algorithm members. |
Definition at line 1093 of file training_rate_algorithm.cpp.
const bool & OpenNN::TrainingRateAlgorithm::get_display | ( | void | ) | const |
Returns true if messages from this class can be displayed on the screen, or false if messages from this class can't be displayed on the screen.
Definition at line 216 of file training_rate_algorithm.cpp.
const double & OpenNN::TrainingRateAlgorithm::get_error_training_rate | ( | void | ) | const |
Returns the training rate value at wich the line minimization algorithm is assumed to fail when bracketing a minimum.
Definition at line 205 of file training_rate_algorithm.cpp.
PerformanceFunctional * OpenNN::TrainingRateAlgorithm::get_performance_functional_pointer | ( | void | ) | const |
Returns a pointer to the performance functional object to which the training rate algorithm is associated. If the performance functional pointer is NULL, this method throws an exception.
Definition at line 79 of file training_rate_algorithm.cpp.
const double & OpenNN::TrainingRateAlgorithm::get_warning_training_rate | ( | void | ) | const |
Returns the training rate value at wich a warning message is written to the screen during line minimization.
Definition at line 194 of file training_rate_algorithm.cpp.
bool OpenNN::TrainingRateAlgorithm::has_performance_functional | ( | void | ) | const |
Returns true if this training rate algorithm has an associated performance functional, and false otherwise.
Definition at line 105 of file training_rate_algorithm.cpp.
void OpenNN::TrainingRateAlgorithm::set | ( | void | ) |
Sets the performance functional pointer to NULL. It also sets the rest of members to their default values.
Definition at line 227 of file training_rate_algorithm.cpp.
void OpenNN::TrainingRateAlgorithm::set | ( | PerformanceFunctional * | new_performance_functional_pointer | ) |
Sets a new performance functional pointer. It also sets the rest of members to their default values.
new_performance_functional_pointer | Pointer to a performance functional object. |
Definition at line 240 of file training_rate_algorithm.cpp.
void OpenNN::TrainingRateAlgorithm::set_bracketing_factor | ( | const double & | new_bracketing_factor | ) |
Sets a new increase factor value to be used for line minimization when bracketing a minimum.
new_bracketing_factor | Bracketing factor value. |
Definition at line 332 of file training_rate_algorithm.cpp.
void OpenNN::TrainingRateAlgorithm::set_display | ( | const bool & | new_display | ) |
Sets a new display value. If it is set to true messages from this class are to be displayed on the screen; if it is set to false messages from this class are not to be displayed on the screen.
new_display | Display value. |
Definition at line 452 of file training_rate_algorithm.cpp.
void OpenNN::TrainingRateAlgorithm::set_error_training_rate | ( | const double & | new_error_training_rate | ) |
Sets a new training rate value at wich a the line minimization algorithm is assumed to fail when bracketing a minimum.
new_error_training_rate | Error training rate value. |
Definition at line 420 of file training_rate_algorithm.cpp.
void OpenNN::TrainingRateAlgorithm::set_performance_functional_pointer | ( | PerformanceFunctional * | new_performance_functional_pointer | ) |
Sets a pointer to a performance functional object to be associated to the training algorithm.
new_performance_functional_pointer | Pointer to a performance functional object. |
Definition at line 278 of file training_rate_algorithm.cpp.
void OpenNN::TrainingRateAlgorithm::set_training_rate_method | ( | const TrainingRateMethod & | new_training_rate_method | ) |
Sets a new training rate method to be used for training.
new_training_rate_method | Training rate method. |
Definition at line 289 of file training_rate_algorithm.cpp.
void OpenNN::TrainingRateAlgorithm::set_training_rate_method | ( | const std::string & | new_training_rate_method | ) |
Sets the method for obtaining the training rate from a string with the name of the method.
new_training_rate_method | Name of training rate method ("Fixed", "GoldenSection", "BrentMethod" or "UserTrainingRate"). |
Definition at line 300 of file training_rate_algorithm.cpp.
void OpenNN::TrainingRateAlgorithm::set_training_rate_tolerance | ( | const double & | new_training_rate_tolerance | ) |
Sets a new tolerance value to be used in line minimization.
new_training_rate_tolerance | Tolerance value in line minimization. |
Definition at line 360 of file training_rate_algorithm.cpp.
void OpenNN::TrainingRateAlgorithm::set_warning_training_rate | ( | const double & | new_warning_training_rate | ) |
Sets a new training rate value at wich a warning message is written to the screen during line minimization.
new_warning_training_rate | Warning training rate value. |
Definition at line 391 of file training_rate_algorithm.cpp.
tinyxml2::XMLDocument * OpenNN::TrainingRateAlgorithm::to_XML | ( | void | ) | const |
Returns a default string representation in XML-type format of the training algorithm object. This containts the training operators, the training parameters, stopping criteria and other stuff.
Definition at line 999 of file training_rate_algorithm.cpp.