|
@@ -42,46 +42,56 @@ namespace NICE {
|
|
|
|
|
|
protected:
|
|
protected:
|
|
/** number of examples */
|
|
/** number of examples */
|
|
- int n;
|
|
|
|
|
|
+ uint ui_n;
|
|
|
|
|
|
/** dimension of feature vectors */
|
|
/** dimension of feature vectors */
|
|
- int d;
|
|
|
|
|
|
+ uint ui_d;
|
|
|
|
|
|
/** noise added to the diagonal of the kernel matrix */
|
|
/** noise added to the diagonal of the kernel matrix */
|
|
- double noise;
|
|
|
|
|
|
+ double d_noise;
|
|
|
|
|
|
/** sorted matrix of features (sorted along each dimension) */
|
|
/** sorted matrix of features (sorted along each dimension) */
|
|
NICE::FeatureMatrixT<double> X_sorted;
|
|
NICE::FeatureMatrixT<double> X_sorted;
|
|
|
|
|
|
//! verbose flag for output after calling the restore-function
|
|
//! verbose flag for output after calling the restore-function
|
|
- bool verbose;
|
|
|
|
|
|
+ bool b_verbose;
|
|
//! debug flag for output during debugging
|
|
//! debug flag for output during debugging
|
|
- bool debug;
|
|
|
|
|
|
+ bool b_debug;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Set number of examples
|
|
* @brief Set number of examples
|
|
* @author Alexander Freytag
|
|
* @author Alexander Freytag
|
|
* @date 07-12-2011 (dd-mm-yyyy)
|
|
* @date 07-12-2011 (dd-mm-yyyy)
|
|
*/
|
|
*/
|
|
- void set_n(const int & _n){n = _n;};
|
|
|
|
|
|
+ void set_n(const uint & _n){this->ui_n = _n;};
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Set number of dimensions
|
|
* @brief Set number of dimensions
|
|
* @author Alexander Freytag
|
|
* @author Alexander Freytag
|
|
* @date 07-12-2011 (dd-mm-yyyy)
|
|
* @date 07-12-2011 (dd-mm-yyyy)
|
|
*/
|
|
*/
|
|
- void set_d(const int & _d){d = _d;};
|
|
|
|
|
|
+ void set_d(const uint & _d){this->ui_d = _d;};
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Prepare the efficient HIK-computations part 1: order the features in each dimension and save the permutation. Pay attention: X is of dim n x d, where as X_sorted is of dimensionality d x n!
|
|
* @brief Prepare the efficient HIK-computations part 1: order the features in each dimension and save the permutation. Pay attention: X is of dim n x d, where as X_sorted is of dimensionality d x n!
|
|
* @author Alexander Freytag
|
|
* @author Alexander Freytag
|
|
* @date 07-12-2011 (dd-mm-yyyy)
|
|
* @date 07-12-2011 (dd-mm-yyyy)
|
|
*/
|
|
*/
|
|
- void hik_prepare_kernel_multiplications(const std::vector<std::vector<double> > & X, NICE::FeatureMatrixT<double> & X_sorted, const int & _dim = -1);
|
|
|
|
-
|
|
|
|
- void hik_prepare_kernel_multiplications ( const std::vector< const NICE::SparseVector * > & X, NICE::FeatureMatrixT<double> & X_sorted, const bool & dimensionsOverExamples, const int & _dim = -1);
|
|
|
|
-
|
|
|
|
- void randomPermutation(NICE::Vector & permutation, const std::vector<int> & oldIndices, const int & newSize) const;
|
|
|
|
|
|
+ void hik_prepare_kernel_multiplications(const std::vector<std::vector<double> > & _X,
|
|
|
|
+ NICE::FeatureMatrixT<double> & _X_sorted,
|
|
|
|
+ const uint & _dim = 0
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ void hik_prepare_kernel_multiplications ( const std::vector< const NICE::SparseVector * > & _X,
|
|
|
|
+ NICE::FeatureMatrixT<double> & _X_sorted,
|
|
|
|
+ const bool & _dimensionsOverExamples,
|
|
|
|
+ const uint & _dim = 0
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ void randomPermutation(NICE::Vector & _permutation,
|
|
|
|
+ const std::vector<uint> & _oldIndices,
|
|
|
|
+ const uint & _newSize
|
|
|
|
+ ) const;
|
|
|
|
|
|
enum ApproximationScheme{ MEDIAN = 0, EXPECTATION=1};
|
|
enum ApproximationScheme{ MEDIAN = 0, EXPECTATION=1};
|
|
ApproximationScheme approxScheme;
|
|
ApproximationScheme approxScheme;
|
|
@@ -104,7 +114,11 @@ namespace NICE {
|
|
* @author Alexander Freytag
|
|
* @author Alexander Freytag
|
|
* @date 06-12-2011 (dd-mm-yyyy)
|
|
* @date 06-12-2011 (dd-mm-yyyy)
|
|
*/
|
|
*/
|
|
- FastMinKernel( const std::vector<std::vector<double> > & X, const double noise , const bool _debug = false, const int & _dim = -1);
|
|
|
|
|
|
+ FastMinKernel( const std::vector<std::vector<double> > & _X,
|
|
|
|
+ const double _noise ,
|
|
|
|
+ const bool _debug = false,
|
|
|
|
+ const uint & _dim = 0
|
|
|
|
+ );
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -113,7 +127,12 @@ namespace NICE {
|
|
* @param X vector of sparse vector pointers
|
|
* @param X vector of sparse vector pointers
|
|
* @param noise GP noise
|
|
* @param noise GP noise
|
|
*/
|
|
*/
|
|
- FastMinKernel( const std::vector< const NICE::SparseVector * > & X, const double noise, const bool _debug = false, const bool & dimensionsOverExamples=false, const int & _dim = -1);
|
|
|
|
|
|
+ FastMinKernel( const std::vector< const NICE::SparseVector * > & X,
|
|
|
|
+ const double _noise,
|
|
|
|
+ const bool _debug = false,
|
|
|
|
+ const bool & dimensionsOverExamples=false,
|
|
|
|
+ const uint & _dim = 0
|
|
|
|
+ );
|
|
|
|
|
|
#ifdef NICE_USELIB_MATIO
|
|
#ifdef NICE_USELIB_MATIO
|
|
/**
|
|
/**
|
|
@@ -123,7 +142,11 @@ namespace NICE {
|
|
* @param noise additional noise variance of the labels
|
|
* @param noise additional noise variance of the labels
|
|
* @param examples set of indices to include
|
|
* @param examples set of indices to include
|
|
*/
|
|
*/
|
|
- FastMinKernel ( const sparse_t & X, const double noise, const std::map<int, int> & examples, const bool _debug = false , const int & _dim = -1);
|
|
|
|
|
|
+ FastMinKernel ( const sparse_t & _X,
|
|
|
|
+ const double _noise,
|
|
|
|
+ const std::map<uint, uint> & _examples,
|
|
|
|
+ const bool _debug = false ,
|
|
|
|
+ const uint & _dim = 0);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -148,14 +171,14 @@ namespace NICE {
|
|
* @author Alexander Freytag
|
|
* @author Alexander Freytag
|
|
* @date 07-12-2011 (dd-mm-yyyy)
|
|
* @date 07-12-2011 (dd-mm-yyyy)
|
|
*/
|
|
*/
|
|
- int get_n() const;
|
|
|
|
|
|
+ uint get_n() const;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Get number of dimensions
|
|
* @brief Get number of dimensions
|
|
* @author Alexander Freytag
|
|
* @author Alexander Freytag
|
|
* @date 07-12-2011 (dd-mm-yyyy)
|
|
* @date 07-12-2011 (dd-mm-yyyy)
|
|
*/
|
|
*/
|
|
- int get_d() const;
|
|
|
|
|
|
+ uint get_d() const;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Computes the ratio of sparsity across the matrix
|
|
* @brief Computes the ratio of sparsity across the matrix
|
|
@@ -183,22 +206,33 @@ namespace NICE {
|
|
*
|
|
*
|
|
* @param pf the parameterized function (optional), if not given, nothing will be done
|
|
* @param pf the parameterized function (optional), if not given, nothing will be done
|
|
*/
|
|
*/
|
|
- void applyFunctionToFeatureMatrix ( const NICE::ParameterizedFunction *pf = NULL );
|
|
|
|
|
|
+ void applyFunctionToFeatureMatrix ( const NICE::ParameterizedFunction *_pf = NULL );
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Prepare the efficient HIK-computations part 2: calculate the partial sum for each dimension. Explicitely exploiting sparsity!!! Pay attention: X_sorted is of dimensionality d x n!
|
|
* @brief Prepare the efficient HIK-computations part 2: calculate the partial sum for each dimension. Explicitely exploiting sparsity!!! Pay attention: X_sorted is of dimensionality d x n!
|
|
* @author Alexander Freytag
|
|
* @author Alexander Freytag
|
|
* @date 17-01-2012 (dd-mm-yyyy)
|
|
* @date 17-01-2012 (dd-mm-yyyy)
|
|
*/
|
|
*/
|
|
- void hik_prepare_alpha_multiplications(const NICE::Vector & alpha, NICE::VVector & A, NICE::VVector & B) const;
|
|
|
|
|
|
+ void hik_prepare_alpha_multiplications(const NICE::Vector & _alpha,
|
|
|
|
+ NICE::VVector & _A,
|
|
|
|
+ NICE::VVector & _B
|
|
|
|
+ ) const;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Computing K*alpha with the minimum kernel trick, explicitely exploiting sparsity!!!
|
|
* @brief Computing K*alpha with the minimum kernel trick, explicitely exploiting sparsity!!!
|
|
* @author Alexander Freytag
|
|
* @author Alexander Freytag
|
|
* @date 17-01-2012 (dd-mm-yyyy)
|
|
* @date 17-01-2012 (dd-mm-yyyy)
|
|
*/
|
|
*/
|
|
- void hik_kernel_multiply(const NICE::VVector & A, const NICE::VVector & B, const NICE::Vector & alpha, NICE::Vector & beta) const;
|
|
|
|
- void hik_kernel_multiply_fast(const double *Tlookup, const Quantization & q, const NICE::Vector & alpha, NICE::Vector & beta) const;
|
|
|
|
|
|
+ void hik_kernel_multiply(const NICE::VVector & _A,
|
|
|
|
+ const NICE::VVector & _B,
|
|
|
|
+ const NICE::Vector & _alpha,
|
|
|
|
+ NICE::Vector & _beta
|
|
|
|
+ ) const;
|
|
|
|
+ void hik_kernel_multiply_fast(const double *_Tlookup,
|
|
|
|
+ const Quantization & _q,
|
|
|
|
+ const NICE::Vector & _alpha,
|
|
|
|
+ NICE::Vector & _beta
|
|
|
|
+ ) const;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Computing k_{*}*alpha using the minimum kernel trick and exploiting sparsity of the feature vector given
|
|
* @brief Computing k_{*}*alpha using the minimum kernel trick and exploiting sparsity of the feature vector given
|
|
@@ -211,7 +245,12 @@ namespace NICE {
|
|
* @param beta result of the scalar product
|
|
* @param beta result of the scalar product
|
|
* @param pf optional feature transformation
|
|
* @param pf optional feature transformation
|
|
*/
|
|
*/
|
|
- void hik_kernel_sum(const NICE::VVector & A, const NICE::VVector & B, const NICE::SparseVector & xstar, double & beta, const ParameterizedFunction *pf = NULL ) const;
|
|
|
|
|
|
+ void hik_kernel_sum(const NICE::VVector & _A,
|
|
|
|
+ const NICE::VVector & _B,
|
|
|
|
+ const NICE::SparseVector & _xstar,
|
|
|
|
+ double & _beta,
|
|
|
|
+ const ParameterizedFunction *_pf = NULL
|
|
|
|
+ ) const;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Computing k_{*}*alpha using the minimum kernel trick and exploiting sparsity of the feature vector given
|
|
* @brief Computing k_{*}*alpha using the minimum kernel trick and exploiting sparsity of the feature vector given
|
|
@@ -225,7 +264,12 @@ namespace NICE {
|
|
* @param beta result of the scalar product
|
|
* @param beta result of the scalar product
|
|
* @param pf optional feature transformation
|
|
* @param pf optional feature transformation
|
|
*/
|
|
*/
|
|
- void hik_kernel_sum(const NICE::VVector & A, const NICE::VVector & B, const NICE::Vector & xstar, double & beta, const ParameterizedFunction *pf = NULL ) const;
|
|
|
|
|
|
+ void hik_kernel_sum(const NICE::VVector & _A,
|
|
|
|
+ const NICE::VVector & _B,
|
|
|
|
+ const NICE::Vector & _xstar,
|
|
|
|
+ double & _beta,
|
|
|
|
+ const ParameterizedFunction *_pf = NULL
|
|
|
|
+ ) const;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief compute beta = k_*^T * alpha by using a large lookup table created by hik_prepare_alpha_multiplications_fast
|
|
* @brief compute beta = k_*^T * alpha by using a large lookup table created by hik_prepare_alpha_multiplications_fast
|
|
@@ -238,7 +282,11 @@ namespace NICE {
|
|
* @param xstar feature vector (indirect k_*)
|
|
* @param xstar feature vector (indirect k_*)
|
|
* @param beta result of the calculation
|
|
* @param beta result of the calculation
|
|
*/
|
|
*/
|
|
- void hik_kernel_sum_fast(const double* Tlookup, const Quantization & q, const NICE::Vector & xstar, double & beta) const;
|
|
|
|
|
|
+ void hik_kernel_sum_fast(const double* _Tlookup,
|
|
|
|
+ const Quantization & _q,
|
|
|
|
+ const NICE::Vector & _xstar,
|
|
|
|
+ double & _beta
|
|
|
|
+ ) const;
|
|
/**
|
|
/**
|
|
* @brief compute beta = k_*^T * alpha by using a large lookup table created by hik_prepare_alpha_multiplications_fast
|
|
* @brief compute beta = k_*^T * alpha by using a large lookup table created by hik_prepare_alpha_multiplications_fast
|
|
* NOTE: Whenever possible, you should use sparse features to obtain significantly smaller computation times!
|
|
* NOTE: Whenever possible, you should use sparse features to obtain significantly smaller computation times!
|
|
@@ -250,7 +298,11 @@ namespace NICE {
|
|
* @param beta result of the calculation
|
|
* @param beta result of the calculation
|
|
*/
|
|
*/
|
|
|
|
|
|
- void hik_kernel_sum_fast(const double *Tlookup, const Quantization & q, const NICE::SparseVector & xstar, double & beta) const;
|
|
|
|
|
|
+ void hik_kernel_sum_fast(const double *_Tlookup,
|
|
|
|
+ const Quantization & _q,
|
|
|
|
+ const NICE::SparseVector & _xstar,
|
|
|
|
+ double & _beta
|
|
|
|
+ ) const;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief compute lookup table for HIK calculation using quantized signals and prepare for K*alpha or k_*^T * alpha computations
|
|
* @brief compute lookup table for HIK calculation using quantized signals and prepare for K*alpha or k_*^T * alpha computations
|
|
@@ -264,7 +316,11 @@ namespace NICE {
|
|
* @return C standard vector representing a q.size()*n double matrix and the lookup table T. Elements can be accessed with
|
|
* @return C standard vector representing a q.size()*n double matrix and the lookup table T. Elements can be accessed with
|
|
* T[dim*q.size() + j], where j is a bin entry corresponding to quantization q.
|
|
* T[dim*q.size() + j], where j is a bin entry corresponding to quantization q.
|
|
*/
|
|
*/
|
|
- double *hik_prepare_alpha_multiplications_fast(const NICE::VVector & A, const NICE::VVector & B, const Quantization & q, const ParameterizedFunction *pf = NULL ) const;
|
|
|
|
|
|
+ double *hik_prepare_alpha_multiplications_fast(const NICE::VVector & _A,
|
|
|
|
+ const NICE::VVector & _B,
|
|
|
|
+ const Quantization & _q,
|
|
|
|
+ const ParameterizedFunction *_pf = NULL
|
|
|
|
+ ) const;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief compute lookup table for HIK calculation using quantized signals and prepare for K*alpha or k_*^T * alpha computations
|
|
* @brief compute lookup table for HIK calculation using quantized signals and prepare for K*alpha or k_*^T * alpha computations
|
|
@@ -277,7 +333,10 @@ namespace NICE {
|
|
* @return C standard vector representing a q.size()*n double matrix and the lookup table T. Elements can be accessed with
|
|
* @return C standard vector representing a q.size()*n double matrix and the lookup table T. Elements can be accessed with
|
|
* T[dim*q.size() + j], where j is a bin entry corresponding to quantization q.
|
|
* T[dim*q.size() + j], where j is a bin entry corresponding to quantization q.
|
|
*/
|
|
*/
|
|
- double* hikPrepareLookupTable(const NICE::Vector & alpha, const Quantization & q, const ParameterizedFunction *pf = NULL) const;
|
|
|
|
|
|
+ double* hikPrepareLookupTable(const NICE::Vector & _alpha,
|
|
|
|
+ const Quantization & _q,
|
|
|
|
+ const ParameterizedFunction *_pf = NULL
|
|
|
|
+ ) const;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief update the lookup table for HIK calculation using quantized signals and prepare for K*alpha or k_*^T * alpha computations
|
|
* @brief update the lookup table for HIK calculation using quantized signals and prepare for K*alpha or k_*^T * alpha computations
|
|
@@ -290,7 +349,13 @@ namespace NICE {
|
|
* @param q Quantization
|
|
* @param q Quantization
|
|
* @param pf ParameterizedFunction to change the original feature values
|
|
* @param pf ParameterizedFunction to change the original feature values
|
|
*/
|
|
*/
|
|
- void hikUpdateLookupTable(double * T, const double & alphaNew, const double & alphaOld, const int & idx, const Quantization & q, const ParameterizedFunction *pf ) const;
|
|
|
|
|
|
+ void hikUpdateLookupTable(double * _T,
|
|
|
|
+ const double & _alphaNew,
|
|
|
|
+ const double & _alphaOld,
|
|
|
|
+ const int & _idx,
|
|
|
|
+ const Quantization & _q,
|
|
|
|
+ const ParameterizedFunction *pf
|
|
|
|
+ ) const;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief return a reference to the sorted feature matrix
|
|
* @brief return a reference to the sorted feature matrix
|
|
@@ -315,14 +380,23 @@ namespace NICE {
|
|
* @return C standard vector representing a q.size()*n double matrix and the lookup table T. Elements can be accessed with
|
|
* @return C standard vector representing a q.size()*n double matrix and the lookup table T. Elements can be accessed with
|
|
* T[dim*q.size() + j], where j is a bin entry corresponding to quantization q.
|
|
* T[dim*q.size() + j], where j is a bin entry corresponding to quantization q.
|
|
**/
|
|
**/
|
|
- double *solveLin(const NICE::Vector & y, NICE::Vector & alpha, const Quantization & q, const ParameterizedFunction *pf = NULL, const bool & useRandomSubsets = true, uint maxIterations = 10000, const int & _sizeOfRandomSubset = (-1), double minDelta = 1e-7, bool timeAnalysis = false) const;
|
|
|
|
|
|
+ double *solveLin(const NICE::Vector & _y,
|
|
|
|
+ NICE::Vector & _alpha,
|
|
|
|
+ const Quantization & _q,
|
|
|
|
+ const ParameterizedFunction *_pf = NULL,
|
|
|
|
+ const bool & _useRandomSubsets = true,
|
|
|
|
+ uint _maxIterations = 10000,
|
|
|
|
+ const uint & _sizeOfRandomSubset = 0,
|
|
|
|
+ double _minDelta = 1e-7,
|
|
|
|
+ bool _timeAnalysis = false
|
|
|
|
+ ) const;
|
|
|
|
|
|
|
|
|
|
//! set the noise parameter
|
|
//! set the noise parameter
|
|
- void setNoise ( double noise ) { this->noise = noise; }
|
|
|
|
|
|
+ void setNoise ( double _noise ) { this->d_noise = _noise; }
|
|
|
|
|
|
//! get the current noise parameter
|
|
//! get the current noise parameter
|
|
- double getNoise (void) const { return noise; }
|
|
|
|
|
|
+ double getNoise (void) const { return this->d_noise; }
|
|
|
|
|
|
double getFrobNormApprox();
|
|
double getFrobNormApprox();
|
|
|
|
|
|
@@ -332,7 +406,7 @@ namespace NICE {
|
|
* @author Alexander Freytag
|
|
* @author Alexander Freytag
|
|
* @date 10-04-2012 (dd-mm-yyyy)
|
|
* @date 10-04-2012 (dd-mm-yyyy)
|
|
*/
|
|
*/
|
|
- void hikPrepareKVNApproximation(NICE::VVector & A) const;
|
|
|
|
|
|
+ void hikPrepareKVNApproximation(NICE::VVector & _A) const;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Compute lookup table for HIK calculation of |k_*|^2 assuming quantized test samples. You have to run hikPrepareSquaredKernelVector before
|
|
* @brief Compute lookup table for HIK calculation of |k_*|^2 assuming quantized test samples. You have to run hikPrepareSquaredKernelVector before
|
|
@@ -346,7 +420,7 @@ namespace NICE {
|
|
* @return C standard vector representing a q.size()*d double matrix and the lookup table T. Elements can be accessed with
|
|
* @return C standard vector representing a q.size()*d double matrix and the lookup table T. Elements can be accessed with
|
|
* T[dim*q.size() + j], where j is a bin entry corresponding to quantization q.
|
|
* T[dim*q.size() + j], where j is a bin entry corresponding to quantization q.
|
|
*/
|
|
*/
|
|
- double * hikPrepareKVNApproximationFast(NICE::VVector & A, const Quantization & q, const ParameterizedFunction *pf = NULL ) const;
|
|
|
|
|
|
+ double * hikPrepareKVNApproximationFast(NICE::VVector & _A, const Quantization & _q, const ParameterizedFunction *_pf = NULL ) const;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Compute lookup table for HIK calculation of |k_*|^2 assuming quantized test samples ( equals hikPrepareSquaredKernelVector + hikPrepareSquaredKernelVectorFast, but is faster). Approximation does not considere mixed terms between dimensions.
|
|
* @brief Compute lookup table for HIK calculation of |k_*|^2 assuming quantized test samples ( equals hikPrepareSquaredKernelVector + hikPrepareSquaredKernelVectorFast, but is faster). Approximation does not considere mixed terms between dimensions.
|
|
@@ -359,7 +433,7 @@ namespace NICE {
|
|
* @return C standard vector representing a q.size()*d double matrix and the lookup table T. Elements can be accessed with
|
|
* @return C standard vector representing a q.size()*d double matrix and the lookup table T. Elements can be accessed with
|
|
* T[dim*q.size() + j], where j is a bin entry corresponding to quantization q.
|
|
* T[dim*q.size() + j], where j is a bin entry corresponding to quantization q.
|
|
*/
|
|
*/
|
|
- double* hikPrepareLookupTableForKVNApproximation(const Quantization & q, const ParameterizedFunction *pf = NULL) const;
|
|
|
|
|
|
+ double* hikPrepareLookupTableForKVNApproximation(const Quantization & _q, const ParameterizedFunction *_pf = NULL) const;
|
|
|
|
|
|
//////////////////////////////////////////
|
|
//////////////////////////////////////////
|
|
// variance computation: sparse inputs
|
|
// variance computation: sparse inputs
|
|
@@ -375,7 +449,7 @@ namespace NICE {
|
|
* @param norm result of the squared norm approximation
|
|
* @param norm result of the squared norm approximation
|
|
* @param pf optional feature transformation
|
|
* @param pf optional feature transformation
|
|
*/
|
|
*/
|
|
- void hikComputeKVNApproximation(const NICE::VVector & A, const NICE::SparseVector & xstar, double & norm, const ParameterizedFunction *pf = NULL ) ;
|
|
|
|
|
|
+ void hikComputeKVNApproximation(const NICE::VVector & _A, const NICE::SparseVector & _xstar, double & _norm, const ParameterizedFunction *_pf = NULL ) ;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Approximate norm = |k_*|^2 using a large lookup table created by hikPrepareSquaredKernelVector and hikPrepareSquaredKernelVectorFast or directly using hikPrepareLookupTableForSquaredKernelVector. Approximation does not considere mixed terms between dimensions.
|
|
* @brief Approximate norm = |k_*|^2 using a large lookup table created by hikPrepareSquaredKernelVector and hikPrepareSquaredKernelVectorFast or directly using hikPrepareLookupTableForSquaredKernelVector. Approximation does not considere mixed terms between dimensions.
|
|
@@ -387,7 +461,7 @@ namespace NICE {
|
|
* @param xstar feature vector (indirect k_*)
|
|
* @param xstar feature vector (indirect k_*)
|
|
* @param norm result of the calculation
|
|
* @param norm result of the calculation
|
|
*/
|
|
*/
|
|
- void hikComputeKVNApproximationFast(const double *Tlookup, const Quantization & q, const NICE::SparseVector & xstar, double & norm ) const;
|
|
|
|
|
|
+ void hikComputeKVNApproximationFast(const double *_Tlookup, const Quantization & _q, const NICE::SparseVector & _xstar, double & _norm ) const;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Compute the kernel vector k_* between training examples and test example. Runtime. O(n \times D). Exploiting sparsity
|
|
* @brief Compute the kernel vector k_* between training examples and test example. Runtime. O(n \times D). Exploiting sparsity
|
|
@@ -397,7 +471,7 @@ namespace NICE {
|
|
* @param xstar feature vector
|
|
* @param xstar feature vector
|
|
* @param kstar kernel vector
|
|
* @param kstar kernel vector
|
|
*/
|
|
*/
|
|
- void hikComputeKernelVector( const NICE::SparseVector & xstar, NICE::Vector & kstar) const;
|
|
|
|
|
|
+ void hikComputeKernelVector( const NICE::SparseVector & _xstar, NICE::Vector & _kstar) const;
|
|
|
|
|
|
//////////////////////////////////////////
|
|
//////////////////////////////////////////
|
|
// variance computation: non-sparse inputs
|
|
// variance computation: non-sparse inputs
|
|
@@ -413,7 +487,7 @@ namespace NICE {
|
|
* @param norm result of the squared norm approximation
|
|
* @param norm result of the squared norm approximation
|
|
* @param pf optional feature transformation
|
|
* @param pf optional feature transformation
|
|
*/
|
|
*/
|
|
- void hikComputeKVNApproximation(const NICE::VVector & A, const NICE::Vector & xstar, double & norm, const ParameterizedFunction *pf = NULL ) ;
|
|
|
|
|
|
+ void hikComputeKVNApproximation(const NICE::VVector & _A, const NICE::Vector & _xstar, double & _norm, const ParameterizedFunction *_pf = NULL ) ;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Approximate norm = |k_*|^2 using a large lookup table created by hikPrepareSquaredKernelVector and hikPrepareSquaredKernelVectorFast or directly using hikPrepareLookupTableForSquaredKernelVector. Approximation does not considere mixed terms between dimensions.
|
|
* @brief Approximate norm = |k_*|^2 using a large lookup table created by hikPrepareSquaredKernelVector and hikPrepareSquaredKernelVectorFast or directly using hikPrepareLookupTableForSquaredKernelVector. Approximation does not considere mixed terms between dimensions.
|
|
@@ -425,7 +499,7 @@ namespace NICE {
|
|
* @param xstar feature vector (indirect k_*)
|
|
* @param xstar feature vector (indirect k_*)
|
|
* @param norm result of the calculation
|
|
* @param norm result of the calculation
|
|
*/
|
|
*/
|
|
- void hikComputeKVNApproximationFast(const double *Tlookup, const Quantization & q, const NICE::Vector & xstar, double & norm ) const;
|
|
|
|
|
|
+ void hikComputeKVNApproximationFast(const double *_Tlookup, const Quantization & _q, const NICE::Vector & _xstar, double & _norm ) const;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Compute the kernel vector k_* between training examples and test example. Runtime. O(n \times D). Does not exploit sparsity - deprecated!
|
|
* @brief Compute the kernel vector k_* between training examples and test example. Runtime. O(n \times D). Does not exploit sparsity - deprecated!
|
|
@@ -435,26 +509,26 @@ namespace NICE {
|
|
* @param xstar feature vector
|
|
* @param xstar feature vector
|
|
* @param kstar kernel vector
|
|
* @param kstar kernel vector
|
|
*/
|
|
*/
|
|
- void hikComputeKernelVector( const NICE::Vector & xstar, NICE::Vector & kstar) const;
|
|
|
|
|
|
+ void hikComputeKernelVector( const NICE::Vector & _xstar, NICE::Vector & _kstar) const;
|
|
|
|
|
|
/** Persistent interface */
|
|
/** Persistent interface */
|
|
- virtual void restore ( std::istream & is, int format = 0 );
|
|
|
|
- virtual void store ( std::ostream & os, int format = 0 ) const;
|
|
|
|
|
|
+ virtual void restore ( std::istream & _is, int _format = 0 );
|
|
|
|
+ virtual void store ( std::ostream & _os, int _format = 0 ) const;
|
|
virtual void clear ();
|
|
virtual void clear ();
|
|
|
|
|
|
///////////////////// INTERFACE ONLINE LEARNABLE /////////////////////
|
|
///////////////////// INTERFACE ONLINE LEARNABLE /////////////////////
|
|
// interface specific methods for incremental extensions
|
|
// interface specific methods for incremental extensions
|
|
///////////////////// INTERFACE ONLINE LEARNABLE /////////////////////
|
|
///////////////////// INTERFACE ONLINE LEARNABLE /////////////////////
|
|
|
|
|
|
- virtual void addExample( const NICE::SparseVector * example,
|
|
|
|
- const double & label,
|
|
|
|
- const bool & performOptimizationAfterIncrement = true
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- virtual void addMultipleExamples( const std::vector< const NICE::SparseVector * > & newExamples,
|
|
|
|
- const NICE::Vector & newLabels,
|
|
|
|
- const bool & performOptimizationAfterIncrement = true
|
|
|
|
- );
|
|
|
|
|
|
+ virtual void addExample( const NICE::SparseVector * _example,
|
|
|
|
+ const double & _label,
|
|
|
|
+ const bool & _performOptimizationAfterIncrement = true
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ virtual void addMultipleExamples( const std::vector< const NICE::SparseVector * > & _newExamples,
|
|
|
|
+ const NICE::Vector & _newLabels,
|
|
|
|
+ const bool & _performOptimizationAfterIncrement = true
|
|
|
|
+ );
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -464,7 +538,7 @@ namespace NICE {
|
|
*
|
|
*
|
|
* @param example new feature vector
|
|
* @param example new feature vector
|
|
*/
|
|
*/
|
|
- void addExample(const NICE::SparseVector * example, const NICE::ParameterizedFunction *pf = NULL);
|
|
|
|
|
|
+ void addExample(const NICE::SparseVector * _example, const NICE::ParameterizedFunction *_pf = NULL);
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Add multiple new example to the feature-storage. You have to update the corresponding variables explicitely after that.
|
|
* @brief Add multiple new example to the feature-storage. You have to update the corresponding variables explicitely after that.
|
|
@@ -473,7 +547,7 @@ namespace NICE {
|
|
*
|
|
*
|
|
* @param newExamples new feature vectors
|
|
* @param newExamples new feature vectors
|
|
*/
|
|
*/
|
|
- void addMultipleExamples(const std::vector<const NICE::SparseVector * > & newExamples, const NICE::ParameterizedFunction *pf = NULL);
|
|
|
|
|
|
+ void addMultipleExamples(const std::vector<const NICE::SparseVector * > & _newExamples, const NICE::ParameterizedFunction *_pf = NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|