-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
How to get latest minimizer (u) instead of the best one for optimization? #740
Comments
I am genuinely surprised 🤣 You can use a callback to store the
|
Yeah, I actually found the things that I'd been looking for, so 👍 (except the one above) Thank you! Ok, this is actually the way I am doing it right now... maybe this is something for a feature request (e.g. adding |
Since some solvers already store this in their results I haven't seen a reason to do this and increase the memory usage even more for the results (and you as the user can do it with the callback) |
If some solvers already store this, then you just use the same reference and there's no extra memory cost? |
I have another example where this is very common: Stochastic batching when optimizing ML models... without the option to pick the Also: The callback gets called one last time for the best element after optimization finished, so with the code above:
I didn't check the implementation, but wouldn't it be possible to let a keyword decide if either the state Thanks! |
I am not sure if this was specific for Optimisers.jl solvers since you mention stochastic methods, if it is you can pass |
Hi Thanks for all the great work with the sciml ecosystem! I am working on a paper related to NeuralODE and came across the following problem where the returned optimization parameters were not the "best" I am asking this here rather than in Discourse since it seems related to this thread. Here is a MWP that seems to be show that the returned objective value is not the "best" even when save_best=true is set in the OptimizationProblem. I am trying this on a mac M2. == using Zygote rosenbrock(u, p) = (p[1] - u[1])^2 + p[2] * (u[2] - u[1]^2)^2 optf = OptimizationFunction(rosenbrock, AutoZygote()) sol.objective == sol.objectve returns the latest objective evaluation rather than some of the better values (to the tume of 1e-13 evaluated earlier) My Project.toml is as follows Status Regards |
Does it work if you pass it in |
No. It still returns the same objective. |
I did some investigation. Looks like the check before the last iteration is not activated. (Line 133 of OptimizationOptimisers.jl). I modified that from |
That makes sense, this wasn't updated when we changed to separating out the maxiters and epochs args, do you want to do a PR? |
Sure. I will create one by tomorrow. |
Question❓
Hi,
I really like the quality of the documentation, however I struggle to find a functionality I am pretty sure that it exists:
If I get this correct, Optimization.jl always returns the minimizer
u
for the best (minimum/maximum)f
evaluation - this is nice and often what I want.However in some cases one is more interested in the latest
u
- so the last try to find a new optimum (think e.g. of having some stochastic effects in yourf
). Is there a keyword or similar?I would assume to find this on this page of the docu:
Common-Solver-Options-(Solve-Keyword-Arguments)
Thanks in advance!
The text was updated successfully, but these errors were encountered: