-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: main
Are you sure you want to change the base?
Conversation
src/Backtracking.jl
Outdated
end | ||
|
||
# Determine step size by backtracking line search | ||
function Backtracking(backtrack::Backtracking) |
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.
function Backtracking(backtrack::Backtracking) | |
function Backtracking(;x, g, α, p , f) |
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.
Since this should be a constructor for the method
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 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.
src/Backtracking.jl
Outdated
iteration = 0 | ||
|
||
# Backtracking line search | ||
while ϕ_α > ϕ_0 + c1 * α * g * p |
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.
Move this oput to a separate function that takes as argument the function and a Backtracking
object
src/Backtracking.jl
Outdated
|
||
# Ensure termination | ||
if iteration > iterations | ||
throw(LineSearchException("Linesearch failed to converge, reached maximum iterations $(iterations).", α)) |
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.
Don't throw an error, return NaN
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.
Take a look at #3 for some more context for the review comments
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 |
I add a basic backtracking line search method and add a single test (quadratic function) to validate the correctness of the implementation.