We were getting not-deterministic errors from the inference algorithm
example script in Python 3. I believe these were due to the following
code in calc_marginals_sumproduct, where G is a graph:
for node in G.nodes():
potential = multiply_potentials(*[messages[(src,node)] for src in G.neighbors(node)])
marginals[node] = normalize(potential)
return marginals, potential.sum()
This code is iterating over the elements of an underlying dictionary
(G.nodes()), so potential.sum() at the end returns some value
effectively randomly chosen from all the nodes in the dictionary. I
think that we actually want:
for node in G.nodes():
potential = multiply_potentials(*[messages[(src,node)] for src in G.neighbors(node)])
marginals[node] = normalize(potential)
potentials[node] = potential
return marginals, potentials[target_node].sum()
We were getting not-deterministic errors from the inference algorithm example script in Python 3. I believe these were due to the following code in
calc_marginals_sumproduct
, whereG
is a graph:This code is iterating over the elements of an underlying dictionary (
G.nodes()
), sopotential.sum()
at the end returns some value effectively randomly chosen from all the nodes in the dictionary. I think that we actually want:where
target_node = 'burglary'
.