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
@gen (grad) function kernel(t::Int, (grad)(a::Real))
z ~ normal(a, 1)
return z
end
chain = Gen.Unfold(kernel)
T = 3
trace = Gen.simulate(chain, (T, 0.))
choice_gradients(trace, select(T => :z))
But if I change the annotation to (static, grad), all of a sudden gradients for the last timestep don't work anymore (strangely the gradients work fine for every timestep before that), and I get the following error:
MethodError: no method matching +(::Float64, ::Nothing)
Closest candidates are:
+(::Any, ::Any, ::Any, ::Any...) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/base/operators.jl:655
+(::Union{Float16, Float32, Float64}, ::BigFloat) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/base/mpfr.jl:413
+(::AbstractFloat, ::Bool) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/base/bool.jl:172
...
Stacktrace:
[1] macro expansion
@ ~/.julia/packages/Gen/Dne3u/src/static_ir/backprop.jl:502 [inlined]
[2] choice_gradients(trace::var"##StaticIRTrace_kernel#1797", selection::StaticSelection{(:z,), Tuple{AllSelection}}, retval_grad::Nothing)
@ Main ~/.julia/packages/Gen/Dne3u/src/static_ir/backprop.jl:502
[3] macro expansion
@ ~/.julia/packages/Gen/Dne3u/src/static_ir/backprop.jl:396 [inlined]
[4] choice_gradients(trace::var"##StaticIRTrace_kernel#1797", selection::DynamicSelection, retval_grad::Nothing)
@ Main ~/.julia/packages/Gen/Dne3u/src/static_ir/backprop.jl:502
[5] choice_gradients(trace::Gen.VectorTrace{Gen.UnfoldType, Float64, var"##StaticIRTrace_kernel#1797"}, selection::DynamicSelection, retval_grad::Nothing)
@ Gen ~/.julia/packages/Gen/Dne3u/src/modeling_library/unfold/backprop.jl:39
[6] choice_gradients(trace::Gen.VectorTrace{Gen.UnfoldType, Float64, var"##StaticIRTrace_kernel#1797"}, selection::DynamicSelection)
@ Gen ~/.julia/packages/Gen/Dne3u/src/gen_fn_interface.jl:405
[7] top-level scope
@ In[482]:13
[8] eval
@ ./boot.jl:373 [inlined]
[9] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1196
Not sure why this happens---any thoughts?
The text was updated successfully, but these errors were encountered:
The following works fine:
But if I change the annotation to (static, grad), all of a sudden gradients for the last timestep don't work anymore (strangely the gradients work fine for every timestep before that), and I get the following error:
Not sure why this happens---any thoughts?
The text was updated successfully, but these errors were encountered: