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
Here is a little program that illustrates the problem:
using Turing, ReverseDiff, Memoization
using Statistics
using Random
Turing.setadbackend(:reversediff)
turing.setrdcache(true)
Turing.turnprogress(false)
using Distributions
for i in 1:10
N = 1000
d = Normal(0.0, i)
data=rand(d,N)
@model g(rn,T) = begin
sigma ~ Uniform(0.0,20.0)
rn ~ MvNormal(zeros(T),sigma)
end
chn = sample(g(data,N),NUTS(0.65),1000)
println("Std of chain: ",mean(Array(chn[:sigma])),"Std of data: ",std(data))
end
I am creating a dataset that samples from a Normal distributions and our model is estimating the sigma of the distribution. When you run the code you can see that the sampler samples only from the first dataset and therefore the estimated mean for sigma is always around 1. I tried to run Turing.emptyrdcache() after sampling but that did not solve the problem.
Here is my Project.toml:
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Memoization = "6fafb56a-5788-4b4e-91ca-c0cea6611c73"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"
Turing = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
The text was updated successfully, but these errors were encountered:
This issue is a bit weird. If emptying the cache is not helping then it is probably not emptying it properly. Maybe something changed with Memoization.jl. The second unusual thing here is that the same tape should be good enough for all the iterations and it should give the correct gradient. So I am suspecting something maybe wrong with ReverseDiff here.
Here is a little program that illustrates the problem:
I am creating a dataset that samples from a Normal distributions and our model is estimating the sigma of the distribution. When you run the code you can see that the sampler samples only from the first dataset and therefore the estimated mean for sigma is always around 1. I tried to run Turing.emptyrdcache() after sampling but that did not solve the problem.
Here is my Project.toml:
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Memoization = "6fafb56a-5788-4b4e-91ca-c0cea6611c73"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"
Turing = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
The text was updated successfully, but these errors were encountered: