Numerical instabilities in sum-product belief propagation?

35 views
Skip to first unread message

Lars Mescheder

unread,
Sep 16, 2016, 5:00:03 AM9/16/16
to opengm
Hi,
First, thanks for all the hard work you put into making opengm. It's a great library that is easy to use.

However, sometimes, sum-product belief propagation gives me marginals that do not sum to one:
import opengm
import numpy as np

def infer_bp(potv, potf, indv):
    N
= potv.shape[0]
    F
= potf.shape[0]
   
    gm
= opengm.gm([2] * N, 'multiplier')
   
    fids
= gm.addFunctions(potv)
    gm
.addFactors(fids, np.arange(N))
    fids
= gm.addFunctions(potf)
    gm
.addFactors(fids, indv)
   
    bp
= opengm.inference.BeliefPropagation(gm, 'integrator')
    res
= bp.infer()
   
print res
   
    margv
= bp.marginals(np.arange(N))
    margf
= bp.factorMarginals(np.arange(N, N+F))

   
return margv, margf

N
= 100
F
= N - 1
potv
= np.zeros((N, 2), dtype=np.float64)
potf
= np.zeros((F, 2, 2), dtype=np.float64)
indv
= np.zeros((F, 2), dtype=np.int32)

potv
[:, :] = np.array([1e2, 1e0])
potf
[:, :] = np.array([[1e0, 1e2], [1e0, 1e-2]])
indv
[:, 0] = 0
indv
[:, 1] = np.arange(1, F+1)

margv
, margf = infer_bp(potv, potf, indv)

print margv[:10]

results in
NORMAL
[[  3.64091745e-18   5.80150354e-50]
 
[  5.40748338e-18   5.40748338e-18]
 
[  5.40748338e-18   5.40748338e-18]
 
[  5.40748338e-18   5.40748338e-18]
 
[  5.40748338e-18   5.40748338e-18]
 
[  5.40748338e-18   5.40748338e-18]
 
[  5.40748338e-18   5.40748338e-18]
 
[  5.40748338e-18   5.40748338e-18]
 
[  5.40748338e-18   5.40748338e-18]
 
[  5.40748338e-18   5.40748338e-18]]

Of course, this is an artificial example, but a similar case arises in my research code. Note that for N=10 there are no issues (marginals sum to 1). Any suggestions?


Reply all
Reply to author
Forward
0 new messages