-
Notifications
You must be signed in to change notification settings - Fork 696
Fix lbfgsb linesearch out of bound and findAlpha method #633
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
Changes from 2 commits
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 |
|---|---|---|
|
|
@@ -58,12 +58,19 @@ class StrongWolfeLineSearch(maxZoomIter: Int, maxLineSearchIter: Int) extends Cu | |
| val c1 = 1e-4 | ||
| val c2 = 0.9 | ||
|
|
||
| def minimize(f: DiffFunction[Double], init: Double = 1.0): Double = { | ||
| minimizeWithBound(f, init = 1.0, bound = Double.PositiveInfinity) | ||
|
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. LBFGS is passing init value not always equals to 1 to this method. It that right to ignore it here?
Contributor
Author
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. In LBFGS-B, we can use 1 as the init value, according to paper, or do you have some better init value ? 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. Personally, I don't have a better init value, but LBFGS has: https://github.com/scalanlp/breeze/blob/master/math/src/main/scala/breeze/optimize/LBFGS.scala#L76 :) Let me describe my problem: I've updated spark in my project to latest version (2.2) and some test on logistic regression start failing.
Contributor
Author
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. oh! you're right. we should fix it. like:
Contributor
Author
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. Thanks for finding this bug! |
||
| } | ||
|
|
||
| /** | ||
| * Performs a line search on the function f, returning a point satisfying | ||
| * the Strong Wolfe conditions. Based on the line search detailed in | ||
| * Nocedal & Wright Numerical Optimization p58. | ||
| * Performs a line search on the function f with bound, returning a point satisfying | ||
| * the Strong Wolfe conditions OR satisfying sufficient decrease condition and hit bound. | ||
| * Based on the line search detailed in Nocedal & Wright Numerical Optimization p58. | ||
| * BUT add some modification for bound checking. | ||
| */ | ||
|
Contributor
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. Should we update the annotation? It looks like out of date. |
||
| def minimize(f: DiffFunction[Double], init: Double = 1.0):Double = { | ||
| def minimizeWithBound(f: DiffFunction[Double], init: Double = 1.0, bound: Double = 1.0): Double = { | ||
|
|
||
| require(init <= bound, "init value should <= bound") | ||
|
|
||
| def phi(t: Double): Bracket = { | ||
| val (pval, pdd) = f.calculate(t) | ||
|
|
@@ -171,8 +178,17 @@ class StrongWolfeLineSearch(maxZoomIter: Int, maxLineSearchIter: Int) extends Cu | |
| } | ||
|
|
||
| low = c | ||
| t *= 1.5 | ||
| logger.debug("Sufficent Decrease condition but not curvature condition satisfied. Increased t to: " + t) | ||
| if (t == bound) { | ||
| logger.debug("Reach bound, satisfy sufficent decrease condition," + | ||
| " but not curvature condition satisfied.") | ||
| return bound | ||
| } else { | ||
| t *= 1.5 | ||
| if (t > bound) { | ||
| t = bound | ||
| } | ||
| logger.debug("Sufficent Decrease condition but not curvature condition satisfied. Increased t to: " + t) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
i prefer cforRange these days