Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #402 from shelhamer/add-param-macro
Convert parameter assignments to SG_ADD macro
  • Loading branch information
Soeren Sonnenburg committed Apr 1, 2012
2 parents 3518f6d + 0bd6cf3 commit 72e11b3
Show file tree
Hide file tree
Showing 66 changed files with 296 additions and 248 deletions.
8 changes: 4 additions & 4 deletions src/shogun/clustering/KMeans.cpp
Expand Up @@ -484,9 +484,9 @@ void CKMeans::init()
k=3;
dimensions=0;

m_parameters->add(&max_iter, "max_iter", "Maximum number of iterations");
m_parameters->add(&k, "k", "Parameter k");
m_parameters->add(&dimensions, "dimensions", "Dimensions of data");
m_parameters->add(&R, "R", "Cluster radiuses");
SG_ADD(&max_iter, "max_iter", "Maximum number of iterations", MS_AVAILABLE);
SG_ADD(&k, "k", "k, the number of clusters", MS_AVAILABLE);
SG_ADD(&dimensions, "dimensions", "Dimensions of data", MS_NOT_AVAILABLE);
SG_ADD(&R, "R", "Cluster radiuses", MS_NOT_AVAILABLE);
}

2 changes: 1 addition & 1 deletion src/shogun/converter/DiffusionMaps.cpp
Expand Up @@ -34,7 +34,7 @@ CDiffusionMaps::CDiffusionMaps() :

void CDiffusionMaps::init()
{
m_parameters->add(&m_t, "t", "number of steps");
SG_ADD(&m_t, "t", "number of steps", MS_AVAILABLE);
}

CDiffusionMaps::~CDiffusionMaps()
Expand Down
12 changes: 6 additions & 6 deletions src/shogun/converter/EmbeddingConverter.cpp
Expand Up @@ -77,11 +77,11 @@ CKernel* CEmbeddingConverter::get_kernel() const

void CEmbeddingConverter::init()
{
this->m_parameters->add(&m_target_dim, "target_dim",
"target dimensionality of preprocessor");
this->m_parameters->add((CSGObject**)&m_distance, "distance",
"distance to be used for embedding");
this->m_parameters->add((CSGObject**)&m_kernel, "kernel",
"kernel to be used for embedding");
SG_ADD(&m_target_dim, "target_dim",
"target dimensionality of preprocessor", MS_AVAILABLE);
SG_ADD((CSGObject**)&m_distance, "distance",
"distance to be used for embedding", MS_AVAILABLE);
SG_ADD((CSGObject**)&m_kernel, "kernel", "kernel to be used for embedding",
MS_AVAILABLE);
}
}
2 changes: 1 addition & 1 deletion src/shogun/converter/Isomap.cpp
Expand Up @@ -88,7 +88,7 @@ CIsomap::CIsomap() : CMultidimensionalScaling()

void CIsomap::init()
{
m_parameters->add(&m_k, "k", "number of neighbors");
SG_ADD(&m_k, "k", "number of neighbors", MS_AVAILABLE);
}

CIsomap::~CIsomap()
Expand Down
4 changes: 2 additions & 2 deletions src/shogun/converter/LaplacianEigenmaps.cpp
Expand Up @@ -32,8 +32,8 @@ CLaplacianEigenmaps::CLaplacianEigenmaps() :

void CLaplacianEigenmaps::init()
{
m_parameters->add(&m_k, "k", "number of neighbors");
m_parameters->add(&m_tau, "tau", "heat distribution coefficient");
SG_ADD(&m_k, "k", "number of neighbors", MS_AVAILABLE);
SG_ADD(&m_tau, "tau", "heat distribution coefficient", MS_AVAILABLE);
}

CLaplacianEigenmaps::~CLaplacianEigenmaps()
Expand Down
20 changes: 10 additions & 10 deletions src/shogun/converter/LocallyLinearEmbedding.cpp
Expand Up @@ -100,17 +100,17 @@ CLocallyLinearEmbedding::CLocallyLinearEmbedding() :

