Description
Based on question/conversation on slack (with @devmotion, @mohamed82008):
A bit of a different take on TuringLang/DynamicPPL.jl#94
I would like to specify which variables are tracked by Turing. In the above issue I believe users are trying to track additional variables (which are transforms of others), but sometimes I also want to specify that I do not want to track a specific variable (in my example below for example n
might be very large, and I don't want to track all of theta
).
@model function tpl(y, n, m, ::Type{TV}=Vector{Float64}) where {TV}
a = TV.(undef, m)
b = TV.(undef, m)
for i in 1:m
a[i] ~ LogNormal(0.0, 0.5)
b[i] ~ Normal(0.0, 3.0)
end
theta = TV(undef, n)
for p in 1:n
theta[p] ~ Normal(0,1)
for i in 1:m
prob = invlogit(a[i] * (theta[p] - b[i]))
y[i,p] ~ Bernoulli(prob)
end
end
return a, b
end;
Users in the slack have suggested using the variables returned in the model macro (a
and b
in my example) as the variables which are tracked. I think this is a great solution (and intuitively this is what I thought the return would do when I first read through the tutorial.