Эх сурвалжийг харах

generic quantization, stable commit, not yet cleaned up

Alexander Freytag 9 жил өмнө
parent
commit
051eca217a

+ 15 - 2
FMKGPHyperparameterOptimization.cpp

@@ -462,7 +462,7 @@ void FMKGPHyperparameterOptimization::initFromConfig ( const Config *_conf,
     {     
       this->q = new NICE::Quantization1DAequiDist0ToMax ( numBins );
     }
-    else if ( s_quantType == "nd-aequi-0-1" )
+    else if ( s_quantType == "nd-aequi-0-max" )
     {
       this->q = new NICE::QuantizationNDAequiDist0ToMax ( numBins );
     }
@@ -670,7 +670,20 @@ void FMKGPHyperparameterOptimization::setFastMinKernel ( FastMinKernel * _fmk )
   }
   
   //
-  this->q->computeParametersFromData ( this->fmk->featureMatrix() );
+  if ( this->q != NULL )
+  {  
+    this->q->computeParametersFromData ( &(this->fmk->featureMatrix()) );
+    
+//     if ( this->b_debug )
+//     {
+      std::cerr << "resulting prototypes for first dimension: " << std::endl;
+      for ( uint idxProto = 0; idxProto < this->q->getNumberOfBins(); idxProto++)
+      {
+        std::cerr << this->q->getPrototype ( idxProto, 0 ) << " ";
+      }
+      std::cerr << std::endl;
+//     }
+  }
 }
 
 void FMKGPHyperparameterOptimization::setNrOfEigenvaluesToConsiderForVarApprox ( const int & _nrOfEigenvaluesToConsiderForVarApprox )

+ 103 - 55
FastMinKernel.cpp

@@ -257,20 +257,28 @@ double *FastMinKernel::hik_prepare_alpha_multiplications_fast(const NICE::VVecto
   //NOTE keep in mind: for doing this, we already have precomputed A and B using hik_prepare_alpha_multiplications!
   
   // number of quantization bins
-  uint hmax = _q->size();
+  uint hmax = _q->getNumberOfBins();
 
   // store (transformed) prototypes
-  double *prototypes = new double [ hmax ];
-  for ( uint i = 0 ; i < hmax ; i++ )
-    if ( _pf != NULL ) {
-      // FIXME: the transformed prototypes could change from dimension to another dimension
-      // We skip this flexibility ...but it should be changed in the future
-      prototypes[i] = _pf->f ( 1, _q->getPrototype(i) );
-    } else {
-      prototypes[i] = _q->getPrototype(i);
-    }
-
+  double * prototypes   = new double [ hmax * this->ui_d ];
+  double * p_prototypes = prototypes;
 
+  for (uint dim = 0; dim < this->ui_d; dim++)  
+  {
+    for ( uint i = 0 ; i < hmax ; i++ )
+    {
+      if ( _pf != NULL )
+      {
+        *p_prototypes = _pf->f ( dim, _q->getPrototype( i, dim ) );
+      } else
+      {
+        *p_prototypes = _q->getPrototype( i, dim );
+      }
+      
+      p_prototypes++;
+    }
+  } 
+  
   // creating the lookup table as pure C, which might be beneficial
   // for fast evaluation
   double *Tlookup = new double [ hmax * this->ui_d ];
@@ -302,7 +310,7 @@ double *FastMinKernel::hik_prepare_alpha_multiplications_fast(const NICE::VVecto
     
     for (uint j = 0; j < hmax; j++)
     {
-      double fval = prototypes[j];
+      double fval = prototypes[ dim*hmax + j ];
       double t;
 
       if (  (index == 0) && (j < qBin) ) {
@@ -339,6 +347,12 @@ double *FastMinKernel::hik_prepare_alpha_multiplications_fast(const NICE::VVecto
   }
 
   delete [] prototypes;
+  
+  double * Tval = Tlookup;
+  std::cerr << " computed LUT " << std::endl;
+  for ( uint idx = 0 ; idx < hmax * this->ui_d; idx++, Tval++ )
+    std::cerr << " " << *Tval ;
+  std::cerr << std::endl;
 
   return Tlookup;
 }
@@ -349,18 +363,27 @@ double *FastMinKernel::hikPrepareLookupTable(const NICE::Vector & _alpha,
                                             ) const
 {
   // number of quantization bins
-  uint hmax = _q->size();
+  uint hmax = _q->getNumberOfBins();
 
   // store (transformed) prototypes
-  double *prototypes = new double [ hmax ];
-  for ( uint i = 0 ; i < hmax ; i++ )
-    if ( _pf != NULL ) {
-      // FIXME: the transformed prototypes could change from dimension to another dimension
-      // We skip this flexibility ...but it should be changed in the future
-      prototypes[i] = _pf->f ( 1, _q->getPrototype(i) );
-    } else {
-      prototypes[i] = _q->getPrototype(i);
+  double * prototypes   = new double [ hmax * this->ui_d ];
+  double * p_prototypes = prototypes;
+
+  for (uint dim = 0; dim < this->ui_d; dim++)  
+  {
+    for ( uint i = 0 ; i < hmax ; i++ )
+    {
+      if ( _pf != NULL )
+      {
+        *p_prototypes = _pf->f ( dim, _q->getPrototype( i, dim ) );
+      } else
+      {
+        *p_prototypes = _q->getPrototype( i, dim );
+      }
+      
+      p_prototypes++;
     }
+  }
 
   // creating the lookup table as pure C, which might be beneficial
   // for fast evaluation
@@ -400,7 +423,7 @@ double *FastMinKernel::hikPrepareLookupTable(const NICE::Vector & _alpha,
     
     for (uint j = 0; j < hmax; j++)
     {
-      double fval = prototypes[j];
+      double fval = prototypes[ dim*hmax + j ];
       double t;
 
       if (  (index == 0) && (j < qBin) ) {
@@ -466,18 +489,27 @@ void FastMinKernel::hikUpdateLookupTable(double * _T,
   }
   
   // number of quantization bins
-  uint hmax = _q->size();
+  uint hmax = _q->getNumberOfBins();
 
   // store (transformed) prototypes
-  double *prototypes = new double [ hmax ];
-  for ( uint i = 0 ; i < hmax ; i++ )
-    if ( _pf != NULL ) {
-      // FIXME: the transformed prototypes could change from dimension to another dimension
-      // We skip this flexibility ...but it should be changed in the future
-      prototypes[i] = _pf->f ( 1, _q->getPrototype(i) );
-    } else {
-      prototypes[i] = _q->getPrototype(i);
+  double * prototypes   = new double [ hmax * this->ui_d ];
+  double * p_prototypes = prototypes;
+
+  for (uint dim = 0; dim < this->ui_d; dim++)  
+  {
+    for ( uint i = 0 ; i < hmax ; i++ )
+    {
+      if ( _pf != NULL )
+      {
+        *p_prototypes = _pf->f ( dim, _q->getPrototype( i, dim ) );
+      } else
+      {
+        *p_prototypes = _q->getPrototype( i, dim );
+      }
+      
+      p_prototypes++;
     }
+  }
   
   double diffOfAlpha(_alphaNew - _alphaOld);
   
@@ -497,7 +529,7 @@ void FastMinKernel::hikUpdateLookupTable(double * _T,
         uint q_bin = _q->quantize( x_i, dim );
         
         if ( q_bin > j )
-          fval = prototypes[j];
+          fval = prototypes[ dim*hmax + j ];
         else
           fval = x_i;      
         
@@ -1138,18 +1170,27 @@ double * FastMinKernel::hikPrepareKVNApproximationFast(NICE::VVector & _A,
   //NOTE keep in mind: for doing this, we already have precomputed A using hikPrepareSquaredKernelVector!
   
   // number of quantization bins
-  uint hmax = _q->size();
+  uint hmax = _q->getNumberOfBins();
 
   // store (transformed) prototypes
-  double *prototypes = new double [ hmax ];
-  for ( uint i = 0 ; i < hmax ; i++ )
-    if ( _pf != NULL ) {
-      // FIXME: the transformed prototypes could change from dimension to another dimension
-      // We skip this flexibility ...but it should be changed in the future
-      prototypes[i] = _pf->f ( 1, _q->getPrototype(i) );
-    } else {
-      prototypes[i] = _q->getPrototype(i);
+  double *prototypes = new double [ hmax * this->ui_d ];
+  double * p_prototypes = prototypes;
+  
+  for (uint dim = 0; dim < this->ui_d; dim++)  
+  {
+    for ( uint i = 0 ; i < hmax ; i++ )
+    {
+      if ( _pf != NULL )
+      {
+        *p_prototypes = _pf->f ( dim, _q->getPrototype( i, dim ) );
+      } else
+      {
+        *p_prototypes = _q->getPrototype( i, dim );
+      }
+      
+      p_prototypes++;
     }
+  }
 
 
   // creating the lookup table as pure C, which might be beneficial
@@ -1181,7 +1222,7 @@ double * FastMinKernel::hikPrepareKVNApproximationFast(NICE::VVector & _A,
     
     for (uint j = 0; j < hmax; j++)
     {
-      double fval = prototypes[j];
+      double fval = prototypes[ dim*hmax + j];
       double t;
 
       if (  (index == 0) && (j < qBin) ) {
@@ -1209,9 +1250,7 @@ double * FastMinKernel::hikPrepareKVNApproximationFast(NICE::VVector & _A,
           t = _A[dim][index];
         } else {
           // standard case
-          t =  _A[dim][index-1] + pow( fval, 2 ) * (this->ui_n-nrZeroIndices-(index) );
-//           A[dim][index-1] + fval * (n-nrZeroIndices-(index) );//fval*fval * (n-nrZeroIndices-(index-1) );
-          
+          t =  _A[dim][index-1] + pow( fval, 2 ) * (this->ui_n-nrZeroIndices-(index) );          
         }
       }
 
@@ -1229,18 +1268,27 @@ double* FastMinKernel::hikPrepareLookupTableForKVNApproximation(const Quantizati
                                                                ) const
 {
   // number of quantization bins
-  uint hmax = _q->size();
+  uint hmax = _q->getNumberOfBins();
 
   // store (transformed) prototypes
-  double *prototypes = new double [ hmax ];
-  for ( uint i = 0 ; i < hmax ; i++ )
-    if ( _pf != NULL ) {
-      // FIXME: the transformed prototypes could change from dimension to another dimension
-      // We skip this flexibility ...but it should be changed in the future
-      prototypes[i] = _pf->f ( 1, _q->getPrototype(i) );
-    } else {
-      prototypes[i] = _q->getPrototype(i);
+  double *prototypes = new double [ hmax * this->ui_d ];
+  double * p_prototypes = prototypes;
+
+  for (uint dim = 0; dim < this->ui_d; dim++)  
+  {
+    for ( uint i = 0 ; i < hmax ; i++ )
+    {
+      if ( _pf != NULL )
+      {
+        *p_prototypes = _pf->f ( dim, _q->getPrototype( i, dim ) );
+      } else
+      {
+        *p_prototypes = _q->getPrototype( i, dim );
+      }
+      
+      p_prototypes++;
     }
+  }    
 
   // creating the lookup table as pure C, which might be beneficial
   // for fast evaluation
@@ -1268,7 +1316,7 @@ double* FastMinKernel::hikPrepareLookupTableForKVNApproximation(const Quantizati
     
     for (uint j = 0; j < hmax; j++)
     {
-      double fval = prototypes[j];
+      double fval = prototypes[ dim*hmax + j];
       double t;
 
       if (  (index == 0) && (j < qBin) ) {

+ 4 - 2
FeatureMatrixT.h

@@ -295,9 +295,11 @@ template<class T> class FeatureMatrixT : public NICE::Persistent
                                    ) const;
                                    
                                    
-    T getLargestValue () const;
+    T getLargestValue ( const bool & _getTransformedValue = false ) const;
     
-    NICE::Vector<T> getLargestValuePerDimension ( const double & _quantile=1.0 ) const;
+    NICE::VectorT<T> getLargestValuePerDimension ( const double & _quantile=1.0,
+                                                              const bool & _getTransformedValue = false
+                                                            ) const;
     
     //------------------------------------------------------
     // high level methods

+ 27 - 11
FeatureMatrixT.tcc

@@ -504,36 +504,52 @@ namespace NICE {
     }
     
     template <typename T>
-    T FeatureMatrixT<T>::getLargestValue () const
+    T FeatureMatrixT<T>::getLargestValue ( const bool & _getTransformedValue ) const
     {
       T vmax = (T) 0; 
+      T vtmp = (T) 0;
       
-      for ( std::vector<NICE::SortedVectorSparse<T> >::const_iterator it = this->features.begin();
+      std::cerr << " FeatureMatrixT<T>::getLargestValue begin of for loop " << std::endl;
+      uint tmp ( 0 );
+      for ( typename std::vector<NICE::SortedVectorSparse<T> >::const_iterator it = this->features.begin();
             it != this->features.end();
-            it++
+            it++, tmp++
       )
       {
-        if ( it->getLargestValueUnsafe( ) > vmax )
+        std::cerr << " dim: " << tmp << std::endl;
+        vtmp = it->getLargestValueUnsafe( 1.0 /*quantile, we are interested in the largest value*/, _getTransformedValue );
+        std:: cerr << "largest value: " << vtmp << std::endl;
+        if ( vtmp > vmax )
         {
-          vmax = it->getLargestValueUnsafe( 1.0 /*quantile, we are interested in the largest value*/);
+          vmax = vtmp;
         }
       }
+      std::cerr << " FeatureMatrixT<T>::getLargestValue end of for loop -- largest value: " << vmax << std::endl;
       return vmax;
     }
     
     template <typename T>
-    NICE::Vector<T> FeatureMatrixT<T>::getLargestValuePerDimension ( const double & _quantile ) const     
+    NICE::VectorT<T> FeatureMatrixT<T>::getLargestValuePerDimension ( const double & _quantile, 
+                                                                      const bool & _getTransformedValue
+                                                                    ) const     
     {
-      NICE::Vector<T> vmax ( this->get_d() );
+      NICE::VectorT<T> vmax ( this->get_d() );
       
-      NICE::Vector<T>::iterator vmaxIt = vmax.begin();
-      for ( std::vector<NICE::SortedVectorSparse<T> >::const_iterator it = this->features.begin();
+      std::cerr << " FeatureMatrixT<T>::getLargestValuePerDimension begin of for loop " << std::endl;      
+      
+      uint tmp ( 0 );      
+      typename NICE::VectorT<T>::iterator vmaxIt = vmax.begin();
+      for ( typename std::vector<NICE::SortedVectorSparse<T> >::const_iterator it = this->features.begin();
             it != this->features.end();
-            it++, vmaxIt+
+            it++, vmaxIt++, tmp++
       )
       {
-        *vmaxIt = it->getLargestValueUnsafe( _quantile );
+        std::cerr << " dim: " << tmp << std::endl;        
+        *vmaxIt = it->getLargestValueUnsafe( _quantile, _getTransformedValue );
+        std:: cerr << "largest value: " << *vmaxIt << std::endl;
       }      
+      std::cerr << " FeatureMatrixT<T>::getLargestValuePerDimension end of for loop " << std::endl;     
+      return vmax;
     }
     
     //------------------------------------------------------

+ 2 - 1
Quantization.h

@@ -97,7 +97,8 @@ class Quantization  : public NICE::Persistent
                         
                         
                         
-  virtual void computeParametersFromData ( const NICE::FeatureMatrixT *  _fm ) = 0;                        
+  //FIXME should the argument _fm be templated?
+  virtual void computeParametersFromData ( const NICE::FeatureMatrix *  _fm ) = 0;                        
   
   ///////////////////// INTERFACE PERSISTENT /////////////////////
   // interface specific methods for store and restore

+ 85 - 6
SortedVectorSparse.h

@@ -256,13 +256,92 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
       }
     }
     
-    inline T getLargestValueUnsafe ( const double & _quantile) const
+    inline T getLargestValueUnsafe ( const double & _quantile = 1.0, 
+                                     const bool & _getTransformedValue = false
+                                   ) const
     {
-        return ( T ) 0;
-        std::multimap< T, dataelement >::const_iterator it = this->nzData.end();
-        // FIXME take as many steps backwards as indicated by _quantile
-        it--;
-        return it->second();
+        uint idxDest ( round ( (this->getNonZeros() - 1) * _quantile)  );
+        
+        if ( _quantile > 0.5 )
+        {
+          std::cerr << " getLargestTransformedValueUnsafe -- _quantile > 0.5 " << std::endl;
+          typename std::multimap< T, dataelement >::const_reverse_iterator it = this->nzData.rend();
+          
+          //
+          // take as many backward steps as indicated by _quantile
+          for ( uint idx = this->getNonZeros(); idx > idxDest; idx-- )
+          {
+            std::cerr << " idx: " << idx ;
+            std::cerr << " value: " << it->second.second << std::endl;
+            it++;
+          }          
+          // alternative usage for random access iterators:
+          // it = it + (uint) this->getNonZeros() * ( 1.0 -  _quantile );
+          
+            std::cerr << " final idx: " << idxDest ;
+            std::cerr << " final value: " << it->second.second << std::endl;   
+            if ( _getTransformedValue )
+              return it->second.second;
+            else
+              return it->first;
+        }
+        else
+        {
+          typename std::multimap< T, dataelement >::const_iterator it = this->nzData.begin();
+          
+          // take as many steps forward as indicated by _quantile
+          for ( uint idx = 0; idx < idxDest; idx++ )
+          {
+            it++;
+          }
+          // alternative usage for random access iterators:
+          // it = it + (uint) this->getNonZeros() * _quantile;  
+          
+          if ( _getTransformedValue )
+            return it->second.second;
+          else
+            return it->first;
+        }
+    }    
+    
+    inline T getLargestTransformedValueUnsafe ( const double & _quantile = 1.0 ) const
+    {
+        uint idxDest ( round ( (this->getNonZeros() - 1) * _quantile )  );
+        
+        if ( _quantile > 0.5 )
+        {
+          std::cerr << " getLargestTransformedValueUnsafe -- _quantile > 0.5 " << std::endl;
+          typename std::multimap< T, dataelement >::const_reverse_iterator it = this->nzData.rend();
+          
+          //
+          // take as many backward steps as indicated by _quantile
+          for ( uint idx = this->getNonZeros(); idx > idxDest; idx-- )
+          {
+            std::cerr << " idx: " << idx ;
+            std::cerr << " value: " << it->second.second << std::endl;
+            it++;
+          }          
+          // alternative usage for random access iterators:
+          // it = it + (uint) this->getNonZeros() * ( 1.0 -  _quantile );
+          
+            std::cerr << " final idx: " << idxDest ;
+            std::cerr << " final value: " << it->second.second << std::endl;          
+          return it->second.second;
+        }
+        else
+        {
+          typename std::multimap< T, dataelement >::const_iterator it = this->nzData.begin();
+          
+          // take as many steps forward as indicated by _quantile
+          for ( uint idx = 0; idx < idxDest; idx++ )
+          {
+            it++;
+          }
+          // alternative usage for random access iterators:
+          // it = it + (uint) this->getNonZeros() * _quantile;  
+          
+          return it->second.second;
+        }
     }
       
     std::multimap< T, dataelement > & nonzeroElements()

+ 8 - 0
matlab/GPHIKClassifierMex.cpp

@@ -212,6 +212,14 @@ NICE::Config parseParametersGPHIKClassifier(const mxArray *prhs[], int nrhs)
         conf.sS("GPHIKClassifier", variable, value);
     }
 
+    if(variable == "s_quantType")
+    {
+      string value = MatlabConversion::convertMatlabToString( prhs[i+1] );
+      if( value != "1d-aequi-0-1" && value != "1d-aequi-0-max" && value != "nd-aequi-0-max" )
+        mexErrMsgIdAndTxt("mexnice:error","Unexpected parameter value for \'s_quantType\'. \'1d-aequi-0-1\' , \'1d-aequi-0-max\' or \'nd-aequi-0-max\' expected.");
+        conf.sS("GPHIKClassifier", variable, value);
+    }
+    
     if(variable == "transform")
     {
       string value = MatlabConversion::convertMatlabToString( prhs[i+1] );

+ 8 - 0
matlab/GPHIKRegressionMex.cpp

@@ -210,6 +210,14 @@ NICE::Config parseParametersGPHIKRegression(const mxArray *prhs[], int nrhs)
         mexErrMsgIdAndTxt("mexnice:error","Unexpected parameter value for \'optimization_method\'. \'greedy\', \'downhillsimplex\' or \'none\' expected.");
         conf.sS("GPHIKRegression", variable, value);
     }
+    
+    if(variable == "s_quantType")
+    {
+      string value = MatlabConversion::convertMatlabToString( prhs[i+1] );
+      if( value != "1d-aequi-0-1" && value != "1d-aequi-0-max" && value != "nd-aequi-0-max" )
+        mexErrMsgIdAndTxt("mexnice:error","Unexpected parameter value for \'s_quantType\'. \'1d-aequi-0-1\' , \'1d-aequi-0-max\' or \'nd-aequi-0-max\' expected.");
+        conf.sS("GPHIKClassifier", variable, value);
+    }    
 
     if(variable == "transform")
     {

+ 7 - 3
matlab/plot1dExampleClassification.m

@@ -22,14 +22,14 @@ b_debug                             = false;
 b_uncertaintyPredictionForClassification ...
                                     = true; 
 b_optimize_noise                    = false;
-b_use_quantization                  = false;
+b_use_quantization                  = true;
 b_ils_verbose                       = false;
 %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% integer
 i_nrOfEigenvaluesToConsiderForVarApprox ...
                                     = 1;
-i_num_bins                          = 100; % default
+i_num_bins                          = 1000; % default
 i_ils_max_iterations                = 1000; % default
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% double    
@@ -49,6 +49,9 @@ s_ils_method                        = 'CG'; % default
 % options: 'none', 'greedy', 'downhillsimplex'
 s_optimization_method               = 'downhillsimplex';
 
+% options: '1d-aequi-0-1' , '1d-aequi-0-max' or 'nd-aequi-0-1'
+s_quantType                         = '1d-aequi-0-1';
+
 % options:  'identity', 'exp', 'absexp'
 % with settings above, this equals 'identity'
 s_transform                         = 'identity'; 
@@ -79,6 +82,7 @@ myGPHIKClassifier = ...
                           ...
                           'ils_method',                                s_ils_method, ...
                           'optimization_method',                       s_optimization_method, ...   
+                          's_quantType',                               s_quantType, ...                          
                           'transform',                                 s_transform, ...
                           'varianceApproximation',                     s_varianceApproximation ...
         );
@@ -89,7 +93,7 @@ myGPHIKClassifier.train( myData, myLabels );
 
 %% evaluate model on test data
 
-myDataTest = 0:0.01:1;
+myDataTest = 0:0.001:1;
 % create l1-normalized 'histograms'
 myDataTest = cat(1, myDataTest, 1-myDataTest)';
 

+ 1 - 1
quantization/Quantization1DAequiDist0To1.cpp

@@ -52,7 +52,7 @@ uint Quantization1DAequiDist0To1::quantize ( double _value,
     return (uint)( _value * (this->ui_numBins-1) + 0.5 );
 }
 
-virtual void Quantization1DAequiDist0ToMax::computeParametersFromData ( const NICE::FeatureMatrix *  _fm )
+void Quantization1DAequiDist0To1::computeParametersFromData ( const NICE::FeatureMatrix *  _fm )
 {
   // nothing to do here...
 }

+ 7 - 13
quantization/Quantization1DAequiDist0ToMax.cpp

@@ -58,20 +58,14 @@ uint Quantization1DAequiDist0ToMax::quantize ( double _value,
 
 
 
-virtual void Quantization1DAequiDist0ToMax::computeParametersFromData ( const NICE::FeatureMatrix *  _fm )
+void Quantization1DAequiDist0ToMax::computeParametersFromData ( const NICE::FeatureMatrix *  _fm )
 {
-      double vmax = ( 0.0 ); 
-      for ( uint dim = 0; dim < _fm->get_d(); dim++ )
-      {
-        _fm->getUnsafe( dim, _fm->getNumberOfNonZeroElementsPerDimension( dim ));
-        ;
-        if ( > vmax )
-        {
-          vmax = ;
-        }
-      }
-      this->upperBound.resize ( 1 );
-      this->upperBound ( 0 ) = vmax;
+      std::cerr << " Quantization1DAequiDist0ToMax::computeParametersFromData start " << std::endl;  
+      double vmax = ( _fm->getLargestValue( ) ); 
+      
+      std::cerr << " largest feature value: " << vmax << std::endl;
+      this->v_upperBounds.resize ( 1 );
+      this->v_upperBounds ( 0 ) = vmax;
 }
 // ---------------------- STORE AND RESTORE FUNCTIONS ----------------------
 

+ 11 - 9
quantization/QuantizationNDAequiDist0ToMax.cpp

@@ -22,7 +22,10 @@ QuantizationNDAequiDist0ToMax::QuantizationNDAequiDist0ToMax(
                              )
 {
   this->ui_numBins    = _numBins;
-  this->v_upperBounds = *_upperBounds;
+  if ( (_upperBounds != NULL)  && (_upperBounds->size() > 0) )
+    this->v_upperBounds = (*_upperBounds);
+  else
+    this->v_upperBounds = NICE::Vector( 1 );  
 }
 
 QuantizationNDAequiDist0ToMax::~QuantizationNDAequiDist0ToMax()
@@ -50,14 +53,13 @@ uint QuantizationNDAequiDist0ToMax::quantize ( double _value,
 }
 
 
-virtual void Quantization1DAequiDist0ToMax::computeParametersFromData ( const NICE::FeatureMatrix *  _fm )
-{
-      double vmax = _fm->getLargestValue();      
-      this->upperBound.resize ( 1 );
-      this->upperBound ( 0 ) = vmax;
-      
-      double d_quantile ( 0.99 );
-      this->upperBound = this->fmk->getLargestValuePerDimension( d_quantile );  
+void QuantizationNDAequiDist0ToMax::computeParametersFromData ( const NICE::FeatureMatrix *  _fm )
+{     
+  // 100% quantile...
+  double d_quantile ( 1.00 ); 
+  std::cerr << "QuantizationNDAequiDist0ToMax::computeParametersFromData -- d_quantile: " << d_quantile << std::endl;
+  this->v_upperBounds = _fm->getLargestValuePerDimension( d_quantile );  
+  std::cerr << " computed upper bounds: " <<  this->v_upperBounds << std::endl;
 }
 
 // ---------------------- STORE AND RESTORE FUNCTIONS ----------------------