9#include "inputs_selection.h"
17 : training_strategy_pointer(nullptr)
27 : training_strategy_pointer(new_training_strategy_pointer)
50 buffer <<
"OpenNN Exception: InputsSelection class.\n"
51 <<
"DataSet* get_training_strategy_pointer() const method.\n"
52 <<
"Training strategy pointer is nullptr.\n";
54 throw logic_error(buffer.str());
170 if(new_trials_number <= 0)
172 ostringstream buffer;
173 buffer <<
"OpenNN Exception: InputsSelection class.\n"
174 <<
"void set_trials_number(const Index&) method.\n"
175 <<
"Number of assays must be greater than 0.\n";
177 throw logic_error(buffer.str());
204 if(new_selection_error_goal < 0)
206 ostringstream buffer;
208 buffer <<
"OpenNN Exception: InputsSelection class.\n"
209 <<
"void set_selection_error_goal(const type&) method.\n"
210 <<
"Selection loss goal must be greater or equal than 0.\n";
212 throw logic_error(buffer.str());
237 if(new_maximum_time < 0)
239 ostringstream buffer;
241 buffer <<
"OpenNN Exception: InputsSelection class.\n"
242 <<
"void set_maximum_time(const type&) method.\n"
243 <<
"Maximum time must be greater than 0.\n";
245 throw logic_error(buffer.str());
261 if(new_maximum_correlation < 0 || new_maximum_correlation > 1)
263 ostringstream buffer;
265 buffer <<
"OpenNN Exception: InputsSelection class.\n"
266 <<
"void set_maximum_correlation(const type&) method.\n"
267 <<
"Maximum correlation must be comprised between 0 and 1.\n";
269 throw logic_error(buffer.str());
285 if(new_minimum_correlation < 0 || new_minimum_correlation > 1)
287 ostringstream buffer;
289 buffer <<
"OpenNN Exception: InputsSelection class.\n"
290 <<
"void set_minimum_correlation(const type&) method.\n"
291 <<
"Minimum correaltion must be comprised between 0 and 1.\n";
293 throw logic_error(buffer.str());
315 ostringstream buffer;
319 buffer <<
"OpenNN Exception: InputsSelection class.\n"
320 <<
"void check() const method.\n"
321 <<
"Pointer to training strategy is nullptr.\n";
323 throw logic_error(buffer.str());
334 buffer <<
"OpenNN Exception: InputsSelection class.\n"
335 <<
"void check() const method.\n"
336 <<
"Pointer to neural network is nullptr.\n";
338 throw logic_error(buffer.str());
343 if(neural_network_pointer->
is_empty())
345 buffer <<
"OpenNN Exception: InputsSelection class.\n"
346 <<
"void check() const method.\n"
347 <<
"Neural network is empty.\n";
349 throw logic_error(buffer.str());
356 buffer <<
"OpenNN Exception: InputsSelection class.\n"
357 <<
"void check() const method.\n"
358 <<
"Pointer to data set is nullptr.\n";
360 throw logic_error(buffer.str());
367 if(selection_samples_number == 0)
369 buffer <<
"OpenNN Exception: InputsSelection class.\n"
370 <<
"void check() const method.\n"
371 <<
"Number of selection samples is zero.\n";
373 throw logic_error(buffer.str());
384 case InputsSelection::StoppingCondition::MaximumTime:
385 return "MaximumTime";
387 case InputsSelection::StoppingCondition::SelectionErrorGoal:
388 return "SelectionErrorGoal";
390 case InputsSelection::StoppingCondition::MaximumInputs:
391 return "MaximumInputs";
393 case InputsSelection::StoppingCondition::MinimumInputs:
394 return "MinimumInputs";
396 case InputsSelection::StoppingCondition::MaximumEpochs:
397 return "MaximumEpochs";
399 case InputsSelection::StoppingCondition::MaximumSelectionFailures:
400 return "MaximumSelectionFailures";
402 case InputsSelection::StoppingCondition::CorrelationGoal:
403 return "CorrelationGoal";
417 if(time >
static_cast<type
>(3600e5))
419 ostringstream buffer;
421 buffer <<
"OpenNN Exception: OptimizationAlgorithm class.\n"
422 <<
"const string write_time(const type& time) const method.\n"
423 <<
"Time must be lower than 10e5 seconds.\n";
425 throw logic_error(buffer.str());
428 if(time <
static_cast<type
>(0))
430 ostringstream buffer;
432 buffer <<
"OpenNN Exception: OptimizationAlgorithm class.\n"
433 <<
"const string write_time(const type& time) const method.\n"
434 <<
"Time must be greater than 0.\n";
436 throw logic_error(buffer.str());
440 int hours =
static_cast<int>(time) / 3600;
441 int seconds =
static_cast<int>(time) % 3600;
442 int minutes = seconds / 60;
443 seconds = seconds % 60;
445 ostringstream elapsed_time;
447 elapsed_time << setfill(
'0') << setw(2) << hours <<
":"
448 << setfill(
'0') << setw(2) << minutes <<
":"
449 << setfill(
'0') << setw(2) << seconds << endl;
451 return elapsed_time.str();
463 if(uses.size() < inputs_number)
465 ostringstream buffer;
467 buffer <<
"OpenNN Exception: InputsSelection class.\n"
468 <<
"const Index get_input_index(const Tensor<DataSet::VariableUse, 1>, const Index) method.\n"
469 <<
"Size of uses vector("<< uses.size() <<
") must be greater than " << inputs_number <<
".\n";
471 throw logic_error(buffer.str());
479 while(i < uses.size())
481 if(uses[i] == DataSet::VariableUse::Input && inputs_number == j)
485 else if(uses[i] == DataSet::VariableUse::Input)
This class represents the concept of data set for data modelling problems, such as approximation,...
Index get_selection_samples_number() const
Returns the number of samples in the data set which will be used for selection.
This abstract class represents the concept of loss index composed of an error term and a regularizati...
bool has_data_set() const
bool has_neural_network() const
NeuralNetwork * get_neural_network_pointer() const
Returns a pointer to the neural network object associated to the error term.
DataSet * get_data_set_pointer() const
Returns a pointer to the data set object associated to the error term.
This class represents the concept of training strategy for a neural network in OpenNN.
LossIndex * get_loss_index_pointer()
Returns a pointer to the LossIndex class.
This structure contains the optimization algorithm results.
string write_stopping_condition() const
Return a string with the stopping condition of the Results.