OpenNN  2.2
Open Neural Networks Library
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
OpenNN::QuasiNewtonMethod Class Reference

#include <quasi_newton_method.h>

Inheritance diagram for OpenNN::QuasiNewtonMethod:
OpenNN::TrainingAlgorithm

Classes

struct  QuasiNewtonMethodResults
 

Public Types

enum  InverseHessianApproximationMethod { DFP, BFGS }
 

Public Member Functions

 QuasiNewtonMethod (void)
 
 QuasiNewtonMethod (PerformanceFunctional *)
 
 QuasiNewtonMethod (const tinyxml2::XMLDocument &)
 
virtual ~QuasiNewtonMethod (void)
 
const TrainingRateAlgorithmget_training_rate_algorithm (void) const
 
TrainingRateAlgorithmget_training_rate_algorithm_pointer (void)
 
const InverseHessianApproximationMethodget_inverse_Hessian_approximation_method (void) const
 
std::string write_inverse_Hessian_approximation_method (void) const
 
const double & get_warning_parameters_norm (void) const
 
const double & get_warning_gradient_norm (void) const
 
const double & get_warning_training_rate (void) const
 
const double & get_error_parameters_norm (void) const
 
const double & get_error_gradient_norm (void) const
 
const double & get_error_training_rate (void) const
 
const double & get_minimum_parameters_increment_norm (void) const
 
const double & get_minimum_performance_increase (void) const
 
const double & get_performance_goal (void) const
 
const double & get_gradient_norm_goal (void) const
 
const size_t & get_maximum_generalization_performance_decreases (void) const
 
const size_t & get_maximum_iterations_number (void) const
 
const double & get_maximum_time (void) const
 
const bool & get_reserve_parameters_history (void) const
 
const bool & get_reserve_parameters_norm_history (void) const
 
const bool & get_reserve_performance_history (void) const
 
const bool & get_reserve_gradient_history (void) const
 
const bool & get_reserve_gradient_norm_history (void) const
 
const bool & get_reserve_inverse_Hessian_history (void) const
 
const bool & get_reserve_generalization_performance_history (void) const
 
const bool & get_reserve_training_direction_history (void) const
 
const bool & get_reserve_training_rate_history (void) const
 
const bool & get_reserve_elapsed_time_history (void) const
 
void set_performance_functional_pointer (PerformanceFunctional *)
 
void set_inverse_Hessian_approximation_method (const InverseHessianApproximationMethod &)
 
void set_inverse_Hessian_approximation_method (const std::string &)
 
void set_default (void)
 
void set_warning_parameters_norm (const double &)
 
void set_warning_gradient_norm (const double &)
 
void set_warning_training_rate (const double &)
 
void set_error_parameters_norm (const double &)
 
void set_error_gradient_norm (const double &)
 
void set_error_training_rate (const double &)
 
void set_minimum_parameters_increment_norm (const double &)
 
void set_minimum_performance_increase (const double &)
 
void set_performance_goal (const double &)
 
void set_gradient_norm_goal (const double &)
 
void set_maximum_generalization_performance_decreases (const size_t &)
 
void set_maximum_iterations_number (const size_t &)
 
void set_maximum_time (const double &)
 
void set_reserve_parameters_history (const bool &)
 
void set_reserve_parameters_norm_history (const bool &)
 
void set_reserve_performance_history (const bool &)
 
void set_reserve_gradient_history (const bool &)
 
void set_reserve_gradient_norm_history (const bool &)
 
void set_reserve_inverse_Hessian_history (const bool &)
 
void set_reserve_generalization_performance_history (const bool &)
 
void set_reserve_training_direction_history (const bool &)
 
void set_reserve_training_rate_history (const bool &)
 
void set_reserve_elapsed_time_history (const bool &)
 
void set_display_period (const size_t &)
 
Vector< double > calculate_gradient_descent_training_direction (const Vector< double > &) const
 
Matrix< double > calculate_DFP_inverse_Hessian (const Vector< double > &, const Vector< double > &, const Vector< double > &, const Vector< double > &, const Matrix< double > &) const
 
Matrix< double > calculate_BFGS_inverse_Hessian (const Vector< double > &, const Vector< double > &, const Vector< double > &, const Vector< double > &, const Matrix< double > &) const
 
Matrix< double > calculate_inverse_Hessian_approximation (const Vector< double > &, const Vector< double > &, const Vector< double > &, const Vector< double > &, const Matrix< double > &) const
 
Vector< double > calculate_training_direction (const Vector< double > &, const Matrix< double > &) const
 
QuasiNewtonMethodResultsperform_training (void)
 
void set_reserve_all_training_history (const bool &)
 
std::string write_training_algorithm_type (void) const
 
tinyxml2::XMLDocument * to_XML (void) const
 
std::string to_string (void) const
 
Matrix< std::string > to_string_matrix (void) const
 
void from_XML (const tinyxml2::XMLDocument &)
 
- Public Member Functions inherited from OpenNN::TrainingAlgorithm
 TrainingAlgorithm (void)
 
 TrainingAlgorithm (PerformanceFunctional *)
 
 TrainingAlgorithm (const tinyxml2::XMLDocument &)
 
virtual ~TrainingAlgorithm (void)
 
virtual TrainingAlgorithmoperator= (const TrainingAlgorithm &)
 
virtual bool operator== (const TrainingAlgorithm &) const
 
PerformanceFunctionalget_performance_functional_pointer (void) const
 
bool has_performance_functional (void) const
 
const bool & get_display (void) const
 
const size_t & get_display_period (void) const
 
const size_t & get_save_period (void) const
 
const std::string & get_neural_network_file_name (void) const
 
void set (void)
 
void set (PerformanceFunctional *)
 
void set_display (const bool &)
 
void set_display_period (const size_t &)
 
void set_save_period (const size_t &)
 
void set_neural_network_file_name (const std::string &)
 
virtual void check (void) const
 
void print (void) const
 
void save (const std::string &) const
 
void load (const std::string &)
 
virtual void initialize_random (void)
 

Private Attributes

TrainingRateAlgorithm training_rate_algorithm
 
InverseHessianApproximationMethod inverse_Hessian_approximation_method
 
double warning_parameters_norm
 
double warning_gradient_norm
 
double warning_training_rate
 
double error_parameters_norm
 
double error_gradient_norm
 
double error_training_rate
 
double minimum_parameters_increment_norm
 
double minimum_performance_increase
 
double performance_goal
 
double gradient_norm_goal
 
size_t maximum_generalization_performance_decreases
 
size_t maximum_iterations_number
 
double maximum_time
 
bool reserve_parameters_history
 
bool reserve_parameters_norm_history
 
bool reserve_performance_history
 
bool reserve_gradient_history
 
bool reserve_gradient_norm_history
 
bool reserve_inverse_Hessian_history
 
bool reserve_training_direction_history
 
bool reserve_training_rate_history
 
bool reserve_elapsed_time_history
 
bool reserve_generalization_performance_history
 

Additional Inherited Members

- Protected Attributes inherited from OpenNN::TrainingAlgorithm
PerformanceFunctionalperformance_functional_pointer
 
size_t display_period
 
size_t save_period
 
std::string neural_network_file_name
 
bool display
 

Detailed Description

This concrete class represents a quasi-Newton training algorithm for a performance functional of a neural network.

Definition at line 47 of file quasi_newton_method.h.

Constructor & Destructor Documentation

OpenNN::QuasiNewtonMethod::QuasiNewtonMethod ( void  )
explicit

Default constructor. It creates a quasi-Newton method training algorithm not associated to any performance functional. It also initializes the class members to their default values.

Definition at line 29 of file quasi_newton_method.cpp.

OpenNN::QuasiNewtonMethod::QuasiNewtonMethod ( PerformanceFunctional new_performance_functional_pointer)
explicit

Performance functional constructor. It creates a quasi-Newton method training algorithm associated to a performance functional. It also initializes the class members to their default values.

Parameters
new_performance_functional_pointerPointer to a performance functional object.

Definition at line 43 of file quasi_newton_method.cpp.

OpenNN::QuasiNewtonMethod::QuasiNewtonMethod ( const tinyxml2::XMLDocument &  document)
explicit

XML constructor. It creates a quasi-Newton method training algorithm not associated to any performance functional. It also initializes the class members to their default values.

Definition at line 58 of file quasi_newton_method.cpp.

OpenNN::QuasiNewtonMethod::~QuasiNewtonMethod ( void  )
virtual

Destructor. It does not delete any object.

Definition at line 70 of file quasi_newton_method.cpp.

Member Function Documentation

Matrix< double > OpenNN::QuasiNewtonMethod::calculate_BFGS_inverse_Hessian ( const Vector< double > &  old_parameters,
const Vector< double > &  parameters,
const Vector< double > &  old_gradient,
const Vector< double > &  gradient,
const Matrix< double > &  old_inverse_Hessian 
) const

Returns an approximation of the inverse Hessian matrix according to the Broyden-Fletcher-Goldfarb-Shanno (BGFS) algorithm.

Parameters
old_parametersA previous set of parameters.
old_gradientThe gradient of the objective function for that previous set of parameters.
old_inverse_HessianThe Hessian of the objective function for that previous set of parameters.
parametersActual set of parameters.
gradientThe gradient of the objective function for the actual set of parameters.

Definition at line 1264 of file quasi_newton_method.cpp.

Matrix< double > OpenNN::QuasiNewtonMethod::calculate_DFP_inverse_Hessian ( const Vector< double > &  old_parameters,
const Vector< double > &  parameters,
const Vector< double > &  old_gradient,
const Vector< double > &  gradient,
const Matrix< double > &  old_inverse_Hessian 
) const

Returns an approximation of the inverse Hessian matrix according to the Davidon-Fletcher-Powel (DFP) algorithm.

Parameters
old_parametersA previous set of parameters.
old_gradientThe gradient of the objective function for that previous set of parameters.
old_inverse_HessianThe Hessian of the objective function for that previous set of parameters.
parametersActual set of parameters.
gradientThe gradient of the objective function for the actual set of parameters.

Definition at line 1113 of file quasi_newton_method.cpp.

Vector< double > OpenNN::QuasiNewtonMethod::calculate_gradient_descent_training_direction ( const Vector< double > &  gradient) const

Returns the gradient descent training direction, which is the negative of the normalized gradient.

Parameters
gradientGradient vector.

Definition at line 1061 of file quasi_newton_method.cpp.

Matrix< double > OpenNN::QuasiNewtonMethod::calculate_inverse_Hessian_approximation ( const Vector< double > &  old_parameters,
const Vector< double > &  parameters,
const Vector< double > &  old_gradient,
const Vector< double > &  gradient,
const Matrix< double > &  old_inverse_Hessian 
) const

Calculates an approximation of the inverse Hessian, accoring to the method used.

Parameters
old_parametersAnother point of the objective function.
parametersCurrent point of the objective function
old_gradientGradient at the other point.
gradientGradient at the current point.
old_inverse_HessianInverse Hessian at the other point of the objective function.

Definition at line 1010 of file quasi_newton_method.cpp.

Vector< double > OpenNN::QuasiNewtonMethod::calculate_training_direction ( const Vector< double > &  gradient,
const Matrix< double > &  inverse_Hessian_approximation 
) const

Returns the quasi-Newton method training direction, which has been previously normalized.

Parameters
gradientGradient vector.
inverse_Hessian_approximationInverse Hessian approximation matrix.

Definition at line 1050 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::from_XML ( const tinyxml2::XMLDocument &  document)
virtual

Loads a default training algorithm from a XML document.

Parameters
documentTinyXML document containing the performance term members.

Reimplemented from OpenNN::TrainingAlgorithm.

Definition at line 2712 of file quasi_newton_method.cpp.

const double & OpenNN::QuasiNewtonMethod::get_error_gradient_norm ( void  ) const

Returns the value for the norm of the gradient vector at wich an error message is written to the screen and the program exits.

Definition at line 189 of file quasi_newton_method.cpp.

const double & OpenNN::QuasiNewtonMethod::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 200 of file quasi_newton_method.cpp.

const double & OpenNN::QuasiNewtonMethod::get_gradient_norm_goal ( void  ) const

Returns the goal value for the norm of the objective function gradient. This is used as a stopping criterion when training a multilayer perceptron

Definition at line 242 of file quasi_newton_method.cpp.

const double & OpenNN::QuasiNewtonMethod::get_performance_goal ( void  ) const

Returns the goal value for the performance. This is used as a stopping criterion when training a multilayer perceptron

Definition at line 231 of file quasi_newton_method.cpp.

QuasiNewtonMethod::QuasiNewtonMethodResults * OpenNN::QuasiNewtonMethod::perform_training ( void  )
virtual

Trains a neural network with an associated performance functional according to the quasi-Newton method. Training occurs according to the training operators, training parameters and stopping criteria.

Implements OpenNN::TrainingAlgorithm.

Definition at line 1707 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_display_period ( const size_t &  new_display_period)

Sets a new number of iterations between the training showing progress.

Parameters
new_display_periodNumber of iterations between the training showing progress.

Definition at line 975 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_error_gradient_norm ( const double &  new_error_gradient_norm)

Sets a new value for the gradient vector norm at which an error message is written to the screen and the program exits.

Parameters
new_error_gradient_normError norm of gradient vector value.

Definition at line 638 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_error_parameters_norm ( const double &  new_error_parameters_norm)

Sets a new value for the parameters vector norm at which an error message is written to the screen and the program exits.

Parameters
new_error_parameters_normError norm of parameters vector value.

Definition at line 607 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::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.

Parameters
new_error_training_rateError training rate value.

Definition at line 669 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_gradient_norm_goal ( const double &  new_gradient_norm_goal)

Sets a new the goal value for the norm of the objective function gradient. This is used as a stopping criterion when training a multilayer perceptron

Parameters
new_gradient_norm_goalGoal value for the norm of the objective function gradient.

Definition at line 772 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_inverse_Hessian_approximation_method ( const InverseHessianApproximationMethod new_inverse_Hessian_approximation_method)

Sets a new inverse Hessian approximatation method value.

Parameters
new_inverse_Hessian_approximation_methodInverse Hessian approximation method value.

Definition at line 399 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_inverse_Hessian_approximation_method ( const std::string &  new_inverse_Hessian_approximation_method_name)

Sets a new method for approximating the inverse of the Hessian matrix from a string containing the name. Possible values are:

  • "DFP"
  • "BFGS"
Parameters
new_inverse_Hessian_approximation_method_nameName of inverse Hessian approximation method.

Definition at line 416 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_maximum_generalization_performance_decreases ( const size_t &  new_maximum_generalization_performance_decreases)

Sets a new maximum number of generalization failures.

Parameters
new_maximum_generalization_performance_decreasesMaximum number of iterations in which the generalization evalutation decreases.

Definition at line 802 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_maximum_iterations_number ( const size_t &  new_maximum_iterations_number)

Sets a maximum number of iterations for training.

Parameters
new_maximum_iterations_numberMaximum number of iterations for training.

Definition at line 815 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_maximum_time ( const double &  new_maximum_time)

Sets a new maximum training time.

Parameters
new_maximum_timeMaximum training time.

Definition at line 828 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_minimum_parameters_increment_norm ( const double &  new_minimum_parameters_increment_norm)

Sets a new value for the minimum parameters increment norm stopping criterion.

Parameters
new_minimum_parameters_increment_normValue of norm of parameters increment norm used to stop training.

Definition at line 699 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_minimum_performance_increase ( const double &  new_minimum_performance_increase)

Sets a new minimum performance improvement during training.

Parameters
new_minimum_performance_increaseMinimum improvement in the performance between two iterations.

Definition at line 729 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_performance_functional_pointer ( PerformanceFunctional new_performance_functional_pointer)
virtual

Sets a pointer to a performance functional object to be associated to the quasi-Newton method object. It also sets that performance functional to the training rate algorithm.

Parameters
new_performance_functional_pointerPointer to a performance functional object.

Reimplemented from OpenNN::TrainingAlgorithm.

Definition at line 386 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_performance_goal ( const double &  new_performance_goal)

Sets a new goal value for the performance. This is used as a stopping criterion when training a multilayer perceptron

Parameters
new_performance_goalGoal value for the performance.

Definition at line 760 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_reserve_all_training_history ( const bool &  new_reserve_all_training_history)

Makes the training history of all variables to reseved or not in memory.

Parameters
new_reserve_all_training_historyTrue if the training history of all variables is to be reserved, false otherwise.

Definition at line 445 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_reserve_elapsed_time_history ( const bool &  new_reserve_elapsed_time_history)

Makes the elapsed time over the iterations to be reseved or not in memory. This is a vector.

Parameters
new_reserve_elapsed_time_historyTrue if the elapsed time history vector is to be reserved, false otherwise.

Definition at line 951 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_reserve_generalization_performance_history ( const bool &  new_reserve_generalization_performance_history)

Makes the Generalization performance history to be reserved or not in memory. This is a vector.

Parameters
new_reserve_generalization_performance_historyTrue if the Generalization performance history is to be reserved, false otherwise.

Definition at line 963 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_reserve_gradient_history ( const bool &  new_reserve_gradient_history)

Makes the gradient history vector of vectors to be reseved or not in memory.

Parameters
new_reserve_gradient_historyTrue if the gradient history matrix is to be reserved, false otherwise.

Definition at line 891 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_reserve_gradient_norm_history ( const bool &  new_reserve_gradient_norm_history)

Makes the gradient norm history vector to be reseved or not in memory.

Parameters
new_reserve_gradient_norm_historyTrue if the gradient norm history matrix is to be reserved, false otherwise.

Definition at line 903 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_reserve_inverse_Hessian_history ( const bool &  new_reserve_inverse_Hessian_history)

Sets the history of the inverse of the Hessian matrix to be reserved or not in memory. This is a vector of matrices.

Parameters
new_reserve_inverse_Hessian_historyTrue if the inverse Hessian history is to be reserved, false otherwise.

Definition at line 915 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_reserve_parameters_history ( const bool &  new_reserve_parameters_history)

Makes the parameters history vector of vectors to be reseved or not in memory.

Parameters
new_reserve_parameters_historyTrue if the parameters history vector of vectors is to be reserved, false otherwise.

Definition at line 858 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_reserve_parameters_norm_history ( const bool &  new_reserve_parameters_norm_history)

Makes the parameters norm history vector to be reseved or not in memory.

Parameters
new_reserve_parameters_norm_historyTrue if the parameters norm history vector is to be reserved, false otherwise.

Definition at line 869 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_reserve_performance_history ( const bool &  new_reserve_performance_history)

Makes the performance history vector to be reseved or not in memory.

Parameters
new_reserve_performance_historyTrue if the performance history vector is to be reserved, false otherwise.

Definition at line 880 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_reserve_training_direction_history ( const bool &  new_reserve_training_direction_history)

Makes the training direction history vector of vectors to be reseved or not in memory.

Parameters
new_reserve_training_direction_historyTrue if the training direction history matrix is to be reserved, false otherwise.

Definition at line 927 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_reserve_training_rate_history ( const bool &  new_reserve_training_rate_history)

Makes the training rate history vector to be reseved or not in memory.

Parameters
new_reserve_training_rate_historyTrue if the training rate history vector is to be reserved, false otherwise.

Definition at line 939 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_warning_gradient_norm ( const double &  new_warning_gradient_norm)

Sets a new value for the gradient vector norm at which a warning message is written to the screen.

Parameters
new_warning_gradient_normWarning norm of gradient vector value.

Definition at line 547 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::set_warning_parameters_norm ( const double &  new_warning_parameters_norm)

Sets a new value for the parameters vector norm at which a warning message is written to the screen.

Parameters
new_warning_parameters_normWarning norm of parameters vector value.

Definition at line 516 of file quasi_newton_method.cpp.

void OpenNN::QuasiNewtonMethod::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.

Parameters
new_warning_training_rateWarning training rate value.

Definition at line 578 of file quasi_newton_method.cpp.

Matrix< std::string > OpenNN::QuasiNewtonMethod::to_string_matrix ( void  ) const
virtual

Returns a default (empty) string matrix containing the members of the training algorithm object.

Reimplemented from OpenNN::TrainingAlgorithm.

Definition at line 2542 of file quasi_newton_method.cpp.

tinyxml2::XMLDocument * OpenNN::QuasiNewtonMethod::to_XML ( void  ) const
virtual

Returns a XML-type string representation of this quasi-Newton method object. It contains the training methods and parameters chosen, as well as the stopping criteria and other user stuff concerning the quasi-Newton method object.

Reimplemented from OpenNN::TrainingAlgorithm.

Definition at line 2149 of file quasi_newton_method.cpp.

Member Data Documentation

size_t OpenNN::QuasiNewtonMethod::maximum_generalization_performance_decreases
private

Maximum number of iterations at which the generalization performance decreases. This is an early stopping method for improving generalization.

Definition at line 399 of file quasi_newton_method.h.

TrainingRateAlgorithm OpenNN::QuasiNewtonMethod::training_rate_algorithm
private

Training rate algorithm object. It is used to calculate the step for the quasi-Newton training direction.

Definition at line 346 of file quasi_newton_method.h.


The documentation for this class was generated from the following files: