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 would like to use BayesNets.jl with Turing.jl to perform Bayesian parameter estimation. The primary requirement is that a library interacting with Turing is set up generically to support ForwardDiff.Dual types and Float64 in order to allow automatic differentiation to compute gradients. As shown below, I found that DiscreteCPD does not work because it is hardcoded to accept Float64. See this line.
A simple fix is to change that line to
const DiscreteCPD = CategoricalCPD
I tried adding constraints but it threw an error.
const DiscreteCPD = CategoricalCPD{Categorical{T,Vector{T}}} where {T<:Real}
I was wondering if you would be willing to change the line (I could also open a PR), and whether there are additional places that might need to be changed in the code.
Thanks!
MWE
using BayesNets, TikzGraphs
using ForwardDiff
c = ForwardDiff.Dual(.5,.4)
snc = ForwardDiff.Dual(.5,.4)
sc = ForwardDiff.Dual(.5,.4)
bn = BayesNet([DiscreteCPD(:c, [c,(1-c)])])
push!(bn,
DiscreteCPD(
:s, [:c], [2],
[Categorical([snc,(1-snc)]),
Categorical([sc,(1-sc)])]
),
)
Hello,
I would like to use BayesNets.jl with Turing.jl to perform Bayesian parameter estimation. The primary requirement is that a library interacting with Turing is set up generically to support
ForwardDiff.Dual
types andFloat64
in order to allow automatic differentiation to compute gradients. As shown below, I found thatDiscreteCPD
does not work because it is hardcoded to acceptFloat64
. See this line.A simple fix is to change that line to
const DiscreteCPD = CategoricalCPD
I tried adding constraints but it threw an error.
const DiscreteCPD = CategoricalCPD{Categorical{T,Vector{T}}} where {T<:Real}
I was wondering if you would be willing to change the line (I could also open a PR), and whether there are additional places that might need to be changed in the code.
Thanks!
MWE
Error
The text was updated successfully, but these errors were encountered: