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, NEWTON_METHOD,
  QUASI_NEWTON_METHOD, LEVENBERG_MARQUARDT_ALGORITHM, USER_MAIN
}
 
enum  RefinementType { NO_REFINEMENT, USER_REFINEMENT }
 

Public Member Functions

 TrainingStrategy (void)
 
 TrainingStrategy (LossIndex *)
 
 TrainingStrategy (const tinyxml2::XMLDocument &)
 
 TrainingStrategy (const std::string &)
 
virtual ~TrainingStrategy (void)
 
void check_loss_index (void) const
 
void check_training_algorithms (void) const
 
void initialize_random (void)
 
LossIndexget_loss_index_pointer (void) const
 
bool has_loss_index (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 (LossIndex *)
 
virtual void set_default (void)
 
void set_loss_index_pointer (LossIndex *)
 
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)
 
void initialize_layers_autoencoding (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 write_XML (tinyxml2::XMLPrinter &) const
 
void save (const std::string &) const
 
void load (const std::string &)
 

Protected Attributes

LossIndexloss_index_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 61 of file training_strategy.h.

Constructor & Destructor Documentation

◆ TrainingStrategy() [1/4]

OpenNN::TrainingStrategy::TrainingStrategy ( void  )
explicit

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

Definition at line 27 of file training_strategy.cpp.

◆ TrainingStrategy() [2/4]

OpenNN::TrainingStrategy::TrainingStrategy ( LossIndex new_loss_index_pointer)
explicit

Loss index constructor. It creates a training strategy object associated to a loss functional object. It also constructs the main training algorithm object.

Parameters
new_loss_index_pointerPointer to a loss functional object.

Definition at line 52 of file training_strategy.cpp.

◆ TrainingStrategy() [3/4]

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

XML constructor. It creates a training strategy object not associated to any loss 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.

◆ TrainingStrategy() [4/4]

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

File constructor. It creates a training strategy object associated to a loss 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.

◆ ~TrainingStrategy()

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

◆ check_training_algorithms()

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 173 of file training_strategy.cpp.

◆ from_XML()

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 2550 of file training_strategy.cpp.

◆ get_conjugate_gradient_pointer()

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 341 of file training_strategy.cpp.

◆ get_display()

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 677 of file training_strategy.cpp.

◆ get_evolutionary_algorithm_pointer()

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 297 of file training_strategy.cpp.

◆ get_gradient_descent_pointer()

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 319 of file training_strategy.cpp.

◆ get_Levenberg_Marquardt_algorithm_pointer()

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 385 of file training_strategy.cpp.

◆ get_Newton_method_pointer()

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 407 of file training_strategy.cpp.

◆ get_quasi_Newton_method_pointer()

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 363 of file training_strategy.cpp.

◆ get_random_search_pointer()

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 275 of file training_strategy.cpp.

◆ has_loss_index()

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

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

Definition at line 257 of file training_strategy.cpp.

◆ initialize_layers_autoencoding()

void OpenNN::TrainingStrategy::initialize_layers_autoencoding ( void  )
Todo:

Definition at line 1733 of file training_strategy.cpp.

◆ initialize_random()

void OpenNN::TrainingStrategy::initialize_random ( void  )

Initializes the initialization, main and refinement algorithms at random.

Todo:

Definition at line 195 of file training_strategy.cpp.

◆ load()

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 2816 of file training_strategy.cpp.

◆ perform_training()

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

This is the most important method of this class. It optimizes the loss 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 1821 of file training_strategy.cpp.

◆ save()

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 2800 of file training_strategy.cpp.

◆ set() [1/2]

void OpenNN::TrainingStrategy::set ( void  )

Sets the loss 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 689 of file training_strategy.cpp.

◆ set() [2/2]

void OpenNN::TrainingStrategy::set ( LossIndex new_loss_index_pointer)

Sets a new loss 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_loss_index_pointerPointer to a loss functional object.

Definition at line 708 of file training_strategy.cpp.

◆ set_default()

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

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

  • Display: true.

Definition at line 1299 of file training_strategy.cpp.

◆ set_display()

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 1153 of file training_strategy.cpp.

◆ set_initialization_type() [1/2]

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 725 of file training_strategy.cpp.

◆ set_initialization_type() [2/2]

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 894 of file training_strategy.cpp.

◆ set_loss_index_pointer()

void OpenNN::TrainingStrategy::set_loss_index_pointer ( LossIndex new_loss_index_pointer)

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

Parameters
new_loss_index_pointerPointer to a loss functional object.

Definition at line 1011 of file training_strategy.cpp.

◆ set_main_type() [1/2]

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 777 of file training_strategy.cpp.

◆ set_main_type() [2/2]

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 930 of file training_strategy.cpp.

◆ set_refinement_type() [1/2]

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 848 of file training_strategy.cpp.

◆ set_refinement_type() [2/2]

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 979 of file training_strategy.cpp.

◆ to_XML()

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 2165 of file training_strategy.cpp.

◆ write_XML()

void OpenNN::TrainingStrategy::write_XML ( tinyxml2::XMLPrinter &  file_stream) const

Serializes the training strategy object into a XML document of the TinyXML library without keep the DOM tree in memory. See the OpenNN manual for more information about the format of this document.

Definition at line 2411 of file training_strategy.cpp.


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