-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
Use common convergence checks for lbfgs solver #14250
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
Conversation
@@ -74,7 +73,7 @@ def optimizer(obj_func, initial_theta, bounds): | |||
# the corresponding value of the target function. | |||
return theta_opt, func_min | |||
|
|||
Per default, the 'fmin_l_bfgs_b' algorithm from scipy.optimize | |||
Per default, the 'L-BFGS-B' algorithm from scipy.optimize.maximize | |||
is used. If None is passed, the kernel's parameters are kept fixed. | |||
Available internal optimizers are:: | |||
|
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.
Should we then deprecate fmin_l_bfgs_b
as the input value in favor of L-BFGS-B
, or lbfgs
?
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.
Yes, I think that would be in order, and similarly I wanted to see if allowing other scipy optimizers in Gaussian processes would be interesting. Though I would rather do that in a follow-up PR, and keep this as a minimal refactoring not affecting backward compatibility.
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 agree allowing other optimizers would be a different PR, but since you're touching the docstring here, it makes sense for the accepted value to be the same or similar to what you mention in the docstring, I think.
But if you wanna do the deprecation in a different PR, I'm happy with that as well, and then this LGTM.
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 haven't changed the docstring value here only changed that the algorithm is called L-BFGS-B
, not fmin_l_bfgs_b
. That fix would apply even before this PR as fmin_l_bfgs_b
is not an algorithm name it's the scipy function name for that optimizer.
Will do the deprecated in a follow up PR :) Thanks for the review!
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.
Thanks @rth, I really like PRs like this one.
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.
looks great!
thx heaps @rth |
First step toward #14248
This replaces to calls to
fmin_l_bfgs_b
withscipy.optimize.minimize(method="L-BFGS-B")
and uses a common helper to check for convergence (for instance previously no warnings were shown in Gaussian process models). It also consistently applies the fix formax_iter
,that was not done in neural_network module. Follow up on #9274 (review).
Although this PR is mostly an internal refactoring, it also fixes the above mentioned issues, and could be considered a bug fix.
The message in case of a
ConvergenceWarning
is changed, so in that sense its somewhat non backward compatible change, but because the warning type is very specific I don't know how much that matters.Note:
fmin_l_bfgs_b
is now marked as a legacy function in scipy,The mapping between legacy and new parameters for the optimization result can be found here