void CLocallyLinearEmbedding::init()
{
m_parameters->add(&m_auto_k, "auto_k",
"whether k should be determined automatically in range");
m_parameters->add(&m_k, "k", "number of neighbors");
m_parameters->add(&m_max_k, "max_k",
"maximum number of neighbors used to compute optimal one");
SG_ADD(&m_auto_k, "auto_k",
"whether k should be determined automatically in range", MS_AVAILABLE);
SG_ADD(&m_k, "k", "number of neighbors", MS_AVAILABLE);
SG_ADD(&m_max_k, "max_k",
"maximum number of neighbors used to compute optimal one", MS_AVAILABLE);
m_parameters->add(&m_nullspace_shift, "nullspace_shift",
"nullspace finding regularization shift");
m_parameters->add(&m_reconstruction_shift, "reconstruction_shift",
"shift used to regularize reconstruction step");
m_parameters->add(&m_use_arpack, "use_arpack",
"whether arpack is being used or not");
"nullspace finding regularization shift");
SG_ADD(&m_reconstruction_shift, "reconstruction_shift",
"shift used to regularize reconstruction step", MS_NOT_AVAILABLE);
SG_ADD(&m_use_arpack, "use_arpack", "whether arpack is being used or not",
MS_NOT_AVAILABLE);
}


Expand Down
9 changes: 6 additions & 3 deletions src/shogun/converter/MultidimensionalScaling.cpp
Expand Up @@ -68,9 +68,12 @@ CMultidimensionalScaling::CMultidimensionalScaling() : CEmbeddingConverter()

void CMultidimensionalScaling::init()
{
m_parameters->add(&m_eigenvalues, "eigenvalues", "eigenvalues of last embedding");
m_parameters->add(&m_landmark, "landmark", "indicates if landmark approximation should be used");
m_parameters->add(&m_landmark_number, "landmark number", "the number of landmarks for approximation");
SG_ADD(&m_eigenvalues, "eigenvalues", "eigenvalues of last embedding",
MS_NOT_AVAILABLE);
SG_ADD(&m_landmark, "landmark",
"indicates if landmark approximation should be used", MS_NOT_AVAILABLE);
SG_ADD(&m_landmark_number, "landmark number",
"the number of landmarks for approximation", MS_AVAILABLE);
}

CMultidimensionalScaling::~CMultidimensionalScaling()
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/kernel/ANOVAKernel.cpp
Expand Up @@ -148,7 +148,7 @@ void CANOVAKernel::load_serializable_post() throw (ShogunException)

void CANOVAKernel::register_params()
{
m_parameters->add(&cardinality, "cardinality", "Kernel cardinality.");
SG_ADD(&cardinality, "cardinality", "Kernel cardinality.", MS_AVAILABLE);
}


Expand Down
4 changes: 2 additions & 2 deletions src/shogun/kernel/AUCKernel.cpp
Expand Up @@ -20,8 +20,8 @@ using namespace shogun;
void
CAUCKernel::init()
{
m_parameters->add((CSGObject**) &subkernel, "subkernel",
"The subkernel.");
SG_ADD((CSGObject**) &subkernel, "subkernel", "The subkernel.",
MS_AVAILABLE);
}

CAUCKernel::CAUCKernel()
Expand Down
4 changes: 2 additions & 2 deletions src/shogun/kernel/AvgDiagKernelNormalizer.h
Expand Up @@ -40,8 +40,8 @@ class CAvgDiagKernelNormalizer : public CKernelNormalizer
{
scale=c;

m_parameters->add(&scale, "scale",
"Scale quotient by which kernel is scaled.");
SG_ADD(&scale, "scale", "Scale quotient by which kernel is scaled."
MS_AVAILABLE);
}

/** default destructor */
Expand Down
9 changes: 5 additions & 4 deletions src/shogun/kernel/BesselKernel.cpp
Expand Up @@ -58,10 +58,11 @@ bool CBesselKernel::init(CFeatures* l, CFeatures* r)

void CBesselKernel::init()
{
m_parameters->add(&order, "order", "Kernel order.");
m_parameters->add(&width, "width", "Kernel width.");
m_parameters->add(&degree, "degree", "Kernel degree.");
m_parameters->add((CSGObject**) &distance, "distance", "Distance to be used.");
SG_ADD(&order, "order", "Kernel order.", MS_AVAILABLE);
SG_ADD(&width, "width", "Kernel width.", MS_AVAILABLE);
SG_ADD(&degree, "degree", "Kernel degree.", MS_AVAILABLE);
SG_ADD((CSGObject**) &distance, "distance", "Distance to be used.",
MS_AVAILABLE);
}

float64_t CBesselKernel::compute(int32_t idx_a, int32_t idx_b)
Expand Down
5 changes: 3 additions & 2 deletions src/shogun/kernel/CauchyKernel.cpp
Expand Up @@ -51,8 +51,9 @@ bool CCauchyKernel::init(CFeatures* l, CFeatures* r)

void CCauchyKernel::init()
{
m_parameters->add(&m_sigma, "sigma", "Sigma kernel parameter.");
m_parameters->add((CSGObject**) &m_distance, "distance", "Distance to be used.");
SG_ADD(&m_sigma, "sigma", "Sigma kernel parameter.", MS_AVAILABLE);
SG_ADD((CSGObject**) &m_distance, "distance", "Distance to be used.",
MS_AVAILABLE);
}

float64_t CCauchyKernel::compute(int32_t idx_a, int32_t idx_b)
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/kernel/Chi2Kernel.cpp
Expand Up @@ -19,7 +19,7 @@ using namespace shogun;
void
CChi2Kernel::init()
{
m_parameters->add(&width, "width");
SG_ADD(&width, "width", "Kernel width.", MS_AVAILABLE);
}

CChi2Kernel::CChi2Kernel()
Expand Down
5 changes: 3 additions & 2 deletions src/shogun/kernel/CircularKernel.cpp
Expand Up @@ -62,8 +62,9 @@ void CCircularKernel::load_serializable_post() throw (ShogunException)

void CCircularKernel::init()
{
m_parameters->add((CSGObject**) &distance, "distance", "Distance to be used.");
m_parameters->add(&sigma, "sigma", "Sigma kernel parameter.");
SG_ADD((CSGObject**) &distance, "distance", "Distance to be used.",
MS_AVAILABLE);
SG_ADD(&sigma, "sigma", "Sigma kernel parameter.", MS_AVAILABLE);
}

float64_t CCircularKernel::compute(int32_t idx_a, int32_t idx_b)
Expand Down
19 changes: 8 additions & 11 deletions src/shogun/kernel/CombinedKernel.cpp
Expand Up @@ -779,17 +779,14 @@ void CCombinedKernel::init()
kernel_list=new CList(true);
SG_REF(kernel_list);


m_parameters->add((CSGObject**) &kernel_list, "kernel_list",
"List of kernels.");
SG_ADD((CSGObject**) &kernel_list, "kernel_list", "List of kernels.",
MS_AVAILABLE);
m_parameters->add_vector(&sv_idx, &sv_count, "sv_idx",
"Support vector index.");
"Support vector index.");
m_parameters->add_vector(&sv_weight, &sv_count, "sv_weight",
"Support vector weights.");
m_parameters->add(&append_subkernel_weights,
"append_subkernel_weights",
"If subkernel weights are appended.");
m_parameters->add(&initialized, "initialized",
"Whether kernel is ready to be used.");
"Support vector weights.");
SG_ADD(&append_subkernel_weights, "append_subkernel_weights",
"If subkernel weights are appended.", MS_AVAILABLE);
SG_ADD(&initialized, "initialized", "Whether kernel is ready to be used.",
MS_NOT_AVAILABLE);
}

9 changes: 5 additions & 4 deletions src/shogun/kernel/CommWordStringKernel.cpp
Expand Up @@ -615,8 +615,9 @@ void CCommWordStringKernel::init()

m_parameters->add_vector(&dictionary_weights, &dictionary_size, "dictionary_weights",
"Dictionary for applying kernel.");
m_parameters->add(&use_sign, "use_sign",
"If signum(counts) is used instead of counts.");
m_parameters->add(&use_dict_diagonal_optimization, "use_dict_diagonal_optimization",
"If K(x,x) is computed potentially more efficiently.");
SG_ADD(&use_sign, "use_sign",
"If signum(counts) is used instead of counts.", MS_AVAILABLE);
SG_ADD(&use_dict_diagonal_optimization,
"use_dict_diagonal_optimization", "If K(x,x) is computed potentially "
"more efficiently.", MS_NOT_AVAILABLE);
}
3 changes: 2 additions & 1 deletion src/shogun/kernel/ConstKernel.cpp
Expand Up @@ -52,5 +52,6 @@ bool CConstKernel::init(CFeatures* l, CFeatures* r)
void CConstKernel::init()
{
const_value=1.0;
m_parameters->add(&const_value, "const_value", "Value for kernel elements.");
SG_ADD(&const_value, "const_value", "Value for kernel elements.",
MS_AVAILABLE);
}
4 changes: 2 additions & 2 deletions src/shogun/kernel/CustomKernel.cpp
Expand Up @@ -31,8 +31,8 @@ CCustomKernel::init()
MS_NOT_AVAILABLE);
SG_ADD(&m_free_km, "free_km", "Whether kernel matrix should be freed in "
"destructor", MS_NOT_AVAILABLE);
m_parameters->add(&kmatrix, "kmatrix", "Kernel matrix.");
m_parameters->add(&upper_diagonal, "upper_diagonal");
SG_ADD(&kmatrix, "kmatrix", "Kernel matrix.", MS_NOT_AVAILABLE);
SG_ADD(&upper_diagonal, "upper_diagonal", MS_NOT_AVAILABLE);

/* new parameter from param version 0 to 1 */
m_parameter_map->put(
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/kernel/DiagKernel.cpp
Expand Up @@ -51,5 +51,5 @@ bool CDiagKernel::init(CFeatures* l, CFeatures* r)
void CDiagKernel::init()
{
diag=1.0;
m_parameters->add(&diag, "diag", "Value on kernel diagonal.");
SG_ADD(&diag, "diag", "Value on kernel diagonal.", MS_AVAILABLE);
}
4 changes: 2 additions & 2 deletions src/shogun/kernel/DiceKernelNormalizer.h
Expand Up @@ -38,9 +38,9 @@ class CDiceKernelNormalizer : public CKernelNormalizer
"K(x,x) for left hand side examples.");
m_parameters->add_vector(&diag_rhs, &num_diag_rhs, "diag_rhs",
"K(x,x) for right hand side examples.");
m_parameters->add(&use_optimized_diagonal_computation,
SG_ADD(&use_optimized_diagonal_computation,
"use_optimized_diagonal_computation",
"flat if optimized diagonal computation is used");
"flat if optimized diagonal computation is used", MS_NOT_AVAILABLE);
}

/** default destructor */
Expand Down
5 changes: 3 additions & 2 deletions src/shogun/kernel/DistanceKernel.cpp
Expand Up @@ -67,6 +67,7 @@ float64_t CDistanceKernel::compute(int32_t idx_a, int32_t idx_b)

void CDistanceKernel::register_params()
{
m_parameters->add(&width, "width", "Kernel width.");
m_parameters->add((CSGObject**) &distance, "distance", "Distance to be used.");
SG_ADD(&width, "width", "Kernel width.", MS_AVAILABLE);
SG_ADD((CSGObject**) &distance, "distance", "Distance to be used.",
MS_AVAILABLE);
}
5 changes: 3 additions & 2 deletions src/shogun/kernel/ExponentialKernel.cpp
Expand Up @@ -69,6 +69,7 @@ void CExponentialKernel::load_serializable_post() throw (ShogunException)

void CExponentialKernel::init()
{
m_parameters->add(&m_width, "width", "Kernel width.");
m_parameters->add((CSGObject**) &m_distance, "distance", "Distance to be used.");
SG_ADD(&m_width, "width", "Kernel width.", MS_AVAILABLE);
SG_ADD((CSGObject**) &m_distance, "distance", "Distance to be used.",
MS_AVAILABLE);
}
4 changes: 2 additions & 2 deletions src/shogun/kernel/FirstElementKernelNormalizer.h
Expand Up @@ -32,8 +32,8 @@ class CFirstElementKernelNormalizer : public CKernelNormalizer
*/
CFirstElementKernelNormalizer() : CKernelNormalizer(), scale(1.0)
{
m_parameters->add(&scale, "scale",
"Scale quotient by which kernel is scaled.");
SG_ADD(&scale, "scale", "Scale quotient by which kernel is scaled.",
MS_AVAILABLE);
}

/** default destructor */
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/kernel/FixedDegreeStringKernel.cpp
Expand Up @@ -20,7 +20,7 @@ using namespace shogun;
void
CFixedDegreeStringKernel::init()
{
m_parameters->add(&degree, "degree", "The degree.");
SG_ADD(&degree, "degree", "The degree.", MS_AVAILABLE);
set_normalizer(new CSqrtDiagKernelNormalizer());
}

Expand Down
2 changes: 1 addition & 1 deletion src/shogun/kernel/GaussianMatchStringKernel.cpp
Expand Up @@ -81,5 +81,5 @@ float64_t CGaussianMatchStringKernel::compute(int32_t idx_a, int32_t idx_b)

void CGaussianMatchStringKernel::register_params()
{
m_parameters->add(&width, "width", "kernel width");
SG_ADD(&width, "width", "kernel width", MS_AVAILABLE);
}
4 changes: 2 additions & 2 deletions src/shogun/kernel/GaussianShiftKernel.cpp
Expand Up @@ -80,7 +80,7 @@ float64_t CGaussianShiftKernel::compute(int32_t idx_a, int32_t idx_b)

void CGaussianShiftKernel::init()
{
m_parameters->add(&max_shift, "max_shift", "Maximum shift.");
m_parameters->add(&shift_step, "shift_step", "Shift stepsize.");
SG_ADD(&max_shift, "max_shift", "Maximum shift.", MS_AVAILABLE);
SG_ADD(&shift_step, "shift_step", "Shift stepsize.", MS_AVAILABLE);
}

2 changes: 1 addition & 1 deletion src/shogun/kernel/GaussianShortRealKernel.cpp
Expand Up @@ -69,5 +69,5 @@ float64_t CGaussianShortRealKernel::compute(int32_t idx_a, int32_t idx_b)

void CGaussianShortRealKernel::register_params()
{
m_parameters->add(&width, "width", "kernel width");
SG_ADD(&width, "width", "kernel width", MS_AVAILABLE);
}
2 changes: 1 addition & 1 deletion src/shogun/kernel/HistogramIntersectionKernel.cpp
Expand Up @@ -83,5 +83,5 @@ float64_t CHistogramIntersectionKernel::compute(int32_t idx_a, int32_t idx_b)

void CHistogramIntersectionKernel::register_params()
{
m_parameters->add(&m_beta, "beta", "the beta parameter of the kernel");
SG_ADD(&m_beta, "beta", "the beta parameter of the kernel", MS_AVAILABLE);
}
6 changes: 4 additions & 2 deletions src/shogun/kernel/HistogramWordStringKernel.cpp
Expand Up @@ -413,7 +413,8 @@ void CHistogramWordStringKernel::init()
sum_m2_s2=0;
initialized=false;

m_parameters->add(&initialized, "initialized", "if kernel is initalized");
SG_ADD(&initialized, "initialized", "If kernel is initalized.",
MS_NOT_AVAILABLE);
m_parameters->add_vector(&plo_lhs, &num_lhs, "plo_lhs");
m_parameters->add_vector(&plo_rhs, &num_rhs, "plo_rhs");
m_parameters->add_vector(&ld_mean_lhs, &num_lhs, "ld_mean_lhs");
Expand All @@ -423,7 +424,8 @@ void CHistogramWordStringKernel::init()
m_parameters->add_vector(&mean, &num_params2, "mean");
m_parameters->add_vector(&variance, &num_params2, "variance");

m_parameters->add((CSGObject**) &estimate, "estimate", "Plugin Estimate.");
SG_ADD((CSGObject**) &estimate, "estimate", "Plugin Estimate.",
MS_NOT_AVAILABLE);
}

#ifdef DEBUG_HWSK_COMPUTATION
Expand Down
5 changes: 3 additions & 2 deletions src/shogun/kernel/InverseMultiQuadricKernel.cpp
Expand Up @@ -54,8 +54,9 @@ void CInverseMultiQuadricKernel::load_serializable_post() throw (ShogunException

void CInverseMultiQuadricKernel::init()
{
m_parameters->add(&coef, "coef", "Kernel Coefficient.");
m_parameters->add((CSGObject**) &distance, "distance", "Distance to be used.");
SG_ADD(&coef, "coef", "Kernel Coefficient.", MS_AVAILABLE);
SG_ADD((CSGObject**) &distance, "distance", "Distance to be used.",
MS_AVAILABLE);
}

float64_t CInverseMultiQuadricKernel::compute(int32_t idx_a, int32_t idx_b)
Expand Down

0 comments on commit 72e11b3

Please sign in to comment.