GPHIKClassifier.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. /**
  2. * @file GPHIKClassifier.cpp
  3. * @brief Main interface for our GP HIK classifier (similar to the feature pool classifier interface in vislearning) (Implementation)
  4. * @author Erik Rodner, Alexander Freytag
  5. * @date 02/01/2012
  6. */
  7. // STL includes
  8. #include <iostream>
  9. // NICE-core includes
  10. #include <core/basics/numerictools.h>
  11. #include <core/basics/Timer.h>
  12. // gp-hik-core includes
  13. #include "GPHIKClassifier.h"
  14. #include "gp-hik-core/parameterizedFunctions/PFAbsExp.h"
  15. #include "gp-hik-core/parameterizedFunctions/PFExp.h"
  16. #include "gp-hik-core/parameterizedFunctions/PFMKL.h"
  17. using namespace std;
  18. using namespace NICE;
  19. /////////////////////////////////////////////////////
  20. /////////////////////////////////////////////////////
  21. // PROTECTED METHODS
  22. /////////////////////////////////////////////////////
  23. /////////////////////////////////////////////////////
  24. void GPHIKClassifier::init(const Config *conf, const string & s_confSection)
  25. {
  26. //copy the given config to have it accessible lateron
  27. if ( this->confCopy != conf )
  28. {
  29. if ( this->confCopy != NULL )
  30. delete this->confCopy;
  31. this->confCopy = new Config ( *conf );
  32. //we do not want to read until end of file for restoring
  33. this->confCopy->setIoUntilEndOfFile(false);
  34. }
  35. double parameterUpperBound = confCopy->gD(confSection, "parameter_upper_bound", 5.0 );
  36. double parameterLowerBound = confCopy->gD(confSection, "parameter_lower_bound", 1.0 );
  37. this->noise = confCopy->gD(confSection, "noise", 0.01);
  38. string transform = confCopy->gS(confSection, "transform", "absexp" );
  39. if (pf == NULL)
  40. {
  41. if ( transform == "absexp" )
  42. {
  43. this->pf = new PFAbsExp( 1.0, parameterLowerBound, parameterUpperBound );
  44. } else if ( transform == "exp" ) {
  45. this->pf = new PFExp( 1.0, parameterLowerBound, parameterUpperBound );
  46. }else if ( transform == "MKL" ) {
  47. //TODO generic, please :) load from a separate file or something like this!
  48. std::set<int> steps; steps.insert(4000); steps.insert(6000); //specific for VISAPP
  49. this->pf = new PFMKL( steps, parameterLowerBound, parameterUpperBound );
  50. } else {
  51. fthrow(Exception, "Transformation type is unknown " << transform);
  52. }
  53. }
  54. else
  55. {
  56. //we already know the pf from the restore-function
  57. }
  58. this->confSection = confSection;
  59. this->verbose = confCopy->gB(confSection, "verbose", false);
  60. this->debug = confCopy->gB(confSection, "debug", false);
  61. this->uncertaintyPredictionForClassification = confCopy->gB( confSection, "uncertaintyPredictionForClassification", false );
  62. //how do we approximate the predictive variance for classification uncertainty?
  63. string s_varianceApproximation = confCopy->gS(confSection, "varianceApproximation", "approximate_fine"); //default: fine approximative uncertainty prediction
  64. if ( (s_varianceApproximation.compare("approximate_rough") == 0) || ((s_varianceApproximation.compare("1") == 0)) )
  65. {
  66. this->varianceApproximation = APPROXIMATE_ROUGH;
  67. //no additional eigenvalue is needed here at all.
  68. this->confCopy->sI ( confSection, "nrOfEigenvaluesToConsiderForVarApprox", 0 );
  69. }
  70. else if ( (s_varianceApproximation.compare("approximate_fine") == 0) || ((s_varianceApproximation.compare("2") == 0)) )
  71. {
  72. this->varianceApproximation = APPROXIMATE_FINE;
  73. //security check - compute at least one eigenvalue for this approximation strategy
  74. this->confCopy->sI ( confSection, "nrOfEigenvaluesToConsiderForVarApprox", std::max( confCopy->gI(confSection, "nrOfEigenvaluesToConsiderForVarApprox", 1 ), 1) );
  75. }
  76. else if ( (s_varianceApproximation.compare("exact") == 0) || ((s_varianceApproximation.compare("3") == 0)) )
  77. {
  78. this->varianceApproximation = EXACT;
  79. //no additional eigenvalue is needed here at all.
  80. this->confCopy->sI ( confSection, "nrOfEigenvaluesToConsiderForVarApprox", 1 );
  81. }
  82. else
  83. {
  84. this->varianceApproximation = NONE;
  85. //no additional eigenvalue is needed here at all.
  86. this->confCopy->sI ( confSection, "nrOfEigenvaluesToConsiderForVarApprox", 1 );
  87. }
  88. if ( this->verbose )
  89. std::cerr << "varianceApproximationStrategy: " << s_varianceApproximation << std::endl;
  90. }
  91. /////////////////////////////////////////////////////
  92. /////////////////////////////////////////////////////
  93. // PUBLIC METHODS
  94. /////////////////////////////////////////////////////
  95. /////////////////////////////////////////////////////
  96. GPHIKClassifier::GPHIKClassifier( const Config *conf, const string & s_confSection )
  97. {
  98. //default settings, may be overwritten lateron
  99. gphyper = NULL;
  100. pf = NULL;
  101. confCopy = NULL;
  102. //just a default value
  103. uncertaintyPredictionForClassification = false;
  104. this->confSection = s_confSection;
  105. // if no config file was given, we either restore the classifier from an external file, or run ::init with
  106. // an emtpy config (using default values thereby) when calling the train-method
  107. if ( conf != NULL )
  108. {
  109. this->init(conf, confSection);
  110. }
  111. }
  112. GPHIKClassifier::~GPHIKClassifier()
  113. {
  114. if ( gphyper != NULL )
  115. delete gphyper;
  116. if (pf != NULL)
  117. delete pf;
  118. if ( confCopy != NULL )
  119. delete confCopy;
  120. }
  121. ///////////////////// ///////////////////// /////////////////////
  122. // GET / SET
  123. ///////////////////// ///////////////////// /////////////////////
  124. std::set<int> GPHIKClassifier::getKnownClassNumbers ( ) const
  125. {
  126. if (gphyper == NULL)
  127. fthrow(Exception, "Classifier not trained yet -- aborting!" );
  128. return gphyper->getKnownClassNumbers();
  129. }
  130. ///////////////////// ///////////////////// /////////////////////
  131. // CLASSIFIER STUFF
  132. ///////////////////// ///////////////////// /////////////////////
  133. void GPHIKClassifier::classify ( const SparseVector * example, int & result, SparseVector & scores ) const
  134. {
  135. double tmpUncertainty;
  136. this->classify( example, result, scores, tmpUncertainty );
  137. }
  138. void GPHIKClassifier::classify ( const NICE::Vector * example, int & result, SparseVector & scores ) const
  139. {
  140. double tmpUncertainty;
  141. this->classify( example, result, scores, tmpUncertainty );
  142. }
  143. void GPHIKClassifier::classify ( const SparseVector * example, int & result, SparseVector & scores, double & uncertainty ) const
  144. {
  145. if (gphyper == NULL)
  146. fthrow(Exception, "Classifier not trained yet -- aborting!" );
  147. scores.clear();
  148. result = gphyper->classify ( *example, scores );
  149. if ( scores.size() == 0 ) {
  150. fthrow(Exception, "Zero scores, something is likely to be wrong here: svec.size() = " << example->size() );
  151. }
  152. if (uncertaintyPredictionForClassification)
  153. {
  154. if (varianceApproximation != NONE)
  155. {
  156. this->predictUncertainty( example, uncertainty );
  157. }
  158. else
  159. {
  160. //do nothing
  161. uncertainty = std::numeric_limits<double>::max();
  162. }
  163. }
  164. else
  165. {
  166. //do nothing
  167. uncertainty = std::numeric_limits<double>::max();
  168. }
  169. }
  170. void GPHIKClassifier::classify ( const NICE::Vector * example, int & result, SparseVector & scores, double & uncertainty ) const
  171. {
  172. if (gphyper == NULL)
  173. fthrow(Exception, "Classifier not trained yet -- aborting!" );
  174. scores.clear();
  175. result = gphyper->classify ( *example, scores );
  176. if ( scores.size() == 0 ) {
  177. fthrow(Exception, "Zero scores, something is likely to be wrong here: svec.size() = " << example->size() );
  178. }
  179. if (uncertaintyPredictionForClassification)
  180. {
  181. if (varianceApproximation != NONE)
  182. {
  183. this->predictUncertainty( example, uncertainty );
  184. }
  185. else
  186. {
  187. //do nothing
  188. uncertainty = std::numeric_limits<double>::max();
  189. }
  190. }
  191. else
  192. {
  193. //do nothing
  194. uncertainty = std::numeric_limits<double>::max();
  195. }
  196. }
  197. /** training process */
  198. void GPHIKClassifier::train ( const std::vector< const NICE::SparseVector *> & examples, const NICE::Vector & labels )
  199. {
  200. if (verbose)
  201. {
  202. std::cerr << "GPHIKClassifier::train" << std::endl;
  203. }
  204. if ( this->confCopy == NULL )
  205. {
  206. std::cerr << "WARNING -- No config used so far, initialize values with empty config file now..." << std::endl;
  207. NICE::Config tmpConfEmpty ;
  208. this->init ( &tmpConfEmpty, this->confSection );
  209. }
  210. Timer t;
  211. t.start();
  212. FastMinKernel *fmk = new FastMinKernel ( examples, noise, this->debug );
  213. t.stop();
  214. if (verbose)
  215. std::cerr << "Time used for setting up the fmk object: " << t.getLast() << std::endl;
  216. if (gphyper != NULL)
  217. delete gphyper;
  218. if ( ( varianceApproximation != APPROXIMATE_FINE) )
  219. confCopy->sI ( confSection, "nrOfEigenvaluesToConsiderForVarApprox", 0);
  220. gphyper = new FMKGPHyperparameterOptimization ( confCopy, pf, fmk, confSection );
  221. if (verbose)
  222. cerr << "Learning ..." << endl;
  223. // go go go
  224. gphyper->optimize ( labels );
  225. if (verbose)
  226. std::cerr << "optimization done" << std::endl;
  227. if ( ( varianceApproximation != NONE ) )
  228. {
  229. switch (varianceApproximation)
  230. {
  231. case APPROXIMATE_ROUGH:
  232. {
  233. gphyper->prepareVarianceApproximationRough();
  234. break;
  235. }
  236. case APPROXIMATE_FINE:
  237. {
  238. gphyper->prepareVarianceApproximationFine();
  239. break;
  240. }
  241. case EXACT:
  242. {
  243. //nothing to prepare
  244. break;
  245. }
  246. default:
  247. {
  248. //nothing to prepare
  249. }
  250. }
  251. }
  252. // clean up all examples ??
  253. if (verbose)
  254. std::cerr << "Learning finished" << std::endl;
  255. }
  256. /** training process */
  257. void GPHIKClassifier::train ( const std::vector< const NICE::SparseVector *> & examples, std::map<int, NICE::Vector> & binLabels )
  258. {
  259. if (verbose)
  260. std::cerr << "GPHIKClassifier::train" << std::endl;
  261. if ( this->confCopy == NULL )
  262. {
  263. std::cerr << "WARNING -- No config used so far, initialize values with empty config file now..." << std::endl;
  264. NICE::Config tmpConfEmpty ;
  265. this->init ( &tmpConfEmpty, this->confSection );
  266. }
  267. Timer t;
  268. t.start();
  269. FastMinKernel *fmk = new FastMinKernel ( examples, noise, this->debug );
  270. t.stop();
  271. if (verbose)
  272. std::cerr << "Time used for setting up the fmk object: " << t.getLast() << std::endl;
  273. if (gphyper != NULL)
  274. delete gphyper;
  275. gphyper = new FMKGPHyperparameterOptimization ( confCopy, pf, fmk, confSection );
  276. if (verbose)
  277. cerr << "Learning ..." << endl;
  278. // go go go
  279. gphyper->optimize ( binLabels );
  280. if (verbose)
  281. std::cerr << "optimization done, now prepare for the uncertainty prediction" << std::endl;
  282. if ( ( varianceApproximation != NONE ) )
  283. {
  284. switch (varianceApproximation)
  285. {
  286. case APPROXIMATE_ROUGH:
  287. {
  288. gphyper->prepareVarianceApproximationRough();
  289. break;
  290. }
  291. case APPROXIMATE_FINE:
  292. {
  293. gphyper->prepareVarianceApproximationFine();
  294. break;
  295. }
  296. case EXACT:
  297. {
  298. //nothing to prepare
  299. break;
  300. }
  301. default:
  302. {
  303. //nothing to prepare
  304. }
  305. }
  306. }
  307. // clean up all examples ??
  308. if (verbose)
  309. std::cerr << "Learning finished" << std::endl;
  310. }
  311. GPHIKClassifier *GPHIKClassifier::clone () const
  312. {
  313. fthrow(Exception, "GPHIKClassifier: clone() not yet implemented" );
  314. return NULL;
  315. }
  316. void GPHIKClassifier::predictUncertainty( const NICE::SparseVector * example, double & uncertainty ) const
  317. {
  318. if (gphyper == NULL)
  319. fthrow(Exception, "Classifier not trained yet -- aborting!" );
  320. //we directly store the predictive variances in the vector, that contains the classification uncertainties lateron to save storage
  321. switch (varianceApproximation)
  322. {
  323. case APPROXIMATE_ROUGH:
  324. {
  325. gphyper->computePredictiveVarianceApproximateRough( *example, uncertainty );
  326. break;
  327. }
  328. case APPROXIMATE_FINE:
  329. {
  330. std::cerr << "predict uncertainty fine" << std::endl;
  331. gphyper->computePredictiveVarianceApproximateFine( *example, uncertainty );
  332. break;
  333. }
  334. case EXACT:
  335. {
  336. gphyper->computePredictiveVarianceExact( *example, uncertainty );
  337. break;
  338. }
  339. default:
  340. {
  341. fthrow(Exception, "GPHIKClassifier - your settings disabled the variance approximation needed for uncertainty prediction.");
  342. // uncertainty = numeric_limits<double>::max();
  343. // break;
  344. }
  345. }
  346. }
  347. void GPHIKClassifier::predictUncertainty( const NICE::Vector * example, double & uncertainty ) const
  348. {
  349. if (gphyper == NULL)
  350. fthrow(Exception, "Classifier not trained yet -- aborting!" );
  351. //we directly store the predictive variances in the vector, that contains the classification uncertainties lateron to save storage
  352. switch (varianceApproximation)
  353. {
  354. case APPROXIMATE_ROUGH:
  355. {
  356. gphyper->computePredictiveVarianceApproximateRough( *example, uncertainty );
  357. break;
  358. }
  359. case APPROXIMATE_FINE:
  360. {
  361. gphyper->computePredictiveVarianceApproximateFine( *example, uncertainty );
  362. break;
  363. }
  364. case EXACT:
  365. {
  366. gphyper->computePredictiveVarianceExact( *example, uncertainty );
  367. break;
  368. }
  369. default:
  370. {
  371. fthrow(Exception, "GPHIKClassifier - your settings disabled the variance approximation needed for uncertainty prediction.");
  372. // uncertainty = numeric_limits<double>::max();
  373. // break;
  374. }
  375. }
  376. }
  377. ///////////////////// INTERFACE PERSISTENT /////////////////////
  378. // interface specific methods for store and restore
  379. ///////////////////// INTERFACE PERSISTENT /////////////////////
  380. void GPHIKClassifier::restore ( std::istream & is, int format )
  381. {
  382. //delete everything we knew so far...
  383. this->clear();
  384. bool b_restoreVerbose ( false );
  385. #ifdef B_RESTOREVERBOSE
  386. b_restoreVerbose = true;
  387. #endif
  388. if ( is.good() )
  389. {
  390. if ( b_restoreVerbose )
  391. std::cerr << " restore GPHIKClassifier" << std::endl;
  392. std::string tmp;
  393. is >> tmp; //class name
  394. if ( ! this->isStartTag( tmp, "GPHIKClassifier" ) )
  395. {
  396. std::cerr << " WARNING - attempt to restore GPHIKClassifier, but start flag " << tmp << " does not match! Aborting... " << std::endl;
  397. throw;
  398. }
  399. if (pf != NULL)
  400. {
  401. delete pf;
  402. pf = NULL;
  403. }
  404. if ( confCopy != NULL )
  405. {
  406. delete confCopy;
  407. confCopy = NULL;
  408. }
  409. if (gphyper != NULL)
  410. {
  411. delete gphyper;
  412. gphyper = NULL;
  413. }
  414. is.precision (numeric_limits<double>::digits10 + 1);
  415. bool b_endOfBlock ( false ) ;
  416. while ( !b_endOfBlock )
  417. {
  418. is >> tmp; // start of block
  419. if ( this->isEndTag( tmp, "GPHIKClassifier" ) )
  420. {
  421. b_endOfBlock = true;
  422. continue;
  423. }
  424. tmp = this->removeStartTag ( tmp );
  425. if ( b_restoreVerbose )
  426. std::cerr << " currently restore section " << tmp << " in GPHIKClassifier" << std::endl;
  427. if ( tmp.compare("confSection") == 0 )
  428. {
  429. is >> confSection;
  430. is >> tmp; // end of block
  431. tmp = this->removeEndTag ( tmp );
  432. }
  433. else if ( tmp.compare("pf") == 0 )
  434. {
  435. is >> tmp; // start of block
  436. if ( this->isEndTag( tmp, "pf" ) )
  437. {
  438. std::cerr << " ParameterizedFunction object can not be restored. Aborting..." << std::endl;
  439. throw;
  440. }
  441. std::string transform = this->removeStartTag ( tmp );
  442. if ( transform == "PFAbsExp" )
  443. {
  444. this->pf = new PFAbsExp ();
  445. } else if ( transform == "PFExp" ) {
  446. this->pf = new PFExp ();
  447. } else {
  448. fthrow(Exception, "Transformation type is unknown " << transform);
  449. }
  450. pf->restore(is, format);
  451. is >> tmp; // end of block
  452. tmp = this->removeEndTag ( tmp );
  453. }
  454. else if ( tmp.compare("ConfigCopy") == 0 )
  455. {
  456. // possibly obsolete safety checks
  457. if ( confCopy == NULL )
  458. confCopy = new Config;
  459. confCopy->clear();
  460. //we do not want to read until the end of the file
  461. confCopy->setIoUntilEndOfFile( false );
  462. //load every options we determined explicitely
  463. confCopy->restore(is, format);
  464. is >> tmp; // end of block
  465. tmp = this->removeEndTag ( tmp );
  466. }
  467. else if ( tmp.compare("gphyper") == 0 )
  468. {
  469. if ( gphyper == NULL )
  470. gphyper = new NICE::FMKGPHyperparameterOptimization();
  471. //then, load everything that we stored explicitely,
  472. // including precomputed matrices, LUTs, eigenvalues, ... and all that stuff
  473. gphyper->restore(is, format);
  474. is >> tmp; // end of block
  475. tmp = this->removeEndTag ( tmp );
  476. }
  477. else
  478. {
  479. std::cerr << "WARNING -- unexpected GPHIKClassifier object -- " << tmp << " -- for restoration... aborting" << std::endl;
  480. throw;
  481. }
  482. }
  483. //load every settings as well as default options
  484. std::cerr << "run this->init" << std::endl;
  485. this->init(confCopy, confSection);
  486. std::cerr << "run gphyper->initialize" << std::endl;
  487. gphyper->initialize ( confCopy, pf, NULL, confSection );
  488. }
  489. else
  490. {
  491. std::cerr << "GPHIKClassifier::restore -- InStream not initialized - restoring not possible!" << std::endl;
  492. throw;
  493. }
  494. }
  495. void GPHIKClassifier::store ( std::ostream & os, int format ) const
  496. {
  497. if (gphyper == NULL)
  498. fthrow(Exception, "Classifier not trained yet -- aborting!" );
  499. if (os.good())
  500. {
  501. // show starting point
  502. os << this->createStartTag( "GPHIKClassifier" ) << std::endl;
  503. os.precision (numeric_limits<double>::digits10 + 1);
  504. os << this->createStartTag( "confSection" ) << std::endl;
  505. os << confSection << std::endl;
  506. os << this->createEndTag( "confSection" ) << std::endl;
  507. os << this->createStartTag( "pf" ) << std::endl;
  508. pf->store(os, format);
  509. os << this->createEndTag( "pf" ) << std::endl;
  510. os << this->createStartTag( "ConfigCopy" ) << std::endl;
  511. //we do not want to read until end of file for restoring
  512. confCopy->setIoUntilEndOfFile(false);
  513. confCopy->store(os,format);
  514. os << this->createEndTag( "ConfigCopy" ) << std::endl;
  515. os << this->createStartTag( "gphyper" ) << std::endl;
  516. //store the underlying data
  517. //will be done in gphyper->store(of,format)
  518. //store the optimized parameter values and all that stuff
  519. gphyper->store(os, format);
  520. os << this->createEndTag( "gphyper" ) << std::endl;
  521. // done
  522. os << this->createEndTag( "GPHIKClassifier" ) << std::endl;
  523. }
  524. else
  525. {
  526. std::cerr << "OutStream not initialized - storing not possible!" << std::endl;
  527. }
  528. }
  529. void GPHIKClassifier::clear ()
  530. {
  531. if ( gphyper != NULL )
  532. {
  533. delete gphyper;
  534. gphyper = NULL;
  535. }
  536. if (pf != NULL)
  537. {
  538. delete pf;
  539. pf = NULL;
  540. }
  541. if ( confCopy != NULL )
  542. {
  543. delete confCopy;
  544. confCopy = NULL;
  545. }
  546. }
  547. ///////////////////// INTERFACE ONLINE LEARNABLE /////////////////////
  548. // interface specific methods for incremental extensions
  549. ///////////////////// INTERFACE ONLINE LEARNABLE /////////////////////
  550. void GPHIKClassifier::addExample( const NICE::SparseVector * example,
  551. const double & label,
  552. const bool & performOptimizationAfterIncrement
  553. )
  554. {
  555. if ( this->gphyper == NULL )
  556. {
  557. //call train method instead
  558. std::cerr << "Classifier not initially trained yet -- run initial training instead of incremental extension!" << std::endl;
  559. std::vector< const NICE::SparseVector *> examplesVec;
  560. examplesVec.push_back ( example );
  561. NICE::Vector labelsVec ( 1 , label );
  562. this->train ( examplesVec, labelsVec );
  563. }
  564. else
  565. {
  566. this->gphyper->addExample( example, label, performOptimizationAfterIncrement );
  567. }
  568. }
  569. void GPHIKClassifier::addMultipleExamples( const std::vector< const NICE::SparseVector * > & newExamples,
  570. const NICE::Vector & newLabels,
  571. const bool & performOptimizationAfterIncrement
  572. )
  573. {
  574. //are new examples available? If not, nothing has to be done
  575. if ( newExamples.size() < 1)
  576. return;
  577. if ( this->gphyper == NULL )
  578. {
  579. //call train method instead
  580. std::cerr << "Classifier not initially trained yet -- run initial training instead of incremental extension!" << std::endl;
  581. this->train ( newExamples, newLabels );
  582. }
  583. else
  584. {
  585. this->gphyper->addMultipleExamples( newExamples, newLabels, performOptimizationAfterIncrement );
  586. }
  587. }