Skip to content
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

Add backtracking line search #2

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

Xiaoyi-Qu
Copy link

I add a basic backtracking line search method and add a single test (quadratic function) to validate the correctness of the implementation.

end

# Determine step size by backtracking line search
function Backtracking(backtrack::Backtracking)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function Backtracking(backtrack::Backtracking)
function Backtracking(;x, g, α, p , f)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this should be a constructor for the method

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel confused about this comment. In the function Backtracking, there are five arguments including f. Here f is a function. A function cannot be an argument of a function. That is where I feel confused.

iteration = 0

# Backtracking line search
while ϕ_α > ϕ_0 + c1 * α * g * p
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this oput to a separate function that takes as argument the function and a Backtracking object


# Ensure termination
if iteration > iterations
throw(LineSearchException("Linesearch failed to converge, reached maximum iterations $(iterations).", α))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't throw an error, return NaN

Copy link
Member

@Vaibhavdixit02 Vaibhavdixit02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at #3 for some more context for the review comments

@Xiaoyi-Qu
Copy link
Author

Xiaoyi-Qu commented Mar 17, 2024

I rewrote the backtracking line search function as you suggest. There is one minor point that is unsatisfactory, and I have not changed that. That is hyperparameters are not put into struct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants