summaryrefslogtreecommitdiff
path: root/training/liblbfgs/lbfgs++.h
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-05-13 16:18:43 -0700
committerChris Dyer <cdyer@cs.cmu.edu>2012-05-13 16:18:43 -0700
commit69b0bf8d618338c82fda17878defff77fb35a69f (patch)
tree3f001b9e6b9a38ec3a3523d2ea2ebd2bef47f260 /training/liblbfgs/lbfgs++.h
parenta097d3ea4132ba4c39c670185a3f4237d24030f9 (diff)
fast creg training code for univariate linear and logistic regression
Diffstat (limited to 'training/liblbfgs/lbfgs++.h')
-rw-r--r--training/liblbfgs/lbfgs++.h29
1 files changed, 18 insertions, 11 deletions
diff --git a/training/liblbfgs/lbfgs++.h b/training/liblbfgs/lbfgs++.h
index 342f9b0e..92ead955 100644
--- a/training/liblbfgs/lbfgs++.h
+++ b/training/liblbfgs/lbfgs++.h
@@ -16,28 +16,33 @@
template <typename Function>
class LBFGS {
public:
- LBFGS(size_t n, // number of variables
- const Function& f, // function to optimize
- double l1_c = 0.0, // l1 penalty strength
- size_t m = 10 // number of memory buffers
- // TODO should use custom allocator here:
+ LBFGS(size_t n, // number of variables
+ const Function& f, // function to optimize
+ size_t m = 10, // number of memory buffers
+ double l1_c = 0.0, // l1 penalty strength
+ unsigned l1_start = 0, // l1 penalty starting index
+ double eps = 1e-5 // convergence epsilon
+ // TODO should use custom allocator here:
) : p_x(new std::vector<lbfgsfloatval_t>(n, 0.0)),
owned(true),
m_x(*p_x),
func(f) {
- Init(m, l1_c);
+ Init(m, l1_c, l1_start, eps);
}
// constructor where external vector storage for variables is used
LBFGS(std::vector<lbfgsfloatval_t>* px,
const Function& f,
- double l1_c = 0.0, // l1 penalty strength
- size_t m = 10
+ size_t m = 10, // number of memory buffers
+ double l1_c = 0.0, // l1 penalty strength
+ unsigned l1_start = 0, // l1 penalty starting index
+ double eps = 1e-5 // convergence epsilon
+ // TODO should use custom allocator here:
) : p_x(px),
owned(false),
m_x(*p_x),
func(f) {
- Init(m, l1_c);
+ Init(m, l1_c, l1_start, eps);
}
~LBFGS() {
@@ -60,12 +65,14 @@ class LBFGS {
}
private:
- void Init(size_t m, double l1_c) {
+ void Init(size_t m, double l1_c, unsigned l1_start, double eps) {
lbfgs_parameter_init(&param);
param.m = m;
+ param.epsilon = eps;
if (l1_c > 0.0) {
param.linesearch = LBFGS_LINESEARCH_BACKTRACKING;
- param.orthantwise_c = 1.0;
+ param.orthantwise_c = l1_c;
+ param.orthantwise_start = l1_start;
}
silence = false;
}