Skip to content
This repository has been archived by the owner on May 12, 2019. It is now read-only.

error using reverse autodiff with a closure #152

Closed
tpapp opened this issue Jan 2, 2017 · 2 comments
Closed

error using reverse autodiff with a closure #152

tpapp opened this issue Jan 2, 2017 · 2 comments

Comments

@tpapp
Copy link

tpapp commented Jan 2, 2017

The following is a code snippet from a model. It works perfectly with autodiff=:forward, but fails with :reverse:

julia>  θ_raw = BasicContMuvParameter(:θ_raw,
                                      logtarget=θ_raw->
                                      structural_ll_raw(path_counts,
                                                        LMSimple1,
                                                        θ_raw),
                                      autodiff=:reverse)
ERROR: BoundsError: attempt to access 0-element Array{Any,1} at index [1]
 in getindex(::Array{Any,1}, ::Int64) at ./array.jl:386
 in #BasicContMuvParameter#113(::Void, ::Void, ::Void, ::Void, ::Void, ::Void, ::##
4#5, ::Void, ::Void, ::Void, ::Void, ::Void, ::Void, ::Void, ::Void, ::Void, ::Void
, ::Void, ::Void, ::Array{Klara.VariableState,1}, ::Int64, ::Bool, ::Symbol, ::Int6
4, ::Int64, ::Array{Array{Any,1},1}, ::Type{T}, ::Symbol, ::Type{Val{:high}}, ::Int
64) at /home/tamas/.julia/v0.5/Klara/src/variables/parameters/BasicContMuvParameter
.jl:543                                                                           
 in (::Core.#kw#Type)(::Array{Any,1}, ::Type{BasicContMuvParameter}, ::Symbol, ::Ty
pe{Val{:high}}, ::Int64) at ./<missing>:0                                         
 in #BasicContMuvParameter#111(::Symbol, ::Array{Any,1}, ::Type{T}, ::Symbol, ::Int
64) at /home/tamas/.julia/v0.5/Klara/src/variables/parameters/BasicContMuvParameter
.jl:296                                                                           
 in (::Core.#kw#Type)(::Array{Any,1}, ::Type{BasicContMuvParameter}, ::Symbol, ::In
t64) at ./<missing>:0 (repeats 2 times)                                           

The function structural_ll_raw simply computes the log likelihood. I am wondering I am running into something obvious, ie that it is a closure?

Though my actual code is long, if the issue is not obvious I will make a self-contained example (just let me know).

@papamarkou
Copy link
Contributor

papamarkou commented Jan 2, 2017

Thanks @tpapp, yes, I am aware of this issue, and have opened a relevant issue at ReverseDiffSource a couple of months ago, see JuliaAttic/ReverseDiffSource.jl#49 - it used to work with the previous version of ReverseDiffSource, @fredo-dedup offered to sort this out from his end, when he finds the chance.

@papamarkou
Copy link
Contributor

This has been sorted via DiffBase and ReverseDiff.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants