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 am getting the following error while sampling by using reverse differentiation AD backend.
ERROR: MethodError: vcat(::ReverseDiff.TrackedArray{Float64,Float64,1,Array{Float64,1},Array{Float64,1}}, ::Array{Float64,1}, ::ReverseDiff.TrackedArray{Float64,Float64,1,Array{Float64,1},Array{Float64,1}}) is ambiguous. Candidates:
vcat(611::ReverseDiff.TrackedArray, 612::AbstractArray, x::Union{ReverseDiff.TrackedArray, ReverseDiff.TrackedReal}, xs::Union{Number, AbstractArray}...) in DistributionsAD.ReverseDiffX at C:\Users\manoos\.julia\packages\DistributionsAD\xJ5bm\src\reversediffx.jl:43
vcat(V::AbstractArray{T,1} where T...) in Base at abstractarray.jl:1287
vcat(x::Union{ReverseDiff.TrackedArray, ReverseDiff.TrackedReal}, xs::Union{Number, AbstractArray}...) in DistributionsAD.ReverseDiffX at C:\Users\manoos\.julia\packages\DistributionsAD\xJ5bm\src\reversediffx.jl:43
vcat(A::Union{AbstractArray{T,2}, AbstractArray{T,1}} where T...) in Base at abstractarray.jl:1350
vcat(609::AbstractArray, 610::AbstractArray, x::Union{ReverseDiff.TrackedArray, ReverseDiff.TrackedReal}, xs::Union{Number, AbstractArray}...) in DistributionsAD.ReverseDiffX at C:\Users\manoos\.julia\packages\DistributionsAD\xJ5bm\src\reversediffx.jl:43
vcat(A::Union{LinearAlgebra.UniformScaling, Union{AbstractArray{T,2}, AbstractArray{T,1}} where T}...) in LinearAlgebra at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\LinearAlgebra\src\uniformscaling.jl:310
Possible fix, define
vcat(::ReverseDiff.TrackedArray{V,D,1,VA,DA} where DA where VA where D where V, ::AbstractArray{T,1} where T, ::ReverseDiff.TrackedArray{V,D,1,VA,DA} where DA where VA where D where V, ::Vararg{AbstractArray{T,1} where T,N} where N)
The MWE for the above issue is as below:
using Turing
using DistributionsAD
using LazyArrays
using ReverseDiff
dist_f(a,b) = sqrt(sum((a .- b).^2))
function mean_y(a,b,r)
y_m = map(dist_f,a,b)
y_c = y_m.*r
return y_c
end
function extract_cords(a)
(i,j,k) = map(x->getindex.(a, x), 1:3)
return vec(i), vec(j), vec(k)
end
@model test_samp(y, a, b, x, y1, z,::Type{T}=Float64) where {T} = begin
mn = length(x)
r_dis ~ filldist(Uniform(0.1, 1.0), 4)
x_rnd ~ MvNormal(x,fill(0.1,mn))
# y_rnd ~ MvNormal(vec(a_rn[2,:]),fill(0.1,mn))
z_rnd ~ MvNormal(z,fill(0.1,mn))
# a_rnd = vcat(vcat(x_rnd, y1), z_rnd)
a_rnd = vcat(x_rnd, y1,z_rnd)
mean_arnd = reshape(a_rnd, (3,mn))
resha_mean_arnd = reshape([(mean_arnd[1,i], mean_arnd[2,i], mean_arnd[3,i]) for i in 1:size(mean_arnd, 2)], size(a))
mean_proj_img = mean_y(resha_mean_arnd, b, reshape(r_dis,(2,2)))
dists = DistributionsAD.lazyarray(Normal, copy(mean_proj_img), 0.1)
y ~ arraydist(dists)
end
r = rand(Float64,2,2);
a = fill((1.0, 2.0, 0.2), 2, 2)
b = fill((0.0, 0.1, 0.6), 2, 2)
(x,y,z) = extract_cords(a)
out = rand(size(a,1),size(a,2))
model = test_samp(out, a, b, x, y, z)
Turing.setadbackend(:reversediff)
chain = sample(model, NUTS(0.65), 100)
Regards,
Manu
The text was updated successfully, but these errors were encountered:
Hi,
In my model, I am trying to vector concatenate arrays like below:
The MWE for the above issue is as below:
Regards,
Manu
The text was updated successfully, but these errors were encountered: