Open studentbrad opened 4 years ago
In the docstring for inference.sum_product it says that the algorithm only works for tree graphs. The algorithm for non-trees is different - try inference.loopy_belief_propagation
. However be warned that this algorithm is non-exact, all message-passing algorithms on a loopy graph are non exact!
Thanks for the response.
I tried inference.loopy_belief_propagation
. However, I've run into another error.
Is model
what I think it is? An arbitrary structured graph?
# Perform loopy-belief propagation on factor graph
# and request belief of variable node x3
belief = inference.loopy_belief_propagation(fg, 10, (x3,))
The terminal output is shown below.
Traceback (most recent call last):
File "fglib_example.py", line 39, in <module>
belief = inference.loopy_belief_propagation(fg, 10, (x3,))
File "/home/bradley/.local/lib/python3.6/site-packages/fglib/inference.py", line 165, in loopy_belief_propagation
return _schedule(model, 'spa', iterations, query_node, order)
File "/home/bradley/.local/lib/python3.6/site-packages/fglib/inference.py", line 205, in _schedule
b[n].append(n.belief(model))
File "/home/bradley/.local/lib/python3.6/site-packages/fglib/nodes.py", line 140, in belief
belief *= self.graph[n][self]['object'].get_message(n, self)
TypeError: unsupported operand type(s) for *=: 'NoneType' and 'NoneType'
@studentbrad did you ever resolve this? I have the same issue for loopy graph when trying to compute marginals
@goodyguts, for my loopy graph I tried:
score_node_list = [n for (n, attr) in M.nodes(data=True) if attr["type"] == "vn"]
belief = fg_lib.inference.loopy_belief_propagation(M,iterations=100, query_node = score_node_list)
and runs without error, but no marginals. Can you comment please thx!
@mercicle, I wasn't able to get this implementation of loopy belief propagation working. Of course I appreciate the authors work, but there are other tools for doing the same loopy belief on a structured graph.
@mercicle, I wasn't able to get this implementation of loopy belief propagation working. Of course I appreciate the authors work, but there are other tools for doing the same loopy belief on a structured graph
Could you please let us know what tool you finally used for the loopy BP? Thanks!
It looks like inference is not working for non-tree structures. For example consider the following simple factor graph with nodes x1, x2, x3 and factors fa, fb, fc.
The terminal output is shown below.