-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SG_ADD refactor #4417
SG_ADD refactor #4417
Changes from all commits
6de1d81
c610f3c
d304e15
a601c0a
bd9e09e
2458eee
9d6e506
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,8 @@ | |
* Authors: Heiko Strathmann, Soeren Sonnenburg, Sergey Lisitsyn, | ||
* Giovanni De Toni, Jacob Walker, Thoralf Klein, Chiyuan Zhang, | ||
* Fernando Iglesias, Sanuj Sharma, Roman Votyakov, Yuyu Zhang, | ||
* Viktor Gal, Bjoern Esser, Evangelos Anagnostopoulos, Pan Deng | ||
* Viktor Gal, Bjoern Esser, Evangelos Anagnostopoulos, Pan Deng, | ||
* Gil Hoben | ||
*/ | ||
|
||
#ifndef __SGOBJECT_H__ | ||
|
@@ -56,55 +57,51 @@ template <class T> class SGStringList; | |
#define SG_UNREF_NO_NULL(x) { if (x) { (x)->unref(); } } | ||
|
||
/******************************************************************************* | ||
* Macros for registering parameters/model selection parameters | ||
* Macros for registering parameter properties | ||
******************************************************************************/ | ||
|
||
#ifdef _MSC_VER | ||
|
||
#define VA_NARGS(...) INTERNAL_EXPAND_ARGS_PRIVATE(INTERNAL_ARGS_AUGMENTER(__VA_ARGS__)) | ||
#define INTERNAL_ARGS_AUGMENTER(...) unused, __VA_ARGS__ | ||
#define INTERNAL_EXPAND(x) x | ||
#define INTERNAL_EXPAND_ARGS_PRIVATE(...) INTERNAL_EXPAND(INTERNAL_GET_ARG_COUNT_PRIVATE(__VA_ARGS__, 5, 4, 3, 2, 1, 0)) | ||
#define INTERNAL_GET_ARG_COUNT_PRIVATE(_0_, _1_, _2_, _3_, _4_, _5_, count, ...) count | ||
#define INTERNAL_EXPAND_ARGS_PRIVATE(...) INTERNAL_EXPAND(INTERNAL_GET_ARG_COUNT_PRIVATE(__VA_ARGS__, 4, 3, 2, 1, 0)) | ||
#define INTERNAL_GET_ARG_COUNT_PRIVATE(_0_, _1_, _2_, _3_, _4_, count, ...) count | ||
|
||
#else | ||
|
||
#define VA_NARGS_IMPL(_1, _2, _3, _4, _5, N, ...) N | ||
#define VA_NARGS(...) VA_NARGS_IMPL(__VA_ARGS__, 5, 4, 3, 2, 1) | ||
#define VA_NARGS_IMPL(_1, _2, _3, _4, N, ...) N | ||
#define VA_NARGS(...) VA_NARGS_IMPL(__VA_ARGS__, 4, 3, 2, 1) | ||
|
||
#endif | ||
|
||
#define VARARG_IMPL2(base, count, ...) base##count(__VA_ARGS__) | ||
#define VARARG_IMPL(base, count, ...) VARARG_IMPL2(base, count, __VA_ARGS__) | ||
#define VARARG(base, ...) VARARG_IMPL(base, VA_NARGS(__VA_ARGS__), __VA_ARGS__) | ||
|
||
#define SG_ADD4(param, name, description, ms_available) \ | ||
#define SG_ADD3(param, name, description) \ | ||
{ \ | ||
this->m_parameters->add(param, name, description); \ | ||
this->watch_param( \ | ||
name, param, \ | ||
AnyParameterProperties( \ | ||
description, ms_available, GRADIENT_NOT_AVAILABLE)); \ | ||
if (ms_available) \ | ||
this->m_model_selection_parameters->add(param, name, description); \ | ||
name, param, AnyParameterProperties()); \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes this is good |
||
} | ||
|
||
#define SG_ADD5(param, name, description, ms_available, gradient_available) \ | ||
#define SG_ADD4(param, name, description, param_properties) \ | ||
{ \ | ||
AnyParameterProperties pprop = \ | ||
AnyParameterProperties(description, param_properties); \ | ||
this->m_parameters->add(param, name, description); \ | ||
this->watch_param( \ | ||
name, param, AnyParameterProperties( \ | ||
description, ms_available, gradient_available)); \ | ||
if (ms_available) \ | ||
this->watch_param(name, param, pprop); \ | ||
if (pprop.get_model_selection()) \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note for later: we can already start to get rid of the |
||
this->m_model_selection_parameters->add(param, name, description); \ | ||
if (gradient_available) \ | ||
if (pprop.get_gradient()) \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same for those gradient parameters |
||
this->m_gradient_parameters->add(param, name, description); \ | ||
} | ||
|
||
#define SG_ADD(...) VARARG(SG_ADD, __VA_ARGS__) | ||
|
||
/******************************************************************************* | ||
* End of macros for registering parameters/model selection parameters | ||
* End of macros for registering parameter properties | ||
******************************************************************************/ | ||
|
||
/** @brief Class SGObject is the base class of all shogun objects. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,9 +49,9 @@ void CLDA::init() | |
|
||
SG_ADD( | ||
(machine_int_t*)&m_method, "m_method", | ||
"Method used for LDA calculation", MS_NOT_AVAILABLE); | ||
SG_ADD(&m_gamma, "m_gamma", "Regularization parameter", MS_AVAILABLE); | ||
SG_ADD(&m_bdc_svd, "m_bdc_svd", "Use BDC-SVD algorithm", MS_NOT_AVAILABLE); | ||
"Method used for LDA calculation"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, much cleaner |
||
SG_ADD(&m_gamma, "m_gamma", "Regularization parameter", ParameterProperties::HYPER); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is quite nice now |
||
SG_ADD(&m_bdc_svd, "m_bdc_svd", "Use BDC-SVD algorithm"); | ||
} | ||
|
||
CLDA::~CLDA() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weclome to SGObject ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha yes, I thought I would discretely add myself to the list :D