9#ifndef OPTIMIZATIONALGORITHM_H
10#define OPTIMIZATIONALGORITHM_H
26#include "tensor_utilities.h"
27#include "loss_index.h"
36struct TrainingResults;
55 MaximumSelectionErrorIncreases, MaximumEpochsNumber, MaximumTime};
87 virtual void set_threads_number(
const int&);
100 virtual void check()
const;
106 virtual string write_optimization_algorithm_type()
const {
return string();}
110 virtual void print()
const;
118 void save(
const string&)
const;
119 void load(
const string&);
123 NonBlockingThreadPool* non_blocking_thread_pool =
nullptr;
124 ThreadPoolDevice* thread_pool_device;
156 const Eigen::array<IndexPair<Index>, 1> AT_B = {IndexPair<Index>(0, 0)};
157 const Eigen::array<IndexPair<Index>, 1> product_vector_matrix = {IndexPair<Index>(0, 1)};
158 const Eigen::array<IndexPair<Index>, 1> A_B = {IndexPair<Index>(1, 0)};
161 #include "../../opennn-cuda/opennn-cuda/optimization_algorithm_cuda.h"
179 cout <<
"Potential parameters:" << endl;
180 cout << potential_parameters << endl;
182 cout <<
"Training direction:" << endl;
183 cout << training_direction << endl;
185 cout <<
"Initial learning rate:" << endl;
186 cout << initial_learning_rate << endl;
189 Tensor<type, 1> potential_parameters;
190 Tensor<type, 1> training_direction;
191 type initial_learning_rate = type(0);
220 type get_training_error()
227 type get_selection_error()
236 void save(
const string&)
const;
238 void print(
const string& message =
string())
240 cout << message << endl;
244 cout <<
"Training results" << endl;
245 cout <<
"Epochs number: " << epochs_number-1 << endl;
This abstract class represents the concept of loss index composed of an error term and a regularizati...
void set_display_period(const Index &)
string neural_network_file_name
Path where the neural network is saved.
virtual void set_loss_index_pointer(LossIndex *)
const bool & get_display() const
void set_hardware_use(const string &)
Set hardware to use. Default: Multi-core.
string get_hardware_use() const
Hardware use.
virtual void from_XML(const tinyxml2::XMLDocument &)
virtual void set_default()
Sets the members of the optimization algorithm object to their default values.
void set_neural_network_file_name(const string &)
LossIndex * loss_index_pointer
Pointer to a loss index for a neural network object.
virtual void check() const
void load(const string &)
bool display
Display messages to screen.
virtual Tensor< string, 2 > to_string_matrix() const
void set_save_period(const Index &)
const Index & get_display_period() const
Returns the number of iterations between the training showing progress.
const string write_time(const type &) const
Writes the time from seconds in format HH:mm:ss.
void save(const string &) const
Index save_period
Number of iterations between the training saving progress.
bool has_loss_index() const
const string & get_neural_network_file_name() const
Returns the file name where the neural network will be saved.
const Index & get_save_period() const
Returns the number of iterations between the training saving progress.
string hardware_use
Hardware use.
virtual void print() const
Prints to the screen the XML-type representation of the optimization algorithm object.
virtual void set_display(const bool &)
virtual void write_XML(tinyxml2::XMLPrinter &) const
StoppingCondition
Enumeration of all possibles condition of stop for the algorithms.
virtual ~OptimizationAlgorithm()
Destructor.
LossIndex * get_loss_index_pointer() const
virtual TrainingResults perform_training()=0
Trains a neural network which has a loss index associated.
Index epochs_number
Number of training epochs in the neural network.
Index display_period
Number of iterations between the training showing progress.
HALF_CONSTEXPR half abs(half arg)
Extensions to the C++ standard library.
This structure contains the optimization algorithm results.
Tensor< type, 1 > selection_error_history
History of the selection error over the training iterations.
Tensor< string, 2 > write_final_results(const Index &=3) const
Writes final results of the training.
void resize_training_error_history(const Index &)
Resizes the training error history keeping the values.
void save(const string &) const
Returns a string representation of the results structure.
OptimizationAlgorithm::StoppingCondition stopping_condition
Stopping condition of the algorithm.
TrainingResults()
Default constructor.
virtual ~TrainingResults()
Destructor.
void resize_selection_error_history(const Index &)
Resizes the selection error history keeping the values.
Tensor< type, 1 > training_error_history
History of the loss function loss over the training iterations.
string elapsed_time
Elapsed time of the training process.
string write_stopping_condition() const
Return a string with the stopping condition of the Results.