Closed tpapp closed 4 years ago
Here is an MWE with only_fg!
, the question is whether this can be simplified:
using Optim
using NLSolversBase: only_fg!
fg(x) = 0.5*sum(abs2, x), x
function fg!(F, G, x)
f, g = fg(x)
G ≠ nothing && copy!(G, g)
f
end
optimize(OnceDifferentiable(only_fg!(fg!), ones(3)), ones(3), LBFGS())
Friendly bump, I still could not figure out a better solution (but the above works).
I'm not sure why I didn't get any notifications here, sorry, didn't see it until now. Don't hesitate tagging me in the future :)
Are you looking for something that only takes in x
or which part is it that is important to you?
I simply have code that calculates a function and its gradient, and I am wondering if I can just make a OnceDifferentiable
out of it without making a modifying wrapper.
Or, failing that, if my solution above is the recommended one.
Why am I not getting any notifications for this repo? I have set it to watching, but I didn't get this notification, nor Tim's PR that I just merged...
did you try the OnceDifferentiable(only_fg(fg))
route? I think that's been included for quite a while.
No, I went with only_fg!
, code here.
Where is only_fg
documented? I am not sure how to use it.
It's not, but
function f(x)
sum(x->x^2,x)
end
g(x) = 2 .* x
fg(x) = f(x), g(x)
od_fg = OnceDifferentiable(only_fg(fg), x)
Thanks. I may modify my code above.
My main concern about this package (in general) is that API stability commitments are unclear, so I am wary of using undocumented functions in stable packages. Some documentation (ie the usual Documenter.jl-generated pages and docstrings) would help a lot.
Thanks. I may modify my code above.
My main concern about this package (in general) is that API stability commitments are unclear, so I am wary of using undocumented functions in stable packages. Some documentation (ie the usual Documenter.jl-generated pages and docstrings) would help a lot.
Okay, I guess I can say what is expected to be stable. But breaking changes should only happen without major versions for things that are not exported.
Overall, most of this package should be expected to be stable, as most new development is spent elsewhere and will superceed this.
most new development is spent elsewhere and will superceed this
can you tell me where that is happening, if there is a public repo already?
@tpapp I think the repo is https://github.com/pkofod/NLSolvers.jl and the plan is presented in https://www.youtube.com/watch?v=GfRSPEhewwM
I don't always keep it up to date, but it does work to some extent :) Some of it is coherent, some of it is thrown in ! I have some recent changes off-line based on discussions with @tkf on problematic updates (damped BFGS, etc), and I hope to push a proper More & Sorensen trust region sub-problem solver soon.
This is more of a support request than an issue, I could not find this in the docs. I have a closure
fg
which calculates values and derivatives, egFor an MWE, consider
How can I wrap this in
OnceDifferentiable
? I want to use this with Optim.jl.