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

#include <training_strategy.h>

Classes

struct  Results
 

Public Types

enum  InitializationType { NO_INITIALIZATION, RANDOM_SEARCH, EVOLUTIONARY_ALGORITHM, USER_INITIALIZATION }
 
enum  MainType {
  NO_MAIN, GRADIENT_DESCENT, CONJUGATE_GRADIENT, QUASI_NEWTON_METHOD,
  LEVENBERG_MARQUARDT_ALGORITHM, USER_MAIN
}
 
enum  RefinementType { NO_REFINEMENT, NEWTON_METHOD, USER_REFINEMENT }
 

Public Member Functions

 TrainingStrategy (void)
 
 TrainingStrategy (PerformanceFunctional *)
 
 TrainingStrategy (const tinyxml2::XMLDocument &)
 
 TrainingStrategy (const std::string &)
 
virtual ~TrainingStrategy (void)
 
void check_performance_functional (void) const
 
void check_training_algorithms (void) const
 
void initialize_random (void)
 
PerformanceFunctionalget_performance_functional_pointer (void) const
 
bool has_performance_functional (void) const
 
RandomSearchget_random_search_pointer (void) const
 
EvolutionaryAlgorithmget_evolutionary_algorithm_pointer (void) const
 
GradientDescentget_gradient_descent_pointer (void) const
 
ConjugateGradientget_conjugate_gradient_pointer (void) const
 
QuasiNewtonMethodget_quasi_Newton_method_pointer (void) const
 
LevenbergMarquardtAlgorithmget_Levenberg_Marquardt_algorithm_pointer (void) const
 
NewtonMethodget_Newton_method_pointer (void) const
 
const InitializationTypeget_initialization_type (void) const
 
const MainTypeget_main_type (void) const
 
const RefinementTypeget_refinement_type (void) const
 
std::string write_initialization_type (void) const
 
std::string write_main_type (void) const
 
std::string write_refinement_type (void) const
 
std::string write_initialization_type_text (void) const
 
std::string write_main_type_text (void) const
 
std::string write_refinement_type_text (void) const
 
const bool & get_display (void) const
 
void set (void)
 
void set (PerformanceFunctional *)
 
virtual void set_default (void)
 
void set_performance_functional_pointer (PerformanceFunctional *)
 
void set_initialization_type (const InitializationType &)
 
void set_main_type (const MainType &)
 
void set_refinement_type (const RefinementType &)
 
void set_initialization_type (const std::string &)
 
void set_main_type (const std::string &)
 
void set_refinement_type (const std::string &)
 
void set_display (const bool &)
 
void destruct_initialization (void)
 
void destruct_main (void)
 
void destruct_refinement (void)
 
Results perform_training (void)
 
std::string to_string (void) const
 
void print (void) const
 
tinyxml2::XMLDocument * to_XML (void) const
 
void from_XML (const tinyxml2::XMLDocument &)
 
void save (const std::string &) const
 
void load (const std::string &)
 

Protected Attributes

PerformanceFunctionalperformance_functional_pointer
 
RandomSearchrandom_search_pointer
 
EvolutionaryAlgorithmevolutionary_algorithm_pointer
 
GradientDescentgradient_descent_pointer
 
ConjugateGradientconjugate_gradient_pointer
 
QuasiNewtonMethodquasi_Newton_method_pointer
 
LevenbergMarquardtAlgorithmLevenberg_Marquardt_algorithm_pointer
 
NewtonMethodNewton_method_pointer
 
InitializationType initialization_type
 
MainType main_type
 
RefinementType refinement_type
 
bool display
 

Detailed Description

This class represents the concept of training strategy for a neural network. A training strategy is composed of three training algorithms:

Definition at line 58 of file training_strategy.h.

Constructor & Destructor Documentation

OpenNN::TrainingStrategy::TrainingStrategy ( void  )
explicit

Default constructor. It creates a training strategy object not associated to any performance functional object. It also constructs the main training algorithm object.

Definition at line 27 of file training_strategy.cpp.

OpenNN::TrainingStrategy::TrainingStrategy ( PerformanceFunctional new_performance_functional_pointer)
explicit

Performance functional constructor. It creates a training strategy object associated to a performance functional object. It also constructs the main training algorithm object.

Parameters
new_performance_functional_pointerPointer to a performance functional object.

Definition at line 52 of file training_strategy.cpp.

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

XML constructor. It creates a training strategy object not associated to any performance functional object. It also loads the members of this object from a XML document.

Parameters
documentDocument of the TinyXML library.

Definition at line 77 of file training_strategy.cpp.

OpenNN::TrainingStrategy::TrainingStrategy ( const std::string &  file_name)
explicit

File constructor. It creates a training strategy object associated to a performance functional object. It also loads the members of this object from a XML file.

Parameters
file_nameName of training strategy XML file.

Definition at line 104 of file training_strategy.cpp.

OpenNN::TrainingStrategy::~TrainingStrategy ( void  )
virtual

Destructor. This destructor deletes the initialization, main and refinement training algorithm objects.

Definition at line 129 of file training_strategy.cpp.

Member Function Documentation

void OpenNN::TrainingStrategy::check_training_algorithms ( void  ) const

Throws an exception if the training strategy does not have any initialization, main or refinement algorithms.

Definition at line 170 of file training_strategy.cpp.

void OpenNN::TrainingStrategy::from_XML ( const tinyxml2::XMLDocument &  document)

Loads the members of this training strategy object from a XML document.

Parameters
documentXML document of the TinyXML library.

Definition at line 1784 of file training_strategy.cpp.

ConjugateGradient * OpenNN::TrainingStrategy::get_conjugate_gradient_pointer ( void  ) const

Returns a pointer to the conjugate gradient main algorithm. It also throws an exception if that pointer is NULL.

Definition at line 338 of file training_strategy.cpp.

const bool & OpenNN::TrainingStrategy::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 674 of file training_strategy.cpp.

EvolutionaryAlgorithm * OpenNN::TrainingStrategy::get_evolutionary_algorithm_pointer ( void  ) const

Returns a pointer to the evolutionary algorithm initialization algorithm. It also throws an exception if that pointer is NULL.

Definition at line 294 of file training_strategy.cpp.

GradientDescent * OpenNN::TrainingStrategy::get_gradient_descent_pointer ( void  ) const

Returns a pointer to the gradient descent main algorithm. It also throws an exception if that pointer is NULL.

Definition at line 316 of file training_strategy.cpp.

LevenbergMarquardtAlgorithm * OpenNN::TrainingStrategy::get_Levenberg_Marquardt_algorithm_pointer ( void  ) const

Returns a pointer to the Levenberg-Marquardt main algorithm. It also throws an exception if that pointer is NULL.

Definition at line 382 of file training_strategy.cpp.

NewtonMethod * OpenNN::TrainingStrategy::get_Newton_method_pointer ( void  ) const

Returns a pointer to the Newton method refinement algorithm. It also throws an exception if that pointer is NULL.

Definition at line 404 of file training_strategy.cpp.

QuasiNewtonMethod * OpenNN::TrainingStrategy::get_quasi_Newton_method_pointer ( void  ) const

Returns a pointer to the Newton method main algorithm. It also throws an exception if that pointer is NULL.

Definition at line 360 of file training_strategy.cpp.

RandomSearch * OpenNN::TrainingStrategy::get_random_search_pointer ( void  ) const

Returns a pointer to the random search initialization algorithm. It also throws an exception if that pointer is NULL.

Definition at line 272 of file training_strategy.cpp.

bool OpenNN::TrainingStrategy::has_performance_functional ( void  ) const

Returns true if this training strategy has a performance functional associated, and false otherwise.

Definition at line 254 of file training_strategy.cpp.

void OpenNN::TrainingStrategy::initialize_random ( void  )

Initializes the initialization, main and refinement algorithms at random.

Todo:

Definition at line 192 of file training_strategy.cpp.

void OpenNN::TrainingStrategy::load ( const std::string &  file_name)

Loads a gradient descent object from a XML-type file. Please mind about the file format, wich is specified in the User's Guide.

Parameters
file_nameName of training algorithm XML-type file.

Definition at line 2050 of file training_strategy.cpp.

TrainingStrategy::Results OpenNN::TrainingStrategy::perform_training ( void  )

This is the most important method of this class. It optimizes the performance functional of a neural network. The most general training strategy consists of three steps: initialization, main and refinement training processes. This method also returns a structure with the results from training.

Definition at line 1219 of file training_strategy.cpp.

void OpenNN::TrainingStrategy::save ( const std::string &  file_name) const

Saves to a XML-type file the members of the training algorithm object.

Parameters
file_nameName of training algorithm XML-type file.

Definition at line 2034 of file training_strategy.cpp.

void OpenNN::TrainingStrategy::set ( void  )

Sets the performance functional pointer to NULL. It also destructs the initialization, main and refinement training algorithms. Finally, it sets the rest of members to their default values.

Definition at line 686 of file training_strategy.cpp.

void OpenNN::TrainingStrategy::set ( PerformanceFunctional new_performance_functional_pointer)

Sets a new performance functional pointer. It also destructs the initialization, main and refinement training algorithms. Finally, it sets the rest of members to their default values.

Parameters
new_performance_functional_pointerPointer to a performance functional object.

Definition at line 705 of file training_strategy.cpp.

void OpenNN::TrainingStrategy::set_default ( void  )
virtual

Sets the members of the training strategy object to their default values:

  • Display: true.

Definition at line 1153 of file training_strategy.cpp.

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

Parameters
new_displayDisplay value.

Definition at line 1140 of file training_strategy.cpp.

void OpenNN::TrainingStrategy::set_initialization_type ( const InitializationType new_initialization_type)

Sets a new type of initialization training algorithm.

Parameters
new_initialization_typeType of initialization training algorithm.

Definition at line 722 of file training_strategy.cpp.

void OpenNN::TrainingStrategy::set_initialization_type ( const std::string &  new_initialization_type)

Sets a new initialization training algorithm from a string.

Parameters
new_initialization_typeString with the initialization type.

Definition at line 885 of file training_strategy.cpp.

void OpenNN::TrainingStrategy::set_main_type ( const MainType new_main_type)

Sets a new type of main training algorithm.

Parameters
new_main_typeType of main training algorithm.

Definition at line 774 of file training_strategy.cpp.

void OpenNN::TrainingStrategy::set_main_type ( const std::string &  new_main_type)

Sets a new main training algorithm from a string containing the type.

Parameters
new_main_typeString with the type of main training algorithm.

Definition at line 921 of file training_strategy.cpp.

void OpenNN::TrainingStrategy::set_performance_functional_pointer ( PerformanceFunctional new_performance_functional_pointer)

Sets a pointer to a performance functional object to be associated to the training strategy.

Parameters
new_performance_functional_pointerPointer to a performance functional object.

Definition at line 998 of file training_strategy.cpp.

void OpenNN::TrainingStrategy::set_refinement_type ( const RefinementType new_refinement_type)

Sets a new type of refinement algorithm into this training strategy. Note that it destructs the current refinement algorithm object and constructs a new one.

Parameters
new_refinement_typeType of refinement training algorithm.

Definition at line 839 of file training_strategy.cpp.

void OpenNN::TrainingStrategy::set_refinement_type ( const std::string &  new_refinement_type)

Sets a new refinement algorithm from a string. It destructs the previous refinement algorithm object and constructs a new object.

Parameters
new_refinement_typeString with the refinement training algorithm type.

Definition at line 966 of file training_strategy.cpp.

tinyxml2::XMLDocument * OpenNN::TrainingStrategy::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 1538 of file training_strategy.cpp.


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