growing_inputs.cpp
1// OpenNN: Open Neural Networks Library
2// www.opennn.net
3//
4// G R O W I N G I N P U T S C L A S S
5//
6// Artificial Intelligence Techniques SL
7// artelnics@artelnics.com
8
9#include "growing_inputs.h"
10
11namespace OpenNN
12{
13
15
18{
20}
21
22
25
26GrowingInputs::GrowingInputs(TrainingStrategy* new_training_strategy_pointer)
27 : InputsSelection(new_training_strategy_pointer)
28{
30}
31
32
34
36{
37}
38
39
41
43{
45}
46
47
49
51{
53}
54
55
57
59{
61}
62
63
65
67{
69
70 if(training_strategy_pointer == nullptr || !training_strategy_pointer->has_neural_network())
71 {
73 }
74 else
75 {
77
79
81
82 maximum_inputs_number = inputs_number;
83 }
84
86
87 minimum_correlation = type(0);
88
89 trials_number = 3;
90
92
93 maximum_time = type(3600.0);
94}
95
96
99
100void GrowingInputs::set_maximum_inputs_number(const Index& new_maximum_inputs_number)
101{
102#ifdef OPENNN_DEBUG
103
104 if(new_maximum_inputs_number <= 1)
105 {
106 ostringstream buffer;
107
108 buffer << "OpenNN Exception: GrowingInputs class.\n"
109 << "void set_maximum_selection_failures(const Index&) method.\n"
110 << "Maximum selection failures must be greater than 0.\n";
111
112 throw logic_error(buffer.str());
113 }
114
115#endif
116
117 maximum_inputs_number = new_maximum_inputs_number;
118}
119
120
123
124void GrowingInputs::set_minimum_inputs_number(const Index& new_minimum_inputs_number)
125{
126#ifdef OPENNN_DEBUG
127
128 if(new_minimum_inputs_number == 0)
129 {
130 ostringstream buffer;
131
132 buffer << "OpenNN Exception: GrowingInputs class.\n"
133 << "void set_minimum_inputs_number(const Index&) method.\n"
134 << "Minimum inputs number must be greater than 0.\n";
135
136 throw logic_error(buffer.str());
137 }
138
139#endif
140
141 minimum_inputs_number = new_minimum_inputs_number;
142}
143
144
147
148void GrowingInputs::set_maximum_selection_failures(const Index& new_maximum_selection_failures)
149{
150#ifdef OPENNN_DEBUG
151
152 if(new_maximum_selection_failures <= 0)
153 {
154 ostringstream buffer;
155
156 buffer << "OpenNN Exception: GrowingInputs class.\n"
157 << "void set_maximum_selection_failures(const Index&) method.\n"
158 << "Maximum selection failures must be greater than 0.\n";
159
160 throw logic_error(buffer.str());
161 }
162
163#endif
164
165 maximum_selection_failures = new_maximum_selection_failures;
166}
167
168
170
172{
173#ifdef OPENNN_DEBUG
174
175 check();
176
177#endif
178
179 InputsSelectionResults inputs_selection_results(maximum_epochs_number);
180
181
182 if(display) cout << "Performing growing inputs selection..." << endl;
183
184 // Loss index
185
186 const LossIndex* loss_index_pointer = training_strategy_pointer->get_loss_index_pointer();
187
188 type previus_selection_error = numeric_limits< type>::max();
189
190 // Data set
191
192 DataSet* data_set_pointer = loss_index_pointer->get_data_set_pointer();
193
194 const Tensor<Index, 1> target_columns_indices = data_set_pointer->get_target_columns_indices();
195
196 const Index original_input_columns_number = data_set_pointer->get_input_columns_number();
197
198 const Tensor<string, 1> columns_names = data_set_pointer->get_columns_names();
199
200 Tensor<string, 1> input_columns_names;
201
202 const Tensor<type, 2> correlations = get_correlation_values(data_set_pointer->calculate_input_target_columns_correlations());
203
204 const Tensor<type, 1> total_correlations = correlations.abs().sum(rows_sum);
205
206 Tensor<Index, 1> correlations_rank_descending = data_set_pointer->get_input_columns_indices();
207
208 sort(correlations_rank_descending.data(),
209 correlations_rank_descending.data() + correlations_rank_descending.size(),
210 [&](Index i, Index j){return total_correlations[i] > total_correlations[j];});
211
212 // Neural network
213
215
216 // Training strategy
217
219
220 Index selection_failures = 0;
221
222 TrainingResults training_results;
223
224 // Model selection
225
226 time_t beginning_time, current_time;
227 type elapsed_time = type(0);
228
229 time(&beginning_time);
230
231 bool stop = false;
232
233 data_set_pointer->set_input_columns_unused();
234
235 for(Index i = 1; i <= maximum_epochs_number; i++)
236 {
237 data_set_pointer->set_column_use(correlations_rank_descending[i-1], DataSet::VariableUse::Input);
238
239 const Index input_columns_number = data_set_pointer->get_input_columns_number();
240 const Index input_variables_number = data_set_pointer->get_input_variables_number();
241
242
243
244 if(input_columns_number >= minimum_inputs_number)
245 {
246 long long epoch = input_columns_number-minimum_inputs_number+1;
247 neural_network_pointer->set_inputs_number(input_variables_number);
248
249 if(display)
250 {
251 cout << endl;
252 cout << "Epoch: " << epoch << endl;
253 cout << "Input columns number: " << input_columns_number << endl;
254 cout << "Inputs: " << endl;
255
256 input_columns_names = data_set_pointer->get_input_columns_names();
257
258 for(Index i = 0; i < input_columns_number; i++) cout << " " << input_columns_names(i) << endl;
259 }
260
261 type minimum_training_error = numeric_limits<type>::max();
262 type minimum_selection_error = numeric_limits<type>::max();
263
264 for(Index i = 0; i < trials_number; i++)
265 {
266 neural_network_pointer->set_parameters_random();
267
268 training_results = training_strategy_pointer->perform_training();
269
270 if(display)
271 {
272 cout << "Trial number: " << i+1 << endl;
273 cout << " Training error: " << training_results.get_training_error() << endl;
274 cout << " Selection error: " << training_results.get_selection_error() << endl;
275 }
276
277 if(training_results.get_selection_error() < minimum_selection_error)
278 {
279 minimum_training_error = training_results.get_training_error();
280 minimum_selection_error = training_results.get_selection_error();
281
282 inputs_selection_results.training_error_history(input_columns_number-1) = minimum_training_error;
283 inputs_selection_results.selection_error_history(input_columns_number-1) = minimum_selection_error;
284 }
285
286 if(training_results.get_selection_error() < inputs_selection_results.optimum_selection_error)
287 {
288 // Neural network
289
290 inputs_selection_results.optimal_input_columns_indices = data_set_pointer->get_input_columns_indices();
291 inputs_selection_results.optimal_input_columns_names = data_set_pointer->get_input_columns_names();
292
293 inputs_selection_results.optimal_parameters = neural_network_pointer->get_parameters();
294
295 // Loss index
296
297 inputs_selection_results.optimum_training_error = training_results.get_training_error();
298 inputs_selection_results.optimum_selection_error = training_results.get_selection_error();
299 }
300 }
301
302 if(previus_selection_error < training_results.get_selection_error()) selection_failures++;
303
304 previus_selection_error = training_results.get_selection_error();
305
306 inputs_selection_results.training_error_history(input_columns_number) = training_results.get_training_error();
307
308 inputs_selection_results.selection_error_history(input_columns_number) = training_results.get_selection_error();
309
310 time(&current_time);
311
312 elapsed_time = static_cast<type>(difftime(current_time,beginning_time));
313
314 // Stopping criteria
315
316 if(elapsed_time >= maximum_time)
317 {
318 stop = true;
319
320 if(display) cout << "Epoch " << epoch << endl << "Maximum time reached: " << write_time(elapsed_time) << endl;
321
322 inputs_selection_results.stopping_condition = InputsSelection::StoppingCondition::MaximumTime;
323 }
324 else if(inputs_selection_results.optimum_selection_error <= selection_error_goal)
325 {
326 stop = true;
327
328 if(display) cout << "\nSelection error reached: " << inputs_selection_results.optimum_selection_error << endl;
329
330 inputs_selection_results.stopping_condition = InputsSelection::StoppingCondition::SelectionErrorGoal;
331 }
332 else if(epoch >= maximum_epochs_number)
333 {
334 stop = true;
335
336 if(display) cout << "\nMaximum number of epochs reached." << endl;
337
338 inputs_selection_results.stopping_condition = InputsSelection::StoppingCondition::MaximumEpochs;
339 }
340 else if(selection_failures >= maximum_selection_failures)
341 {
342 stop = true;
343
344 if(display) cout << "\nMaximum selection failures ("<<selection_failures<<") reached." << endl;
345
346 inputs_selection_results.stopping_condition = InputsSelection::StoppingCondition::MaximumSelectionFailures;
347 }
348 else if(input_columns_number >= maximum_inputs_number || input_columns_number >= original_input_columns_number)
349 {
350 stop = true;
351
352 if(display) cout << "\nMaximum inputs (" << input_columns_number << ") reached." << endl;
353
354 inputs_selection_results.stopping_condition = InputsSelection::StoppingCondition::MaximumInputs;
355 }
356
357 if(stop)
358 {
359 inputs_selection_results.elapsed_time = write_time(elapsed_time);
360
361 inputs_selection_results.resize_history(input_columns_number);
362
363 break;
364 }
365 }
366
367 }
368
369 // Set data set stuff
370
371 data_set_pointer->set_input_target_columns(inputs_selection_results.optimal_input_columns_indices, target_columns_indices);
372
373 const Tensor<Scaler, 1> input_variables_scalers = data_set_pointer->get_input_variables_scalers();
374
375 const Tensor<Descriptives, 1> input_variables_descriptives = data_set_pointer->calculate_input_variables_descriptives();
376
377 // Set neural network stuff
378
379 neural_network_pointer->set_inputs_number(data_set_pointer->get_input_variables_number());
380
381 neural_network_pointer->set_inputs_names(data_set_pointer->get_input_variables_names());
382
383 if(neural_network_pointer->has_scaling_layer())
384 neural_network_pointer->get_scaling_layer_pointer()->set(input_variables_descriptives, input_variables_scalers);
385
386 neural_network_pointer->set_parameters(inputs_selection_results.optimal_parameters);
387
388 if(display) inputs_selection_results.print();
389
390 return inputs_selection_results;
391}
392
393
395
396Tensor<string, 2> GrowingInputs::to_string_matrix() const
397{
398 ostringstream buffer;
399
400 Tensor<string, 1> labels(8);
401 Tensor<string, 1> values(8);
402
403 // Trials number
404
405 labels(0) = "Trials number";
406
407 buffer.str("");
408 buffer << trials_number;
409
410 values(0) = buffer.str();
411
412 // Selection loss goal
413
414 labels(1) = "Selection error goal";
415
416 buffer.str("");
417 buffer << selection_error_goal;
418
419 values(1) = buffer.str();
420
421 // Maximum selection failures
422
423 labels(2) = "Maximum selection failures";
424
425 buffer.str("");
427
428 values(2) = buffer.str();
429
430 // Maximum inputs number
431
432 labels(3) = "Maximum inputs number";
433
434 buffer.str("");
435 buffer << maximum_inputs_number;
436
437 values(3) = buffer.str();
438
439 // Minimum correlation
440
441 labels(4) = "Minimum correlations";
442
443 buffer.str("");
444 buffer << minimum_correlation;
445
446 values(4) = buffer.str();
447
448 // Maximum correlation
449
450 labels(5) = "Maximum correlation";
451
452 buffer.str("");
453 buffer << maximum_correlation;
454
455 values(5) = buffer.str();
456
457 // Maximum iterations number
458
459 labels(6) = "Maximum iterations number";
460
461 buffer.str("");
462 buffer << maximum_epochs_number;
463
464 values(6) = buffer.str();
465
466 // Maximum time
467
468 labels(7) = "Maximum time";
469
470 buffer.str("");
471 buffer << maximum_time;
472
473 values(7) = buffer.str();
474
475 const Index rows_number = labels.size();
476 const Index columns_number = 2;
477
478 Tensor<string, 2> string_matrix(rows_number, columns_number);
479
480 string_matrix.chip(0, 1) = labels;
481 string_matrix.chip(1, 1) = values;
482
483 return string_matrix;
484}
485
486
489
491{
492 ostringstream buffer;
493
494 file_stream.OpenElement("GrowingInputs");
495
496 // Trials number
497
498 file_stream.OpenElement("TrialsNumber");
499
500 buffer.str("");
501 buffer << trials_number;
502
503 file_stream.PushText(buffer.str().c_str());
504
505 file_stream.CloseElement();
506
507 // selection error goal
508
509 file_stream.OpenElement("SelectionErrorGoal");
510
511 buffer.str("");
512 buffer << selection_error_goal;
513
514 file_stream.PushText(buffer.str().c_str());
515
516 file_stream.CloseElement();
517
518 // Maximum selection failures
519
520 file_stream.OpenElement("MaximumSelectionFailures");
521
522 buffer.str("");
524
525 file_stream.PushText(buffer.str().c_str());
526
527 file_stream.CloseElement();
528
529 // Minimum inputs number
530
531 file_stream.OpenElement("MinimumInputsNumber");
532
533 buffer.str("");
534 buffer << minimum_inputs_number;
535
536 file_stream.PushText(buffer.str().c_str());
537
538 file_stream.CloseElement();
539
540 // Maximum inputs number
541
542 file_stream.OpenElement("MaximumInputsNumber");
543
544 buffer.str("");
545 buffer << maximum_inputs_number;
546
547 file_stream.PushText(buffer.str().c_str());
548
549 file_stream.CloseElement();
550
551 // Minimum correlation
552
553 file_stream.OpenElement("MinimumCorrelation");
554
555 buffer.str("");
556 buffer << minimum_correlation;
557
558 file_stream.PushText(buffer.str().c_str());
559
560 file_stream.CloseElement();
561
562 // Maximum correlation
563
564 file_stream.OpenElement("MaximumCorrelation");
565
566 buffer.str("");
567 buffer << maximum_correlation;
568
569 file_stream.PushText(buffer.str().c_str());
570
571 file_stream.CloseElement();
572
573 // Maximum iterations
574
575 file_stream.OpenElement("MaximumEpochsNumber");
576
577 buffer.str("");
578 buffer << maximum_epochs_number;
579
580 file_stream.PushText(buffer.str().c_str());
581
582 file_stream.CloseElement();
583
584 // Maximum time
585
586 file_stream.OpenElement("MaximumTime");
587
588 buffer.str("");
589 buffer << maximum_time;
590
591 file_stream.PushText(buffer.str().c_str());
592
593 file_stream.CloseElement();
594
595 file_stream.CloseElement();
596}
597
598
601
603{
604 const tinyxml2::XMLElement* root_element = document.FirstChildElement("GrowingInputs");
605
606 if(!root_element)
607 {
608 ostringstream buffer;
609
610 buffer << "OpenNN Exception: GrowingInputs class.\n"
611 << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
612 << "GrowingInputs element is nullptr.\n";
613
614 throw logic_error(buffer.str());
615 }
616
617 // Trials number
618 {
619 const tinyxml2::XMLElement* element = root_element->FirstChildElement("TrialsNumber");
620
621 if(element)
622 {
623 const Index new_trials_number = static_cast<Index>(atoi(element->GetText()));
624
625 try
626 {
627 set_trials_number(new_trials_number);
628 }
629 catch(const logic_error& e)
630 {
631 cerr << e.what() << endl;
632 }
633 }
634 }
635
636 // Display
637 {
638 const tinyxml2::XMLElement* element = root_element->FirstChildElement("Display");
639
640 if(element)
641 {
642 const string new_display = element->GetText();
643
644 try
645 {
646 set_display(new_display != "0");
647 }
648 catch(const logic_error& e)
649 {
650 cerr << e.what() << endl;
651 }
652 }
653 }
654
655 // selection error goal
656 {
657 const tinyxml2::XMLElement* element = root_element->FirstChildElement("SelectionErrorGoal");
658
659 if(element)
660 {
661 const type new_selection_error_goal = static_cast<type>(atof(element->GetText()));
662
663 try
664 {
665 set_selection_error_goal(new_selection_error_goal);
666 }
667 catch(const logic_error& e)
668 {
669 cerr << e.what() << endl;
670 }
671 }
672 }
673
674 // Maximum iterations number
675 {
676 const tinyxml2::XMLElement* element = root_element->FirstChildElement("MaximumEpochsNumber");
677
678 if(element)
679 {
680 const Index new_maximum_epochs_number = static_cast<Index>(atoi(element->GetText()));
681
682 try
683 {
684 set_maximum_epochs_number(new_maximum_epochs_number);
685 }
686 catch(const logic_error& e)
687 {
688 cerr << e.what() << endl;
689 }
690 }
691 }
692
693 // Maximum correlation
694 {
695 const tinyxml2::XMLElement* element = root_element->FirstChildElement("MaximumCorrelation");
696
697 if(element)
698 {
699 const type new_maximum_correlation = static_cast<type>(atof(element->GetText()));
700
701 try
702 {
703 set_maximum_correlation(new_maximum_correlation);
704 }
705 catch(const logic_error& e)
706 {
707 cerr << e.what() << endl;
708 }
709 }
710 }
711
712 // Minimum correlation
713 {
714 const tinyxml2::XMLElement* element = root_element->FirstChildElement("MinimumCorrelation");
715
716 if(element)
717 {
718 const type new_minimum_correlation = static_cast<type>(atof(element->GetText()));
719
720 try
721 {
722 set_minimum_correlation(new_minimum_correlation);
723 }
724 catch(const logic_error& e)
725 {
726 cerr << e.what() << endl;
727 }
728 }
729 }
730
731 // Maximum time
732 {
733 const tinyxml2::XMLElement* element = root_element->FirstChildElement("MaximumTime");
734
735 if(element)
736 {
737 const type new_maximum_time = static_cast<type>(atof(element->GetText()));
738
739 try
740 {
741 set_maximum_time(new_maximum_time);
742 }
743 catch(const logic_error& e)
744 {
745 cerr << e.what() << endl;
746 }
747 }
748
749 }
750
751 // Minimum inputs number
752 {
753 const tinyxml2::XMLElement* element = root_element->FirstChildElement("MinimumInputsNumber");
754
755 if(element)
756 {
757 const Index new_minimum_inputs_number = static_cast<Index>(atoi(element->GetText()));
758
759 try
760 {
761 set_minimum_inputs_number(new_minimum_inputs_number);
762 }
763 catch(const logic_error& e)
764 {
765 cerr << e.what() << endl;
766 }
767 }
768
769 }
770
771 // Maximum inputs number
772 {
773 const tinyxml2::XMLElement* element = root_element->FirstChildElement("MaximumInputsNumber");
774
775 if(element)
776 {
777 const Index new_maximum_inputs_number = static_cast<Index>(atoi(element->GetText()));
778
779 try
780 {
781 set_maximum_inputs_number(new_maximum_inputs_number);
782 }
783 catch(const logic_error& e)
784 {
785 cerr << e.what() << endl;
786 }
787 }
788 }
789
790 // Maximum selection failures
791 {
792 const tinyxml2::XMLElement* element = root_element->FirstChildElement("MaximumSelectionFailures");
793
794 if(element)
795 {
796 const Index new_maximum_selection_failures = static_cast<Index>(atoi(element->GetText()));
797
798 try
799 {
800 set_maximum_selection_failures(new_maximum_selection_failures);
801 }
802 catch(const logic_error& e)
803 {
804 cerr << e.what() << endl;
805 }
806 }
807 }
808
809}
810
811
814
815void GrowingInputs::save(const string& file_name) const
816{
817 FILE * file = fopen(file_name.c_str(), "w");
818
819 tinyxml2::XMLPrinter printer(file);
820
821 write_XML(printer);
822
823 fclose(file);
824}
825
826
829
830void GrowingInputs::load(const string& file_name)
831{
832 set_default();
833
834 tinyxml2::XMLDocument document;
835
836 if(document.LoadFile(file_name.c_str()))
837 {
838 ostringstream buffer;
839
840 buffer << "OpenNN Exception: GrowingInputs class.\n"
841 << "void load(const string&) method.\n"
842 << "Cannot load XML file " << file_name << ".\n";
843
844 throw logic_error(buffer.str());
845 }
846
847 from_XML(document);
848}
849
850}
851
852// OpenNN: Open Neural Networks Library.
853// Copyright(C) 2005-2021 Artificial Intelligence Techniques, SL.
854//
855// This library is free software; you can redistribute it and/or
856// modify it under the terms of the GNU Lesser General Public
857// License as published by the Free Software Foundation; either
858// version 2.1 of the License, or any later version.
859//
860// This library is distributed in the hope that it will be useful,
861// but WITHOUT ANY WARRANTY; without even the implied warranty of
862// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
863// Lesser General Public License for more details.
864
865// You should have received a copy of the GNU Lesser General Public
866// License along with this library; if not, write to the Free Software
867// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
This class represents the concept of data set for data modelling problems, such as approximation,...
Definition: data_set.h:57
Tensor< string, 1 > get_columns_names() const
Returns a string vector that contains the names of the columns.
Definition: data_set.cpp:2473
Tensor< Descriptives, 1 > calculate_input_variables_descriptives() const
Definition: data_set.cpp:5726
Tensor< Index, 1 > get_target_columns_indices() const
Returns a indices vector with the positions of the targets.
Definition: data_set.cpp:2315
Tensor< Index, 1 > get_input_columns_indices() const
Returns a indices vector with the positions of the inputs.
Definition: data_set.cpp:2271
Index get_input_variables_number() const
Definition: data_set.cpp:2859
Tensor< Correlation, 2 > calculate_input_target_columns_correlations() const
Definition: data_set.cpp:5876
Tensor< string, 1 > get_input_columns_names() const
Returns a string vector that contains the names of the columns whose uses are Input.
Definition: data_set.cpp:2505
void set_input_columns_unused()
Sets all input columns in the data_set as unused columns.
Definition: data_set.cpp:3229
Tensor< string, 1 > get_input_variables_names() const
Definition: data_set.cpp:2184
void set_column_use(const Index &, const VariableUse &)
Definition: data_set.cpp:3255
Index get_input_columns_number() const
Returns the number of columns whose uses are Input.
Definition: data_set.cpp:2575
void set_maximum_selection_failures(const Index &)
const Index & get_maximum_inputs_number() const
Returns the maximum number of inputs in the growing inputs selection algorithm.
const Index & get_minimum_inputs_number() const
Returns the minimum number of inputs in the growing inputs selection algorithm.
void from_XML(const tinyxml2::XMLDocument &)
void set_default()
Sets the members of the growing inputs object to their default values.
void load(const string &)
Tensor< string, 2 > to_string_matrix() const
Writes as matrix of strings the most representative atributes.
InputsSelectionResults perform_inputs_selection()
Perform inputs selection with the growing inputs method.
Index maximum_inputs_number
Maximum number of inputs in the neural network.
void set_maximum_inputs_number(const Index &)
void save(const string &) const
Index minimum_inputs_number
Minimum number of inputs in the neural network.
virtual ~GrowingInputs()
Destructor.
GrowingInputs()
Default constructor.
void set_minimum_inputs_number(const Index &)
void write_XML(tinyxml2::XMLPrinter &) const
const Index & get_maximum_selection_failures() const
Returns the maximum number of selection failures in the growing inputs selection algorithm.
Index maximum_selection_failures
Maximum number of epochs at which the selection error increases.
This abstract class represents the concept of inputs selection algorithm for a ModelSelection[1].
TrainingStrategy * training_strategy_pointer
Pointer to a training strategy object.
void set_selection_error_goal(const type &)
void check() const
Checks that the different pointers needed for performing the inputs selection are not nullptr.
Index trials_number
Number of trials for each neural network.
void set_maximum_correlation(const type &)
bool display
Display messages to screen.
type selection_error_goal
Goal value for the selection error. It is used as a stopping criterion.
void set_maximum_time(const type &)
const string write_time(const type &) const
Writes the time from seconds in format HH:mm:ss.
type maximum_time
Maximum selection algorithm time. It is used as a stopping criterion.
void set_maximum_epochs_number(const Index &)
type minimum_correlation
Minimum value for the correlations.
Index maximum_epochs_number
Maximum number of epochs to perform_inputs_selection. It is used as a stopping criterion.
void set_display(const bool &)
void set_minimum_correlation(const type &)
type maximum_correlation
Maximum value for the correlations.
void set_trials_number(const Index &)
This abstract class represents the concept of loss index composed of an error term and a regularizati...
Definition: loss_index.h:48
DataSet * get_data_set_pointer() const
Returns a pointer to the data set object associated to the error term.
Definition: loss_index.h:92
ScalingLayer * get_scaling_layer_pointer() const
Returns a pointer to the scaling layers object composing this neural network object.
bool has_scaling_layer() const
const bool & get_display() const
Index get_inputs_number() const
Returns the number of inputs to the neural network.
void set_inputs_number(const Index &)
void set_parameters(Tensor< type, 1 > &)
void set_inputs_names(const Tensor< string, 1 > &)
Tensor< type, 1 > get_parameters() const
void set()
Sets the scaling layer to be empty.
This class represents the concept of training strategy for a neural network in OpenNN.
TrainingResults perform_training()
LossIndex * get_loss_index_pointer()
Returns a pointer to the LossIndex class.
NeuralNetwork * get_neural_network_pointer() const
Returns a pointer to the NeuralNetwork class.
void set_display(const bool &)
void PushText(const char *text, bool cdata=false)
Add a text node.
Definition: tinyxml2.cpp:2878
virtual void CloseElement(bool compactMode=false)
If streaming, close the Element.
Definition: tinyxml2.cpp:2834
This structure contains the results from the inputs selection.
Tensor< string, 1 > optimal_input_columns_names
Inputs of the neural network with minimum selection error.
type optimum_training_error
Value of training for the neural network with minimum selection error.
Tensor< type, 1 > selection_error_history
Final selection errors of the different neural networks.
Tensor< type, 1 > optimal_parameters
Vector of parameters for the neural network with minimum selection error.
InputsSelection::StoppingCondition stopping_condition
Stopping condition of the algorithm.
type optimum_selection_error
Value of minimum selection error.
Tensor< type, 1 > training_error_history
Final training errors of the different neural networks.
string elapsed_time
Elapsed time during the loss of the algortihm.
This structure contains the optimization algorithm results.