fglib icon indicating copy to clipboard operation
fglib copied to clipboard

Error in example of sum product

Open qillbel opened this issue 6 years ago • 1 comments

Dear Author,

I got this error after installing this package. Can you tell me what I need to do?

`TypeError Traceback (most recent call last) in () 39 # Perform sum-product algorithm on factor graph 40 # and request belief of variable node x4 ---> 41 belief = inference.sum_product(fg, x4) 42 43 # Print belief of variables

~\Downloads\BitBucket\python\FGlib\fglib\inference.py in sum_product(graph, query_node) 61 62 # Sum-Product algorithm is equivalent to Belief Propagation ---> 63 return belief_propagation(graph, query_node) 64 65

~\Downloads\BitBucket\python\FGlib\fglib\inference.py in belief_propagation(graph, query_node) 49 50 # Return marginal distribution ---> 51 return query_node.belief() 52 53

~\Downloads\BitBucket\python\FGlib\fglib\nodes.py in belief(self, normalize) 132 133 # Pick first node --> 134 n = next(iterator) 135 136 # Product over all incoming messages

TypeError: 'list' object is not an iterator`

qillbel avatar Aug 08 '18 16:08 qillbel

I tried a fresh install with

$ pip install fglib

and got the following output

$ python3 example_spa
Belief of variable node x4:
[0.49090909 0.50909091]
Belief of variable node x3:
[0.49090909 0.50909091]
Belief of variable node x2:
[0.89090909 0.10909091]
Unnormalized belief of variable node x1:
[0.183 0.147]

Could you provide the output of $ python --version and $ pip list?

danbar avatar Aug 10 '18 18:08 danbar