|
@@ -187,12 +187,53 @@ void GPHIKClassifierNICE::predictUncertainty( const NICE::SparseVector * example
|
|
|
void GPHIKClassifierNICE::restore ( std::istream & is, int format )
|
|
|
{
|
|
|
if (is.good())
|
|
|
- {
|
|
|
- classifier->restore(is, format);
|
|
|
-
|
|
|
+ {
|
|
|
std::string tmp;
|
|
|
- is >> tmp; //"performOptimizationAfterIncrement: "
|
|
|
- is >> this->performOptimizationAfterIncrement;
|
|
|
+ is >> tmp; //class name
|
|
|
+
|
|
|
+ if ( ! this->isStartTag( tmp, "GPHIKClassifierNICE" ) )
|
|
|
+ {
|
|
|
+ std::cerr << " WARNING - attempt to restore GPHIKClassifierNICE, but start flag " << tmp << " does not match! Aborting... " << std::endl;
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+
|
|
|
+ is.precision (numeric_limits<double>::digits10 + 1);
|
|
|
+
|
|
|
+ bool b_endOfBlock ( false ) ;
|
|
|
+
|
|
|
+ while ( !b_endOfBlock )
|
|
|
+ {
|
|
|
+ is >> tmp; // start of block
|
|
|
+
|
|
|
+ if ( this->isEndTag( tmp, "GPHIKClassifierNICE" ) )
|
|
|
+ {
|
|
|
+ b_endOfBlock = true;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else if ( tmp.compare("classifier") == 0 )
|
|
|
+ {
|
|
|
+ if ( classifier == NULL )
|
|
|
+ classifier = new NICE::GPHIKClassifier();
|
|
|
+
|
|
|
+ //then, load everything that we stored explicitely,
|
|
|
+ // including precomputed matrices, LUTs, eigenvalues, ... and all that stuff
|
|
|
+ classifier->restore(is, format);
|
|
|
+
|
|
|
+ is >> tmp; // end of block
|
|
|
+ tmp = this->removeEndTag ( tmp );
|
|
|
+ }
|
|
|
+ else if ( tmp.compare("performOptimizationAfterIncrement") == 0 )
|
|
|
+ {
|
|
|
+ is >> performOptimizationAfterIncrement;
|
|
|
+ is >> tmp; // end of block
|
|
|
+ tmp = this->removeEndTag ( tmp );
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cerr << "WARNING -- unexpected GPHIKClassifier object -- " << tmp << " -- for restoration... aborting" << std::endl;
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ } // while-loop
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -206,9 +247,19 @@ void GPHIKClassifierNICE::store ( std::ostream & os, int format ) const
|
|
|
{
|
|
|
os.precision (numeric_limits<double>::digits10 + 1);
|
|
|
|
|
|
+ // show starting point
|
|
|
+ os << this->createStartTag( "GPHIKClassifierNICE" ) << std::endl;
|
|
|
+
|
|
|
+ os << this->createStartTag( "classifier" ) << std::endl;
|
|
|
classifier->store(os, format);
|
|
|
+ os << this->createEndTag( "classifier" ) << std::endl;
|
|
|
+
|
|
|
+ os << this->createStartTag( "performOptimizationAfterIncrement" ) << std::endl;
|
|
|
+ os << performOptimizationAfterIncrement << std::endl;
|
|
|
+ os << this->createEndTag( "performOptimizationAfterIncrement" ) << std::endl;
|
|
|
|
|
|
- os << "performOptimizationAfterIncrement: " << performOptimizationAfterIncrement << std::endl;
|
|
|
+ // done
|
|
|
+ os << this->createEndTag( "GPHIKClassifier" ) << std::endl;
|
|
|
}
|
|
|
else
|
|
|
{
|