Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
shin0biX
force-pushed
the
feature/line_search_kwargs
branch
from
September 21, 2026 11:43
bd4f58e to
704c379
Compare
This change allows users to customize the underlying Hager-Zhang line search algorithm parameters by passing a line_search_kwargs dictionary to the bfgs_minimize function. The parameters are passed through the optimization loop to the line search function at each iteration. Backward compatible: line_search_kwargs=None maintains existing behavior. Fixes tensorflow#1043
…4, setup-python@v5, upload-artifact@v4)
shin0biX
force-pushed
the
feature/line_search_kwargs
branch
from
September 21, 2026 12:30
f90152b to
22c8cc6
Compare
Author
|
The CLA and GitHub Actions Scan are passing. The remaining |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a line_search_kwargs parameter to the BFGS minimizer in TensorFlow Probability, allowing users to customize the underlying Hager-Zhang line search algorithm parameters.
Changes Made
Modified Files:
Detailed Changes:
In bfgs.py:
python
kwargs['line_search_kwargs'] = line_search_kwargs if line_search_kwargs is not None else {}
In bfgs_utils.py:
python
**(filtered_line_search_kwargs or {})
Features
Usage Example
python
import tensorflow_probability as tfp
import tensorflow as tf
def my_loss_and_grad_fn(x):
# Your loss and gradient computation
return loss, grad
results = tfp.optimizer.bfgs_minimize(
value_and_gradients_function=my_loss_and_grad_fn,
initial_position=tf.constant([0.0, 0.0]),
line_search_kwargs={
'initial_step_size': 0.1,
'threshold_use_approximate_wolfe_condition': 1e-4,
'max_iterations': 30
}
)
Testing
Comprehensive testing was performed to verify:
All tests pass, confirming the implementation is correct and ready for use.
Issue Addressed
This implementation addresses #1043 by adding the requested line_search_kwargs parameter to the BFGS minimizer.