Skip to content

Commit

Permalink
add gamma in lbfgs learner
Browse files Browse the repository at this point in the history
  • Loading branch information
mli committed Mar 3, 2016
1 parent 2e81057 commit db44e42
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lbfgs/lbfgs_learner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ real_t LBFGSLearner::CalcGrad(const SArray<real_t>& w_val,
}
prog_.auc = auc[0];
*grad = grads[0];
if (param_.gamma != 1) {
for (real_t& g : *grad) g = (g > 0 ? 1 : -1) * pow(fabs(g), param_.gamma);
}
return objv[0];
}

Expand Down
3 changes: 3 additions & 0 deletions src/lbfgs/lbfgs_param.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ struct LBFGSLearnerParam : public dmlc::Parameter<LBFGSLearnerParam> {
real_t c1;
real_t c2;
real_t rho;

real_t gamma;
int max_num_linesearchs;

int num_threads;
Expand All @@ -61,6 +63,7 @@ struct LBFGSLearnerParam : public dmlc::Parameter<LBFGSLearnerParam> {
DMLC_DECLARE_FIELD(init_alpha).set_default(0);
DMLC_DECLARE_FIELD(max_num_linesearchs).set_default(5);
DMLC_DECLARE_FIELD(c1).set_default(1e-4);
DMLC_DECLARE_FIELD(gamma).set_default(1);
DMLC_DECLARE_FIELD(c2).set_default(.9);
DMLC_DECLARE_FIELD(rho).set_default(.5);
DMLC_DECLARE_FIELD(load_epoch).set_default(0);
Expand Down

0 comments on commit db44e42

Please sign in to comment.