MachineIntelligenceCore:Toolchain
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ContinuousLearningApplication.cpp
Go to the documentation of this file.
1 
24 #ifdef _WIN32
25 #include <system_utils/windows_extras.hpp>
26 #endif
27 
28 namespace mic {
29 namespace application {
30 
32  learning_iterations_to_test_ratio("learning_iterations_to_test_ratio", 50),
33  number_of_averaged_test_measures("number_of_averaged_test_measures", 5)
34 {
35  // Register properties - so their values can be overridden (read from the configuration file).
38 
39  // Reset learning iteration counter.
41 }
42 
44 
45  // Start from learning.
46  APP_STATE->setLearningModeOn();
47 
48  // Main application loop.
49  while (!APP_STATE->Quit()) {
50 
51  // If not paused.
52  if (!APP_STATE->isPaused()) {
53  // If single step mode - pause after the step.
54  if (APP_STATE->isSingleStepModeOn())
55  APP_STATE->pressPause();
56 
57  // Enter critical section - with the use of scoped lock from AppState!
59 
60  // Increment iteration number - at START!
61  iteration++;
62  // Perform single step and - if required - break the loop.
63  if (!performSingleStep())
64  break;
65 
66  } //: if! is paused & end of critical section
67 
68  // Sleep.
69  APP_SLEEP();
70  }//: while
71 }
72 
74  // Check the iteration number and settings.
75  // If learning is on AND (NOT equal to learning_iterations_to_test_ratio) - learn!
76  if (((iteration % learning_iterations_to_test_ratio) != 0) && APP_STATE->isLearningModeOn()) {
77  // Perform learning.
78  return performLearningStep();
79  } else { // Else - test
80  // Perform testing.
81  return performTestingStep();
82  }//: else
83 }
84 
86  // Increment iteration number - at START!
88 
89  LOG(LDEBUG) << "iteration=" << iteration << "learning_iteration=" << learning_iteration << " learning_iteration % number_of_averaged_test_measures =" << learning_iteration % number_of_averaged_test_measures;
90 
91  // Perform testing - two phases.
93 
94  // If a given number of measures were collected - average them and populate (i.e. visualize).
96 
98  // Reset learning iteration counter.
100  }//: if iteration
101 
102  return true;
103 } //: if test mode (!learning)
104 
105 
106 } /* namespace application */
107 } /* namespace mic */
#define LDEBUG
Definition: LoggerAux.hpp:53
Contains declaration of a base class for all continuous learning type applications.
#define APP_SLEEP()
Macro which sleeps the application for a time specified by the sleep_interval variable stored in APP_...
virtual bool performSingleStep(void)
Performs single step of computations - switches between learning and testing depending on the iterati...
Base class for all applications.
Definition: Application.hpp:38
mic::configuration::Property< unsigned int > learning_iterations_to_test_ratio
Number of learning steps after which a single classification test will be performed.
#define APP_STATE
Macro returning application state instance.
unsigned long learning_iteration
Learning iteration counter - used in interlaces learning/testing mode.
#define APP_DATA_SYNCHRONIZATION_SCOPED_LOCK()
Macro creating a scoped lock with the use of data_synchronizaton_mutex stored by WindowManager.
unsigned long iteration
Iteration counter.
Definition: Application.hpp:72
mic::configuration::Property< unsigned int > number_of_averaged_test_measures
Numbers of steps that will be averages.
#define LOG(level)
Macro for message printing.
Definition: Log.hpp:39
void registerProperty(PropertyInterface &prop)