You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a problem, which has a system of equations. I would like to get partial derivates of the whole system.
julia>using ForwardDiff
julia>f1(s) = (s/3)^2
f1 (generic function with 1 method)
julia>f2(s, l) = s^2+exp(3*l/sqrt(4))
f2 (generic function with 1 method)
julia>functionf(x)
returnf1(x[1]) +f2(x[1], x[2])
end
f (generic function with 1 method)
julia> g =forwarddiff_gradient(f, Float64)
g (generic function with 1 method)
julia>g([0.1, 56.2])
ERROR: BoundsError: attempt to access 1-element Array{DualNumbers.Dual{Float64},
1}:0.1+0.0du
at index [2]
in dual_fad at C:\Users\ovax03\.julia\v0.4\ForwardDiff\src\dual_fad\univariate_
range.jl:6in g at C:\Users\ovax03\.julia\v0.4\ForwardDiff\src\dual_fad\univariate_range.j
l:22
Is there an error in my code or should I make a macro, which would derivate all the terms?
The text was updated successfully, but these errors were encountered:
That does indeed look like a bug on our end, thanks for filing!
This package is undergoing a huge refactor at the moment, explained in this comment here. This bug will be fixed once #27 is merged (hopefully within the next 2 weeks). Here's some example code, working directly from the nduals-refactor branch:
julia>using ForwardDiff
julia>f1(s) = (s/3)^2
f1 (generic function with 1 method)
julia>f2(s, l) = s^2+exp(3*l/sqrt(4))
f2 (generic function with 1 method)
julia>functionf(x)
returnf1(x[1]) +f2(x[1], x[2])
end
f (generic function with 1 method)
julia> g =gradient_func(f, Partials{2,Float64}, mutates=false)
gradf (generic function with 1 method)
julia>g([0.1, 56.2])
2-element Array{Float64,1}:0.2222226.12514e36
In the meantime, you could try changing this line in the code you posted:
julia> g =forwarddiff_gradient(f, Float64)
to this:
julia> g =forwarddiff_gradient(f, Float64, fadtype=:typed, n=2)
Hi,
I'm working on a problem, which has a system of equations. I would like to get partial derivates of the whole system.
Is there an error in my code or should I make a macro, which would derivate all the terms?
The text was updated successfully, but these errors were encountered: