Skip to content

jbrea/OptimizationCallbacks.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OptimizationCallbacks.jl

lifecycle build

Documentation

Aqua QA

This package contains a bunch of callable objects that can be useful as callbacks in optimization, such as progress logging (LogProgress), check point saving (CheckPointSaver), or evaluations on other functions, e.g. for tracking validation losses (Evaluator). These callbacks can be triggered with different mechanisms, either based on iteration step (IterationTrigger), on time (TimeTrigger), or on special events, e.g. at the end of optimization (EventTrigger). The package is tested with the popular Optimization.jl package, but it does not depend on it and can also be used in custom optimization procedures, or with other packages.

julia> using Optimization

julia> using OptimizationCallbacks

julia> import ForwardDiff

julia> function rosenbrock(x, p)
           (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
       end
rosenbrock (generic function with 1 method)

julia> optf = OptimizationFunction(rosenbrock, AutoForwardDiff());

julia> prob = OptimizationProblem(optf, [0., 0.], [1., 100.]);

julia> callback = Callback(IterationTrigger(5), LogProgress());

julia> sol = solve(prob, Optimization.LBFGS(); callback)
 eval   | current     | lowest      | highest
_________________________________________________
      5 |    0.460215 |    0.460215 |    0.460215
     10 |    0.162607 |    0.162607 |    0.460215
     15 |   0.0257404 |   0.0257404 |    0.460215
     20 | 0.000911646 | 0.000911646 |    0.460215
     25 | 1.04339e-13 | 1.04339e-13 |    0.460215
retcode: Success
u: 2-element Vector{Float64}:
 0.9999997057368228
 0.999999398151528

More examples can be found in the documentation.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages