-
Notifications
You must be signed in to change notification settings - Fork 1
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
Error with splice, only when using HMC #7
Comments
updating since inference.jl has been updated include("inference.jl") |
@mdb293 I'm not entirely sure whats going on here but I think the culprit is the type of Take a close look at the error:
It is saying that After taking a look at : https://github.com/mdb293/ORB_project3/blob/fdffd6e60c7d6f0d5ff4a440952b3a5fb3012d21/inference.jl#L43-L70 It seems that you might be passing the wrong array to # This just checks types and returns
function _sample_wo_repl(A::Vector{Integer}, n::Int)
(A, n)
end
@gen function sample_wo_repl(A,n)
A,n = _sample_wo_repl(A,n)
sample = Array{String}(undef,n)
for i in 1:n
#println("i is ", i)
idx = @trace(Gen.uniform_discrete(1, length(A_mutable)), (:idx, i))
#print("idx is ", idx)
sample[i] = splice!(A_mutable, idx)
#sample[i] = A_mutable[idx]
#deleteat!(A_mutable, idx)
#println("A_mutable is ", A_mutable)
end
#trying to reset A
#A = copy(A_immutable)
#want to rearrange so that the order of items in the sample matches the order of items that we're sampling from
sampleIdx = names_to_IDs(sample, A_immutable)
sorted = sort(sampleIdx)
ordered_sample = A_immutable[sorted]
return ordered_sample
end
|
I think the problem is the type of idx. When running metropolis_hastings, idx passes the type check and is an int. When running hm, it's of type ::ReverseDiff.TrackedReal{Int64,Int64,Nothing} |
ERROR: LoadError: MethodError: no method matching splice!(::Array{String,1}, ::ReverseDiff.TrackedReal{Int64,Int64,Nothing})
Closest candidates are:
splice!(::Array{T,1} where T, ::Integer) at array.jl:1311
splice!(::Array{T,1} where T, ::Integer, ::Any) at array.jl:1311
splice!(::Array{T,1} where T, ::UnitRange{#s75} where #s75<:Integer) at array.jl:1358
...
Stacktrace:
[1] ##sample_wo_repl#570(::Gen.GFBackpropTraceState, ::Array{String,1}, ::Int64) at /Users/marleneberke/Documents/03_Yale/Projects/001_Mask_RCNN/ORB_project3/inference.jl:54
[2] exec at /Users/marleneberke/.julia/packages/Gen/eQpFO/src/dynamic/dynamic.jl:39 [inlined]
[3] choice_gradients(::Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}, ::AllSelection, ::Nothing) at /Users/marleneberke/.julia/packages/Gen/eQpFO/src/dynamic/backprop.jl:376
[4] special_reverse_exec!(::ReverseDiff.SpecialInstruction{Gen.BackpropTraceRecord,Tuple{Array{String,1},Int64},Array{String,1},Nothing}) at /Users/marleneberke/.julia/packages/Gen/eQpFO/src/dynamic/backprop.jl:346
[5] reverse_exec!(::ReverseDiff.SpecialInstruction{Gen.BackpropTraceRecord,Tuple{Array{String,1},Int64},Array{String,1},Nothing}) at /Users/marleneberke/.julia/packages/ReverseDiff/qmgw8/src/tape.jl:93
[6] reverse_pass!(::Array{ReverseDiff.AbstractInstruction,1}) at /Users/marleneberke/.julia/packages/ReverseDiff/qmgw8/src/tape.jl:87
[7] reverse_pass! at /Users/marleneberke/.julia/packages/Gen/eQpFO/src/backprop.jl:12 [inlined]
[8] choice_gradients(::Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}, ::DynamicSelection, ::Nothing) at /Users/marleneberke/.julia/packages/Gen/eQpFO/src/dynamic/backprop.jl:396
[9] #hmc#167(::Float64, ::Int64, ::Float64, ::typeof(hmc), ::Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}, ::DynamicSelection) at /Users/marleneberke/.julia/packages/Gen/eQpFO/src/inference/hmc.jl:36
[10] hmc(::Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}, ::DynamicSelection) at /Users/marleneberke/.julia/packages/Gen/eQpFO/src/inference/hmc.jl:24
[11] block_resimulation_update(::Gen.DynamicDSLTrace{DynamicDSLFunction{Any}}) at /Users/marleneberke/Documents/03_Yale/Projects/001_Mask_RCNN/ORB_project3/inference.jl:265
[12] block_resimulation_inference(::Tuple{Array{String,1},Int64}, ::DynamicChoiceMap) at /Users/marleneberke/Documents/03_Yale/Projects/001_Mask_RCNN/ORB_project3/inference.jl:282
[13] top-level scope at /Users/marleneberke/Documents/03_Yale/Projects/001_Mask_RCNN/ORB_project3/inference.jl:290
[14] include at ./boot.jl:328 [inlined]
[15] include_relative(::Module, ::String) at ./loading.jl:1094
[16] include(::Module, ::String) at ./Base.jl:31
[17] include(::String) at ./client.jl:431
[18] top-level scope at REPL[243]:1
in expression starting at /Users/marleneberke/Documents/03_Yale/Projects/001_Mask_RCNN/ORB_project3/inference.jl:289
The text was updated successfully, but these errors were encountered: