From 3b2b243bc1a47d9788e6f31bf1ee3dc87cda35f7 Mon Sep 17 00:00:00 2001 From: Heiko Strathmann Date: Sat, 14 Apr 2018 19:48:43 +0200 Subject: [PATCH] use SG_ADD rather than m_parameter->add --- src/shogun/classifier/PluginEstimate.cpp | 25 ++++++++--------- src/shogun/classifier/svm/OnlineLibLinear.cpp | 7 ++--- src/shogun/classifier/svm/OnlineSVMSGD.cpp | 23 +++++++++------- src/shogun/classifier/svm/SGDQN.cpp | 10 +++---- src/shogun/classifier/svm/SVMOcas.cpp | 19 +++++++------ src/shogun/clustering/GMM.cpp | 4 ++- src/shogun/converter/HashedDocConverter.cpp | 3 +-- .../distance/AttenuatedEuclideanDistance.cpp | 4 ++- src/shogun/distance/CustomDistance.cpp | 7 +++-- src/shogun/distance/Distance.cpp | 10 ++++--- src/shogun/distance/HammingWordDistance.cpp | 5 ++-- src/shogun/distance/KernelDistance.cpp | 5 ++-- src/shogun/distance/MahalanobisDistance.cpp | 10 +++++-- src/shogun/distributions/PositionalPWM.cpp | 10 +++---- src/shogun/evaluation/SplittingStrategy.cpp | 15 +++++++---- src/shogun/features/Alphabet.cpp | 12 ++++----- src/shogun/features/CombinedDotFeatures.cpp | 13 ++++----- src/shogun/features/DotFeatures.cpp | 5 ++-- src/shogun/features/DummyFeatures.cpp | 5 ++-- src/shogun/features/FKFeatures.cpp | 2 +- src/shogun/features/PolyFeatures.cpp | 21 +++++++++------ .../features/RandomFourierDotFeatures.cpp | 5 ++-- .../RandomKitchenSinksDotFeatures.cpp | 4 ++- src/shogun/features/SparsePolyFeatures.cpp | 26 +++++++++++------- src/shogun/features/StringFeatures.cpp | 27 +++++++++++-------- src/shogun/features/TOPFeatures.cpp | 8 ++++-- src/shogun/latent/LatentModel.cpp | 13 ++++++--- src/shogun/lib/List.h | 8 ++---- src/shogun/machine/LinearLatentMachine.cpp | 8 +++--- .../linalg/linop/DenseMatrixOperator.cpp | 3 --- .../linalg/linop/SparseMatrixOperator.cpp | 10 ------- .../linsolver/IterativeLinearSolver.cpp | 15 ----------- src/shogun/preprocessor/PNorm.cpp | 2 +- .../DomainAdaptationSVMLinear.cpp | 7 +++-- 34 files changed, 187 insertions(+), 164 deletions(-) diff --git a/src/shogun/classifier/PluginEstimate.cpp b/src/shogun/classifier/PluginEstimate.cpp index 2707dfaee4c..2d40f70ba6d 100644 --- a/src/shogun/classifier/PluginEstimate.cpp +++ b/src/shogun/classifier/PluginEstimate.cpp @@ -20,18 +20,19 @@ CPluginEstimate::CPluginEstimate(float64_t pos_pseudo, float64_t neg_pseudo) : CMachine(), m_pos_pseudo(1e-10), m_neg_pseudo(1e-10), pos_model(NULL), neg_model(NULL), features(NULL) { - m_parameters->add(&m_pos_pseudo, - "pos_pseudo","pseudo count for positive class"); - m_parameters->add(&m_neg_pseudo, - "neg_pseudo", "pseudo count for negative class"); - - m_parameters->add((CSGObject**) &pos_model, - "pos_model", "LinearHMM modelling positive class."); - m_parameters->add((CSGObject**) &neg_model, - "neg_model", "LinearHMM modelling negative class."); - - m_parameters->add((CSGObject**) &features, - "features", "String Features."); + SG_ADD( + &m_pos_pseudo, "pos_pseudo", "pseudo count for positive class", + MS_NOT_AVAILABLE); + SG_ADD( + &m_neg_pseudo, "neg_pseudo", "pseudo count for negative class", + MS_NOT_AVAILABLE); + SG_ADD( + &pos_model, "pos_model", "LinearHMM modelling positive class.", + MS_NOT_AVAILABLE); + SG_ADD( + &neg_model, "neg_model", "LinearHMM modelling negative class.", + MS_NOT_AVAILABLE); + SG_ADD(&features, "features", "String Features.", MS_NOT_AVAILABLE); } CPluginEstimate::~CPluginEstimate() diff --git a/src/shogun/classifier/svm/OnlineLibLinear.cpp b/src/shogun/classifier/svm/OnlineLibLinear.cpp index ce62edca397..13089de7798 100644 --- a/src/shogun/classifier/svm/OnlineLibLinear.cpp +++ b/src/shogun/classifier/svm/OnlineLibLinear.cpp @@ -63,9 +63,10 @@ void COnlineLibLinear::init() Cn=1; use_bias=false; - m_parameters->add(&C1, "C1", "C Cost constant 1."); - m_parameters->add(&C2, "C2", "C Cost constant 2."); - m_parameters->add(&use_bias, "use_bias", "Indicates if bias is used."); + SG_ADD(&C1, "C1", "C Cost constant 1.", MS_AVAILABLE); + SG_ADD(&C2, "C2", "C Cost constant 2.", MS_AVAILABLE); + SG_ADD( + &use_bias, "use_bias", "Indicates if bias is used.", MS_NOT_AVAILABLE); PG = 0; PGmax_old = CMath::INFTY; diff --git a/src/shogun/classifier/svm/OnlineSVMSGD.cpp b/src/shogun/classifier/svm/OnlineSVMSGD.cpp index 4abfe431b1d..470f79bf0ab 100644 --- a/src/shogun/classifier/svm/OnlineSVMSGD.cpp +++ b/src/shogun/classifier/svm/OnlineSVMSGD.cpp @@ -204,14 +204,17 @@ void COnlineSVMSGD::init() loss=new CHingeLoss(); SG_REF(loss); - m_parameters->add(&C1, "C1", "Cost constant 1."); - m_parameters->add(&C2, "C2", "Cost constant 2."); - m_parameters->add(&lambda, "lambda", "Regularization parameter."); - m_parameters->add(&wscale, "wscale", "W scale"); - m_parameters->add(&bscale, "bscale", "b scale"); - m_parameters->add(&epochs, "epochs", "epochs"); - m_parameters->add(&skip, "skip", "skip"); - m_parameters->add(&count, "count", "count"); - m_parameters->add(&use_bias, "use_bias", "Indicates if bias is used."); - m_parameters->add(&use_regularized_bias, "use_regularized_bias", "Indicates if bias is regularized."); + SG_ADD(&C1, "C1", "Cost constant 1.", MS_AVAILABLE); + SG_ADD(&C2, "C2", "Cost constant 2.", MS_AVAILABLE); + SG_ADD(&lambda, "lambda", "Regularization parameter.", MS_AVAILABLE); + SG_ADD(&wscale, "wscale", "W scale", MS_NOT_AVAILABLE); + SG_ADD(&bscale, "bscale", "b scale", MS_NOT_AVAILABLE); + SG_ADD(&epochs, "epochs", "epochs", MS_NOT_AVAILABLE); + SG_ADD(&skip, "skip", "skip", MS_NOT_AVAILABLE); + SG_ADD(&count, "count", "count", MS_NOT_AVAILABLE); + SG_ADD( + &use_bias, "use_bias", "Indicates if bias is used.", MS_NOT_AVAILABLE); + SG_ADD( + &use_regularized_bias, "use_regularized_bias", + "Indicates if bias is regularized.", MS_NOT_AVAILABLE); } diff --git a/src/shogun/classifier/svm/SGDQN.cpp b/src/shogun/classifier/svm/SGDQN.cpp index 9e4cd9c9b49..69d80bf5b3c 100644 --- a/src/shogun/classifier/svm/SGDQN.cpp +++ b/src/shogun/classifier/svm/SGDQN.cpp @@ -224,9 +224,9 @@ void CSGDQN::init() loss=new CHingeLoss(); SG_REF(loss); - m_parameters->add(&C1, "C1", "Cost constant 1."); - m_parameters->add(&C2, "C2", "Cost constant 2."); - m_parameters->add(&epochs, "epochs", "epochs"); - m_parameters->add(&skip, "skip", "skip"); - m_parameters->add(&count, "count", "count"); + SG_ADD(&C1, "C1", "Cost constant 1.", MS_AVAILABLE); + SG_ADD(&C2, "C2", "Cost constant 2.", MS_AVAILABLE); + SG_ADD(&epochs, "epochs", "epochs", MS_AVAILABLE); + SG_ADD(&skip, "skip", "skip", MS_NOT_AVAILABLE); + SG_ADD(&count, "count", "count", MS_NOT_AVAILABLE); } diff --git a/src/shogun/classifier/svm/SVMOcas.cpp b/src/shogun/classifier/svm/SVMOcas.cpp index d8266f00f94..69101da7ebc 100644 --- a/src/shogun/classifier/svm/SVMOcas.cpp +++ b/src/shogun/classifier/svm/SVMOcas.cpp @@ -345,14 +345,17 @@ void CSVMOcas::init() primal_objective = 0.0; - m_parameters->add(&C1, "C1", "Cost constant 1."); - m_parameters->add(&C2, "C2", "Cost constant 2."); - m_parameters->add(&use_bias, "use_bias", - "Indicates if bias is used."); - m_parameters->add(&epsilon, "epsilon", "Convergence precision."); - m_parameters->add(&bufsize, "bufsize", "Maximum number of cutting planes."); - m_parameters->add((machine_int_t*) &method, "method", - "SVMOcas solver type."); + SG_ADD(&C1, "C1", "Cost constant 1.", MS_AVAILABLE); + SG_ADD(&C2, "C2", "Cost constant 2.", MS_AVAILABLE); + SG_ADD( + &use_bias, "use_bias", "Indicates if bias is used.", MS_NOT_AVAILABLE); + SG_ADD(&epsilon, "epsilon", "Convergence precision.", MS_NOT_AVAILABLE); + SG_ADD( + &bufsize, "bufsize", "Maximum number of cutting planes.", + MS_NOT_AVAILABLE); + SG_ADD( + (machine_int_t*)&method, "method", "SVMOcas solver type.", + MS_NOT_AVAILABLE); } float64_t CSVMOcas::compute_primal_objective() const diff --git a/src/shogun/clustering/GMM.cpp b/src/shogun/clustering/GMM.cpp index 9ac0710ff66..1df69bde285 100644 --- a/src/shogun/clustering/GMM.cpp +++ b/src/shogun/clustering/GMM.cpp @@ -822,6 +822,8 @@ void CGMM::register_params() { //TODO serialization broken //m_parameters->add((SGVector*) &m_components, "m_components", "Mixture components"); - m_parameters->add(&m_coefficients, "m_coefficients", "Mixture coefficients."); + SG_ADD( + &m_coefficients, "m_coefficients", "Mixture coefficients.", + MS_NOT_AVAILABLE); } diff --git a/src/shogun/converter/HashedDocConverter.cpp b/src/shogun/converter/HashedDocConverter.cpp index 6ca9e33d21a..146475c859d 100644 --- a/src/shogun/converter/HashedDocConverter.cpp +++ b/src/shogun/converter/HashedDocConverter.cpp @@ -65,8 +65,7 @@ void CHashedDocConverter::init(CTokenizer* tzer, int32_t hash_bits, bool normali MS_NOT_AVAILABLE); SG_ADD(&should_normalize, "should_normalize", "Whether to normalize vectors or not", MS_NOT_AVAILABLE); - m_parameters->add((CSGObject**) &tokenizer, "tokenizer", - "Tokenizer"); + SG_ADD(&tokenizer, "tokenizer", "Tokenizer", MS_NOT_AVAILABLE); } const char* CHashedDocConverter::get_name() const diff --git a/src/shogun/distance/AttenuatedEuclideanDistance.cpp b/src/shogun/distance/AttenuatedEuclideanDistance.cpp index 449e43c9274..2df7ecb801a 100644 --- a/src/shogun/distance/AttenuatedEuclideanDistance.cpp +++ b/src/shogun/distance/AttenuatedEuclideanDistance.cpp @@ -66,5 +66,7 @@ void CAttenuatedEuclideanDistance::init() { disable_sqrt=false; - m_parameters->add(&disable_sqrt, "disable_sqrt", "If sqrt shall not be applied."); + SG_ADD( + &disable_sqrt, "disable_sqrt", "If sqrt shall not be applied.", + MS_NOT_AVAILABLE); } diff --git a/src/shogun/distance/CustomDistance.cpp b/src/shogun/distance/CustomDistance.cpp index 89e5643afe5..7bd28fa5eed 100644 --- a/src/shogun/distance/CustomDistance.cpp +++ b/src/shogun/distance/CustomDistance.cpp @@ -123,9 +123,12 @@ void CCustomDistance::init() upper_diagonal=false; m_parameters->add_matrix(&dmatrix, &num_rows, &num_cols, "dmatrix", "Distance Matrix"); - watch_param("dmatrix", &dmatrix, &num_rows, &num_cols); + watch_param( + "dmatrix", &dmatrix, &num_rows, &num_cols, + AnyParameterProperties("Distance Matrix")); - m_parameters->add(&upper_diagonal, "upper_diagonal", "Upper diagonal"); + SG_ADD( + &upper_diagonal, "upper_diagonal", "Upper diagonal", MS_NOT_AVAILABLE); } void CCustomDistance::cleanup() diff --git a/src/shogun/distance/Distance.cpp b/src/shogun/distance/Distance.cpp index 342936f9130..e6e1550f2ff 100644 --- a/src/shogun/distance/Distance.cpp +++ b/src/shogun/distance/Distance.cpp @@ -259,10 +259,12 @@ void CDistance::init() num_lhs=0; num_rhs=0; - m_parameters->add((CSGObject**) &lhs, "lhs", - "Feature vectors to occur on left hand side."); - m_parameters->add((CSGObject**) &rhs, "rhs", - "Feature vectors to occur on right hand side."); + SG_ADD( + &lhs, "lhs", "Feature vectors to occur on left hand side.", + MS_NOT_AVAILABLE); + SG_ADD( + &rhs, "rhs", "Feature vectors to occur on right hand side.", + MS_NOT_AVAILABLE); } template diff --git a/src/shogun/distance/HammingWordDistance.cpp b/src/shogun/distance/HammingWordDistance.cpp index 7f08b2c2ae5..613a6b650ad 100644 --- a/src/shogun/distance/HammingWordDistance.cpp +++ b/src/shogun/distance/HammingWordDistance.cpp @@ -169,6 +169,7 @@ float64_t CHammingWordDistance::compute(int32_t idx_a, int32_t idx_b) void CHammingWordDistance::init() { use_sign = false; - m_parameters->add(&use_sign, "use_sign", - "If signum(counts) is used instead of counts."); + SG_ADD( + &use_sign, "use_sign", "If signum(counts) is used instead of counts.", + MS_NOT_AVAILABLE); } diff --git a/src/shogun/distance/KernelDistance.cpp b/src/shogun/distance/KernelDistance.cpp index 3eb2d0ccc81..128e051c443 100644 --- a/src/shogun/distance/KernelDistance.cpp +++ b/src/shogun/distance/KernelDistance.cpp @@ -69,7 +69,6 @@ void CKernelDistance::init() kernel = NULL; width = 0.0; - m_parameters->add(&width, "width", "Width of RBF Kernel"); - m_parameters->add((CSGObject**) &kernel, "kernel", - "Kernel."); + SG_ADD(&width, "width", "Width of RBF Kernel", MS_AVAILABLE); + SG_ADD(&kernel, "kernel", "Kernel.", MS_NOT_AVAILABLE); } diff --git a/src/shogun/distance/MahalanobisDistance.cpp b/src/shogun/distance/MahalanobisDistance.cpp index 19fdfa5e049..f9344824ce3 100644 --- a/src/shogun/distance/MahalanobisDistance.cpp +++ b/src/shogun/distance/MahalanobisDistance.cpp @@ -110,7 +110,13 @@ void CMahalanobisDistance::init() disable_sqrt=false; use_mean=false; - m_parameters->add(&disable_sqrt, "disable_sqrt", "If sqrt shall not be applied."); - m_parameters->add(&use_mean, "use_mean", "If distance shall be computed between mean vector and vector from rhs or between lhs and rhs."); + SG_ADD( + &disable_sqrt, "disable_sqrt", "If sqrt shall not be applied.", + MS_NOT_AVAILABLE); + SG_ADD( + &use_mean, "use_mean", "If distance shall be computed between mean " + "vector and vector from rhs or between lhs and " + "rhs.", + MS_NOT_AVAILABLE); } diff --git a/src/shogun/distributions/PositionalPWM.cpp b/src/shogun/distributions/PositionalPWM.cpp index ec219876d07..6b57334b5a9 100644 --- a/src/shogun/distributions/PositionalPWM.cpp +++ b/src/shogun/distributions/PositionalPWM.cpp @@ -124,11 +124,11 @@ void CPositionalPWM::compute_w(int32_t num_pos) void CPositionalPWM::register_params() { - m_parameters->add(&m_poim, "poim", "POIM Scoring Matrix"); - m_parameters->add(&m_w, "w", "Scoring Matrix"); - m_parameters->add(&m_pwm, "pwm", "Positional Weight Matrix."); - m_parameters->add(&m_sigma, "sigma", "Standard Deviation."); - m_parameters->add(&m_mean, "mean", "Mean."); + SG_ADD(&m_poim, "poim", "POIM Scoring Matrix", MS_NOT_AVAILABLE); + SG_ADD(&m_w, "w", "Scoring Matrix", MS_NOT_AVAILABLE); + SG_ADD(&m_pwm, "pwm", "Positional Weight Matrix.", MS_NOT_AVAILABLE); + SG_ADD(&m_sigma, "sigma", "Standard Deviation.", MS_NOT_AVAILABLE); + SG_ADD(&m_mean, "mean", "Mean.", MS_NOT_AVAILABLE); } void CPositionalPWM::compute_scoring(int32_t max_degree) diff --git a/src/shogun/evaluation/SplittingStrategy.cpp b/src/shogun/evaluation/SplittingStrategy.cpp index 9d0469f5b16..9425c430382 100644 --- a/src/shogun/evaluation/SplittingStrategy.cpp +++ b/src/shogun/evaluation/SplittingStrategy.cpp @@ -56,11 +56,16 @@ void CSplittingStrategy::init() m_is_filled=false; m_num_subsets=0; - m_parameters->add((CSGObject**)&m_labels, "labels", "Labels for subsets"); - m_parameters->add((CSGObject**)&m_subset_indices, "subset_indices", - "Set of sets of subset indices"); - m_parameters->add(&m_is_filled, "is_filled", "Whether ther are index sets"); - m_parameters->add(&m_num_subsets, "num_subsets", "Number of index sets"); + SG_ADD(&m_labels, "labels", "Labels for subsets", MS_NOT_AVAILABLE); + SG_ADD( + &m_subset_indices, "subset_indices", "Set of sets of subset indices", + MS_NOT_AVAILABLE); + SG_ADD( + &m_is_filled, "is_filled", "Whether ther are index sets", + MS_NOT_AVAILABLE); + SG_ADD( + &m_num_subsets, "num_subsets", "Number of index sets", + MS_NOT_AVAILABLE); } CSplittingStrategy::~CSplittingStrategy() diff --git a/src/shogun/features/Alphabet.cpp b/src/shogun/features/Alphabet.cpp index ca8ec8bddbf..7b2de669b66 100644 --- a/src/shogun/features/Alphabet.cpp +++ b/src/shogun/features/Alphabet.cpp @@ -726,13 +726,11 @@ void CAlphabet::init() memset(maptable_to_char, 0, sizeof (maptable_to_char)); memset(histogram, 0, sizeof (histogram)); - - m_parameters->add((machine_int_t*) &alphabet, "alphabet", - "Alphabet enum."); - m_parameters->add(&num_symbols, "num_symbols", - "Number of symbols."); - m_parameters->add(&num_bits, "num_bits", - "Number of bits."); + SG_ADD( + (machine_int_t*)&alphabet, "alphabet", "Alphabet enum.", + MS_NOT_AVAILABLE); + SG_ADD(&num_symbols, "num_symbols", "Number of symbols.", MS_NOT_AVAILABLE); + SG_ADD(&num_bits, "num_bits", "Number of bits.", MS_NOT_AVAILABLE); /* We don't need to serialize the mapping tables / they can be computed * after de-serializing. Lets not serialize the histogram for now. Doesn't diff --git a/src/shogun/features/CombinedDotFeatures.cpp b/src/shogun/features/CombinedDotFeatures.cpp index 6765397134e..10bc9546a1d 100644 --- a/src/shogun/features/CombinedDotFeatures.cpp +++ b/src/shogun/features/CombinedDotFeatures.cpp @@ -341,11 +341,12 @@ void CCombinedDotFeatures::set_subfeature_weights(SGVector weights) void CCombinedDotFeatures::init() { - m_parameters->add(&num_dimensions, "num_dimensions", - "Total number of dimensions."); - m_parameters->add(&num_vectors, "num_vectors", - "Total number of vectors."); - m_parameters->add((CSGObject**) &feature_array, - "feature_array", "Feature array."); + SG_ADD( + &num_dimensions, "num_dimensions", "Total number of dimensions.", + MS_NOT_AVAILABLE); + SG_ADD( + &num_vectors, "num_vectors", "Total number of vectors.", + MS_NOT_AVAILABLE); + SG_ADD(&feature_array, "feature_array", "Feature array.", MS_NOT_AVAILABLE); } diff --git a/src/shogun/features/DotFeatures.cpp b/src/shogun/features/DotFeatures.cpp index 7a7d7f5fba5..c1776fddc56 100644 --- a/src/shogun/features/DotFeatures.cpp +++ b/src/shogun/features/DotFeatures.cpp @@ -406,6 +406,7 @@ SGMatrix CDotFeatures::compute_cov( void CDotFeatures::init() { set_property(FP_DOT); - m_parameters->add(&combined_weight, "combined_weight", - "Feature weighting in combined dot features."); + SG_ADD( + &combined_weight, "combined_weight", + "Feature weighting in combined dot features.", MS_NOT_AVAILABLE); } diff --git a/src/shogun/features/DummyFeatures.cpp b/src/shogun/features/DummyFeatures.cpp index 9df890cde7e..6b0a701b5b1 100644 --- a/src/shogun/features/DummyFeatures.cpp +++ b/src/shogun/features/DummyFeatures.cpp @@ -46,6 +46,7 @@ EFeatureClass CDummyFeatures::get_feature_class() const void CDummyFeatures::init() { - m_parameters->add(&num_vectors, "num_vectors", - "Number of feature vectors."); + SG_ADD( + &num_vectors, "num_vectors", "Number of feature vectors.", + MS_NOT_AVAILABLE); } diff --git a/src/shogun/features/FKFeatures.cpp b/src/shogun/features/FKFeatures.cpp index e8863dd75dd..5a2cbfe3a61 100644 --- a/src/shogun/features/FKFeatures.cpp +++ b/src/shogun/features/FKFeatures.cpp @@ -255,5 +255,5 @@ void CFKFeatures::init() //TODO serialize HMMs //m_parameters->add((CSGObject**) &pos, "pos", "HMM for positive class."); //m_parameters->add((CSGObject**) &neg, "neg", "HMM for negative class."); - m_parameters->add(&weight_a, "weight_a", "Class prior."); + SG_ADD(&weight_a, "weight_a", "Class prior.", MS_NOT_AVAILABLE); } diff --git a/src/shogun/features/PolyFeatures.cpp b/src/shogun/features/PolyFeatures.cpp index 6e25347ff04..b60d3b03a9a 100644 --- a/src/shogun/features/PolyFeatures.cpp +++ b/src/shogun/features/PolyFeatures.cpp @@ -376,14 +376,19 @@ CFeatures* CPolyFeatures::duplicate() const void CPolyFeatures::register_parameters() { - m_parameters->add((CSGObject**) &m_feat, "features", - "Features in original space."); - m_parameters->add(&m_degree, "degree", "Degree of the polynomial kernel."); - m_parameters->add(&m_normalize, "normalize", "Normalize?"); - m_parameters->add(&m_input_dimensions, "input_dimensions", - "Dimensions of the input space."); - m_parameters->add(&m_output_dimensions, "output_dimensions", - "Dimensions of the feature space of the polynomial kernel."); + SG_ADD( + (CSGObject**)&m_feat, "features", "Features in original space.", + MS_NOT_AVAILABLE); + SG_ADD( + &m_degree, "degree", "Degree of the polynomial kernel.", MS_AVAILABLE); + SG_ADD(&m_normalize, "normalize", "Normalize?", MS_NOT_AVAILABLE); + SG_ADD( + &m_input_dimensions, "input_dimensions", + "Dimensions of the input space.", MS_NOT_AVAILABLE); + SG_ADD( + &m_output_dimensions, "output_dimensions", + "Dimensions of the feature space of the polynomial kernel.", + MS_NOT_AVAILABLE); multi_index_length=m_output_dimensions*m_degree; m_parameters->add_vector( diff --git a/src/shogun/features/RandomFourierDotFeatures.cpp b/src/shogun/features/RandomFourierDotFeatures.cpp index 0c6e1b11dd7..c0aa3c3235e 100644 --- a/src/shogun/features/RandomFourierDotFeatures.cpp +++ b/src/shogun/features/RandomFourierDotFeatures.cpp @@ -54,8 +54,9 @@ void CRandomFourierDotFeatures::init(KernelName kernel_name, SGVector kernel_params = params; constant = num_samples > 0 ? std::sqrt(2.0 / num_samples) : 1; - m_parameters->add(&kernel_params, "kernel_params", - "The parameters of the kernel to approximate"); + SG_ADD( + &kernel_params, "kernel_params", + "The parameters of the kernel to approximate", MS_NOT_AVAILABLE); SG_ADD((machine_int_t* ) &kernel, "kernel", "The kernel to approximate", MS_NOT_AVAILABLE); SG_ADD(&constant, "constant", "A constant needed", diff --git a/src/shogun/features/RandomKitchenSinksDotFeatures.cpp b/src/shogun/features/RandomKitchenSinksDotFeatures.cpp index c16990baf22..9707f6ba7bb 100644 --- a/src/shogun/features/RandomKitchenSinksDotFeatures.cpp +++ b/src/shogun/features/RandomKitchenSinksDotFeatures.cpp @@ -75,7 +75,9 @@ void CRandomKitchenSinksDotFeatures::init(CDotFeatures* dataset, SG_ADD((CSGObject** ) &feats, "feats", "Features to work on", MS_NOT_AVAILABLE); - m_parameters->add(&random_coeff, "random_coeff", "Random function parameters"); + SG_ADD( + &random_coeff, "random_coeff", "Random function parameters", + MS_NOT_AVAILABLE); } int32_t CRandomKitchenSinksDotFeatures::get_dim_feature_space() const diff --git a/src/shogun/features/SparsePolyFeatures.cpp b/src/shogun/features/SparsePolyFeatures.cpp index c02e9c1ca2d..563fdf6cd4e 100644 --- a/src/shogun/features/SparsePolyFeatures.cpp +++ b/src/shogun/features/SparsePolyFeatures.cpp @@ -249,14 +249,18 @@ CFeatures* CSparsePolyFeatures::duplicate() const void CSparsePolyFeatures::init() { - m_parameters->add((CSGObject**) &m_feat, "features", - "Features in original space."); - m_parameters->add(&m_degree, "degree", "Degree of the polynomial kernel."); - m_parameters->add(&m_normalize, "normalize", "Normalize"); - m_parameters->add(&m_input_dimensions, "input_dimensions", - "Dimensions of the input space."); - m_parameters->add(&m_output_dimensions, "output_dimensions", - "Dimensions of the feature space of the polynomial kernel."); + SG_ADD( + &m_feat, "features", "Features in original space.", MS_NOT_AVAILABLE); + SG_ADD( + &m_degree, "degree", "Degree of the polynomial kernel.", MS_AVAILABLE); + SG_ADD(&m_normalize, "normalize", "Normalize", MS_NOT_AVAILABLE); + SG_ADD( + &m_input_dimensions, "input_dimensions", + "Dimensions of the input space.", MS_NOT_AVAILABLE); + SG_ADD( + &m_output_dimensions, "output_dimensions", + "Dimensions of the feature space of the polynomial kernel.", + MS_NOT_AVAILABLE); m_normalization_values_len = get_num_vectors(); m_parameters->add_vector(&m_normalization_values, &m_normalization_values_len, @@ -265,6 +269,8 @@ void CSparsePolyFeatures::init() "m_normalization_values", &m_normalization_values, &m_normalization_values_len); - m_parameters->add(&mask, "mask", "Mask."); - m_parameters->add(&m_hash_bits, "m_hash_bits", "Number of bits in hash"); + SG_ADD(&mask, "mask", "Mask.", MS_NOT_AVAILABLE); + SG_ADD( + &m_hash_bits, "m_hash_bits", "Number of bits in hash", + MS_NOT_AVAILABLE); } diff --git a/src/shogun/features/StringFeatures.cpp b/src/shogun/features/StringFeatures.cpp index c3db54f77e9..dde5598d3b6 100644 --- a/src/shogun/features/StringFeatures.cpp +++ b/src/shogun/features/StringFeatures.cpp @@ -1729,7 +1729,7 @@ template void CStringFeatures::init() num_symbols=0.0; original_num_symbols=0; - m_parameters->add((CSGObject**) &alphabet, "alphabet"); + SG_ADD(&alphabet, "alphabet", "Alphabet used.", MS_NOT_AVAILABLE); m_parameters->add_vector(&features, &num_vectors, "features", "This contains the array of features."); @@ -1741,16 +1741,21 @@ template void CStringFeatures::init() "Created by sliding window."); watch_param("single_string", &single_string, &length_of_single_string); - m_parameters->add(&max_string_length, "max_string_length", - "Length of longest string."); - m_parameters->add(&num_symbols, "num_symbols", - "Number of used symbols."); - m_parameters->add(&original_num_symbols, "original_num_symbols", - "Original number of used symbols."); - m_parameters->add(&order, "order", - "Order used in higher order mapping."); - m_parameters->add(&preprocess_on_get, "preprocess_on_get", - "Preprocess on-the-fly?"); + SG_ADD( + &max_string_length, "max_string_length", "Length of longest string.", + MS_NOT_AVAILABLE); + SG_ADD( + &num_symbols, "num_symbols", "Number of used symbols.", + MS_NOT_AVAILABLE); + SG_ADD( + &original_num_symbols, "original_num_symbols", + "Original number of used symbols.", MS_NOT_AVAILABLE); + SG_ADD( + &order, "order", "Order used in higher order mapping.", + MS_NOT_AVAILABLE); + SG_ADD( + &preprocess_on_get, "preprocess_on_get", "Preprocess on-the-fly?", + MS_NOT_AVAILABLE); m_parameters->add_vector(&symbol_mask_table, &symbol_mask_table_len, "mask_table", "Symbol mask table - using in higher order mapping"); watch_param("mask_table", &symbol_mask_table, &symbol_mask_table_len); diff --git a/src/shogun/features/TOPFeatures.cpp b/src/shogun/features/TOPFeatures.cpp index 671b4b74ce6..ed81a82b109 100644 --- a/src/shogun/features/TOPFeatures.cpp +++ b/src/shogun/features/TOPFeatures.cpp @@ -367,6 +367,10 @@ void CTOPFeatures::init() //TODO serialize HMMs //m_parameters->add((CSGObject**) &pos, "pos", "HMM for positive class."); //m_parameters->add((CSGObject**) &neg, "neg", "HMM for negative class."); - m_parameters->add(&neglinear, "neglinear", "If negative HMM is a LinearHMM"); - m_parameters->add(&poslinear, "poslinear", "If positive HMM is a LinearHMM"); + SG_ADD( + &neglinear, "neglinear", "If negative HMM is a LinearHMM", + MS_NOT_AVAILABLE); + SG_ADD( + &poslinear, "poslinear", "If positive HMM is a LinearHMM", + MS_NOT_AVAILABLE); } diff --git a/src/shogun/latent/LatentModel.cpp b/src/shogun/latent/LatentModel.cpp index d3bffbdcdfe..acdf03ef538 100644 --- a/src/shogun/latent/LatentModel.cpp +++ b/src/shogun/latent/LatentModel.cpp @@ -82,10 +82,15 @@ void CLatentModel::argmax_h(const SGVector& w) void CLatentModel::register_parameters() { - m_parameters->add((CSGObject**) &m_features, "features", "Latent features"); - m_parameters->add((CSGObject**) &m_labels, "labels", "Latent labels"); - m_parameters->add((CSGObject**) &m_cached_psi, "cached_psi", "Cached PSI features after argmax_h"); - m_parameters->add(&m_do_caching, "do_caching", "Indicate whether or not do PSI vector caching after argmax_h"); + SG_ADD(&m_features, "features", "Latent features", MS_NOT_AVAILABLE); + SG_ADD(&m_labels, "labels", "Latent labels", MS_NOT_AVAILABLE); + SG_ADD( + &m_cached_psi, "cached_psi", "Cached PSI features after argmax_h", + MS_NOT_AVAILABLE); + SG_ADD( + &m_do_caching, "do_caching", + "Indicate whether or not do PSI vector caching after argmax_h", + MS_NOT_AVAILABLE); } diff --git a/src/shogun/lib/List.h b/src/shogun/lib/List.h index 4a4922c39bd..4bcd1686686 100644 --- a/src/shogun/lib/List.h +++ b/src/shogun/lib/List.h @@ -53,12 +53,8 @@ class CListElement :public CSGObject private: void init() { - m_parameters->add(&data, "data", "Data of this element."); - m_parameters->add((CSGObject**) &next, "next", - "Next element in list."); - m_model_selection_parameters->add((CSGObject**) &next, "next", - "Next element in list."); - m_model_selection_parameters->add(&data, "data", "Data of this element."); + SG_ADD(&data, "data", "Data of this element.", MS_NOT_AVAILABLE); + SG_ADD(&next, "next", "Next element in list.", MS_NOT_AVAILABLE); } public: diff --git a/src/shogun/machine/LinearLatentMachine.cpp b/src/shogun/machine/LinearLatentMachine.cpp index a15e55daeba..8fb6b7c578f 100644 --- a/src/shogun/machine/LinearLatentMachine.cpp +++ b/src/shogun/machine/LinearLatentMachine.cpp @@ -116,9 +116,9 @@ void CLinearLatentMachine::init() m_max_iter = 400; m_model = NULL; - m_parameters->add(&m_C, "C", "Cost constant."); - m_parameters->add(&m_epsilon, "epsilon", "Convergence precision."); - m_parameters->add(&m_max_iter, "max_iter", "Maximum iterations."); - m_parameters->add((CSGObject**) &m_model, "latent_model", "Latent Model."); + SG_ADD(&m_C, "C", "Cost constant.", MS_NOT_AVAILABLE); + SG_ADD(&m_epsilon, "epsilon", "Convergence precision.", MS_NOT_AVAILABLE); + SG_ADD(&m_max_iter, "max_iter", "Maximum iterations.", MS_NOT_AVAILABLE); + SG_ADD(&m_model, "latent_model", "Latent Model.", MS_NOT_AVAILABLE); } diff --git a/src/shogun/mathematics/linalg/linop/DenseMatrixOperator.cpp b/src/shogun/mathematics/linalg/linop/DenseMatrixOperator.cpp index b621b6b3af9..08deb210a5e 100644 --- a/src/shogun/mathematics/linalg/linop/DenseMatrixOperator.cpp +++ b/src/shogun/mathematics/linalg/linop/DenseMatrixOperator.cpp @@ -57,9 +57,6 @@ template void CDenseMatrixOperator::init() { CSGObject::set_generic(); - - this->m_parameters->add(&m_operator, "dense_matrix", - "The dense matrix of the linear operator"); } template diff --git a/src/shogun/mathematics/linalg/linop/SparseMatrixOperator.cpp b/src/shogun/mathematics/linalg/linop/SparseMatrixOperator.cpp index 281cb1ba361..53aec34e1a4 100644 --- a/src/shogun/mathematics/linalg/linop/SparseMatrixOperator.cpp +++ b/src/shogun/mathematics/linalg/linop/SparseMatrixOperator.cpp @@ -63,16 +63,6 @@ template void CSparseMatrixOperator::init() { CSGObject::set_generic(); - - this->m_parameters->add_vector(&m_operator.sparse_matrix, - &m_operator.num_vectors, "sparse_matrix", - "The sparse matrix of the linear operator."); - this->watch_param( - "sparse_matrix", &m_operator.sparse_matrix, - &m_operator.num_vectors); - - this->m_parameters->add(&m_operator.num_features, - "m_operator.num_features", "Number of features."); } template diff --git a/src/shogun/mathematics/linalg/linsolver/IterativeLinearSolver.cpp b/src/shogun/mathematics/linalg/linsolver/IterativeLinearSolver.cpp index 3b0f5252a0c..32c232c4351 100644 --- a/src/shogun/mathematics/linalg/linsolver/IterativeLinearSolver.cpp +++ b/src/shogun/mathematics/linalg/linsolver/IterativeLinearSolver.cpp @@ -38,21 +38,6 @@ void CIterativeLinearSolver::init() m_relative_tolerence=1E-5; m_absolute_tolerence=1E-5; m_store_residuals=false; - - this->m_parameters->add(&m_max_iteration_limit, "max_iteration_limit", - "Maximum number of iteration for the solver"); - - this->m_parameters->add(&m_relative_tolerence, "relative_tolerence", - "Relative tolerence of solver"); - - this->m_parameters->add(&m_absolute_tolerence, "absolute_tolerence", - "Absolute tolerence of solver"); - - this->m_parameters->add(&m_store_residuals, "store_residuals", - "Whether to store the residuals"); - - this->m_parameters->add(&m_residuals, "residuals", - "Residuals for each iterations"); } template diff --git a/src/shogun/preprocessor/PNorm.cpp b/src/shogun/preprocessor/PNorm.cpp index 32b682884a5..6fba5cf7308 100644 --- a/src/shogun/preprocessor/PNorm.cpp +++ b/src/shogun/preprocessor/PNorm.cpp @@ -108,7 +108,7 @@ double CPNorm::get_pnorm () const void CPNorm::register_param () { - m_parameters->add (&m_p, "norm", "P-norm parameter"); + SG_ADD(&m_p, "norm", "P-norm parameter", MS_AVAILABLE); } inline float64_t CPNorm::get_pnorm (float64_t* vec, int32_t vec_len) const diff --git a/src/shogun/transfer/domain_adaptation/DomainAdaptationSVMLinear.cpp b/src/shogun/transfer/domain_adaptation/DomainAdaptationSVMLinear.cpp index 218adde1cf5..c315a22fd5a 100644 --- a/src/shogun/transfer/domain_adaptation/DomainAdaptationSVMLinear.cpp +++ b/src/shogun/transfer/domain_adaptation/DomainAdaptationSVMLinear.cpp @@ -63,10 +63,9 @@ void CDomainAdaptationSVMLinear::init(CLinearMachine* pre_svm, float64_t B_param is_presvm_sane(); // serialization code - m_parameters->add((CSGObject**) &presvm, "presvm", "SVM to regularize against"); - m_parameters->add(&B, "B", "Regularization strenth B."); - m_parameters->add(&train_factor, "train_factor", "train_factor"); - + SG_ADD(&presvm, "presvm", "SVM to regularize against", MS_AVAILABLE); + SG_ADD(&B, "B", "Regularization strenth B.", MS_AVAILABLE); + SG_ADD(&train_factor, "train_factor", "train_factor", MS_AVAILABLE); }