-
Notifications
You must be signed in to change notification settings - Fork 227
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
Allow passing in non-optimizable parameters? #53
Comments
This is exactly what closures are for, it's a shame they are still such a performance hit. I hate to see API changes like this that may become unnecessary in the relatively near future. @JeffBezanson – any thoughts on how soon it might be plausible to get faster closures? |
I would love to have faster closures. But I think the use case I'm currently dealing with would be problematic even with faster closures: in these applications, I randomly modify the dataset being closed over on every single iteration of my optimization algorithm, which necessitates a new function definition on every iteration if you use closures to track the current data set being optimized against. Given Julia's approach to JIT-ing functions, it's not clear to me that closures will ever be able to catch up with the interface I'm describing. |
Since I basically need this functionality to push a project at work forward, I think I'm going to start an Optim2 package to work out how I'd like to see things. Would love to hear more what to expect from closures in future releases. |
I don't support changing the default interface to do this, it's horribly ugly, not something that I would want to put on a slide during a talk to sell Julia. What we might need is another level of abstraction over the optimization code so that both the current and the |
It does strike me as not the right default interface. |
Any suggestions? |
If we could dispatch on the argument signature of functions, this could be solved by automatically wrapping |
Since I'm on the topic of things I'd like to be able to do, the other functionality I've been needing is the ability to pass in a function that gets executed after every step. That lets you do things like SGD. |
I have a sense that it would be better to break apart the optimization a |
That sounds reasonable. I should look at a few other libraries and see how they handle this kind of thing. |
Breaking apart the functionality of |
Lately I've found myself constructing some pretty complicated closures to work around the current Optim interface.
As such, I'd like to propose a revised protocol for functions passed to Optim. Instead of working with a function
f(x::Array) -> Float64
, I'd like to work with functions of the formf(x::Array, extra::Any)
whereextra
can be used to provide any additional information needed to evaluatef
givenx
. This would make several things simpler:What would people think of making this kind of breaking change? It would make Optim much more general, but might also make the interface less intuitive for newcomers since you'd want to do something like
f(x, nothing)
when your function doesn't depend on additional information.The text was updated successfully, but these errors were encountered: