Comments (15)
try nu = zeros(eltype(para), point)
. For AD to work, the code need to take generic input types. zeros
without an explicit types defaults to using Float64
.
from forwarddiff.jl.
Thanks for your quick answer, it works!
Because I am a Matlab user and new to Julia, not quite understand the subtle difference. I command zeros(point)
and thenu = zeros(eltype(para), point)
, and found they are all Float64
type. I found myself always confused with Julia type, even in simple case. :(
from forwarddiff.jl.
Behind the scenes, ForwardDiff will provide a vector of a different type (not Float64) to compute the derivatives.
from forwarddiff.jl.
Hi mlubin,
But it didn't work when using forwarddiff_hessian
...
Error is
`hessian` has no method matching hessian(::Array{FADHessian{Float64,6},1})
in g at C:\Users\genwei\.julia\v0.3\ForwardDiff\src\typed_fad\FADHessian.jl:406
from forwarddiff.jl.
I'm not too familiar with this code, I'll let @scidom comment on this.
from forwarddiff.jl.
@mlubin, @genwei007 I am on an island without laptop (on holidays), I will leave this issue open and will comment on it upon my return.
from forwarddiff.jl.
Any updates? I am running into similar problems.
from forwarddiff.jl.
@marcusps, also with forwarddiff_hessian
?
from forwarddiff.jl.
Hi @marcusps, still haven't managed to find a bit of time to look into this, hopefully will get it off my todo list soon.
from forwarddiff.jl.
Not with the Hessian, but with a gradient, @mlubin. I'll try to get a minimal test case written tomorrow.
from forwarddiff.jl.
Hi mlubin and scidom,
Just wonder if other packages like ReverseDiffSource or DualNumbers can work for my previous syntax?
Thanks.
from forwarddiff.jl.
DualNumbers can be used for Jacobians but not Hessians. ReverseDiffSource could possibly work.
from forwarddiff.jl.
This is issue has been resolved after doing what @mlubin suggested. Sorry that it took months before I sat down to check it out. The problem was exactly that the routines of ForwardDiff don't work with generic input times, so when you defined zeros
you have to explicitly tell what type of elements the resulting nu
vector will hold. I will close this issue now. For the sake of completeness, here is the operational code for your example in Julia 0.4:
using ForwardDiff
point = 2 # can be used within function
y = [0:(point - 1);]
function GPCM(para)
a = para[1]
d = para[2]
tau = para[3:4]
t = para[5]
nu = zeros(eltype(para), point)
for k = 1:point
nu[k] = exp(a.*(y[k].*(t-d) - sum(tau[1:k]) )) [1]
end
de = sum(nu)
p = nu ./ de
end
para = [1.,0.,0.,0.,1.]
Jac = forwarddiff_jacobian(GPCM, Float64, fadtype=:typed)
Jac(para)
from forwarddiff.jl.
Hi scidom,
How about 'forwarddiff_hessian' which is not applicable in the present case... Still got errors. Thanks.
from forwarddiff.jl.
Hi @genwei007, let me check this and will let you now if there is an obvious fix.
from forwarddiff.jl.
Related Issues (20)
- AD in-place instead of broadcast HOT 1
- Is the mutating code the problem here? How could I debug this? HOT 2
- Rationals and Modulo
- `NaNMath` (and `SpecialFunctions`) as extensions? HOT 5
- Broken external link
- `construct_seeds` for types where `typeof(one(T)) !=T` is broken HOT 1
- incorrect 2nd derivative of complex exponential HOT 2
- Can you take derivative of complicated function whose symbolic form is not explicit or not known?
- Cancellation with sparse arrays HOT 5
- Implement hessian! for scalar x
- Implement gammalogccdf for ForwardDiff HOT 1
- `ForwardDiff.jacobian` throws error for `fft` HOT 1
- Correctly forming nested dual numbers. HOT 8
- Derivative of a function of derivatives HOT 7
- Symbolics.jl compatibility HOT 1
- Support derivative(f, ::Complex)
- `ForwardDiff` fails to compute correct derivative HOT 3
- Incorrect Hessian by `exp` function HOT 1
- Method ambiguities reported by Aqua HOT 3
- Document internals? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from forwarddiff.jl.