-
Notifications
You must be signed in to change notification settings - Fork 1.1k
add argument line_search_kwargs to BFGS
#1070
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
base: main
Are you sure you want to change the base?
Changes from all 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 |
|---|---|---|
|
|
@@ -81,7 +81,8 @@ def minimize(value_and_gradients_function, | |
| stopping_condition=None, | ||
| validate_args=True, | ||
| max_line_search_iterations=50, | ||
| name=None): | ||
| name=None, | ||
| line_search_kwargs={}): | ||
| """Applies the BFGS algorithm to minimize a differentiable function. | ||
|
|
||
| Performs unconstrained minimization of a differentiable function using the | ||
|
|
@@ -276,10 +277,9 @@ def _body(state): | |
| state, inverse_hessian_estimate=actual_inv_hessian) | ||
|
|
||
| next_state = bfgs_utils.line_search_step( | ||
| current_state, | ||
| value_and_gradients_function, actual_search_direction, | ||
| current_state, value_and_gradients_function, actual_search_direction, | ||
| tolerance, f_relative_tolerance, x_tolerance, stopping_condition, | ||
| max_line_search_iterations) | ||
| max_line_search_iterations, **line_search_kwargs) | ||
|
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. The purpose is for the user to be able to control the parameters of the actual line search algorithm, namely |
||
|
|
||
| # Update the inverse Hessian if needed and continue. | ||
| return [_update_inv_hessian(current_state, next_state)] | ||
|
|
||
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.
We have a pretty strong convention in TFP of letting the
nameargument be last.Also please use
Noneas a default value and explicitly set it to{}ifNonein the body, because{}is not safe as a default argument (see lint error on Travis).