Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tensorflow_probability/python/optimizer/bfgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={}):
Copy link
Copy Markdown
Contributor

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 name argument be last.

Also please use None as a default value and explicitly set it to {} if None in the body, because {} is not safe as a default argument (see lint error on Travis).

"""Applies the BFGS algorithm to minimize a differentiable function.

Performs unconstrained minimization of a differentiable function using the
Expand Down Expand Up @@ -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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 linesearch.hager_zhang. All of the parameters that line_search_step itself consumes are already being passed in explicitly. Please pass the dictionary through to that depth, and add a unit test that you can, indeed, affect the behavior of the algorithm by controlling at least one of those parameters (e.g., initial_step_size).


# Update the inverse Hessian if needed and continue.
return [_update_inv_hessian(current_state, next_state)]
Expand Down