Skip to content
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

Changes to DifferentiableFunction API #287

Closed
ahwillia opened this issue Sep 25, 2016 · 2 comments
Closed

Changes to DifferentiableFunction API #287

ahwillia opened this issue Sep 25, 2016 · 2 comments

Comments

@ahwillia
Copy link
Contributor

Now that PR #266 looks nearly complete, I'm hoping we can revisit issue #156 and a few other additions or changes I've been thinking about. I know @johnmyleswhite mentioned that he would like to change the API in the past (not sure if that was meant in a broader sense or not).

Minor / Low Priority:

  • As I brought up in switch argument order for gradient and hessian evaluations? #156 - I think it would be nice to switch the order of the arguments so that fg!(x, storage) becomes fg!(storage, x) (making the mutated argument come first seems more consistent with Julian conventions and autodiff packages).
  • I kind of like changing the names to OnceDifferentiable and TwiceDifferentiable for brevity (and clarity in the case of DifferentiableFunction which is a bit ambiguous). This could be handled with a depwarn, but maybe isn't worth it. We could also consider merging these into a single type (see some options below)

Higher Priority:

  • DifferentiableFunction and TwiceDifferentiableFunction should know about each other somehow. Some ideas:
abstract AbstractDifferientiable
type OnceDifferentiable <: AbstractDifferentable ...  end
type TwiceDifferentiable <: AbstractDifferentiable ... end
typealias Differentiable Union{OnceDifferentiable, TwiceDifferentiable}
# Merge OnceDifferentiable and TwiceDifferentiable ?
# This could be a problem for dispatching on one vs the other. But there are tricks to fix it.
type Differentiable
    f::Function
    g!::Function
    fg!::Function
    h!::Function
end
# Constructor for a once differentiable function 
Differentiable(f, g!, fg!) = Differentiable(f, g!, fg!, (x,s)->error("Not implemented") )
  • Specifying a differentiable function with autodiff options. The autodiff packages in Julia are coming along and I'd like the ability to do something along these lines:
f(x) = ... # my objective function
DifferentiableFunction(f, method=:autograd) # uses AutoGrad.jl
DifferentiableFunction(f, method=:forward) # uses ForwardDiff.jl
DifferentiableFunction(f, method=:central_diff) # uses finite central differencing

I'm not attached to using symbols - we could also dispatch on types if that is preferred.

@anriseth
Copy link
Contributor

Jest for reference, we also discussed some sort of unified solver API for relevant objective functions etc. in #282

@pkofod
Copy link
Member

pkofod commented Mar 13, 2017

Some was introduced in #337, storage will be closed in a new PR, and has a separate issue.

@pkofod pkofod closed this as completed Mar 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants