Skip to content

Wrong result and non-reproducibility #13

Description

@VincentBt

I feel like there is a problem with indices somewhere. When running the code below where the pairwise potentials are non-informative, the marginals are wrong for a few nodes only (here 1).
For some reason this does not happen all the time though: running the code several times gives different results. I'm using Jupyter Notebook and I relaunch the kernel between each execution.

`import junctiontree.junctiontree as jt
import numpy as np

factors = [
['0'], ['1'], ['2'], ['3'], ['4'], ['5'], ['6'], ['7'], ['8'], ['9'],
['0', '2'], ['0', '3'], ['1', '4'], ['1', '5'], ['1', '6'], ['1', '7'], ['1', '9'], ['2', '5'], ['3', '6'], ['3', '8'], ['4', '6'], ['4', '7'], ['4', '9'], ['5', '6'], ['5', '7'], ['5', '9'], ['6', '8']
]

values = [
np.array([0.51863787, 0.48136213]), np.array([0.37818722, 0.62181278]), np.array([0.54252319, 0.45747681]), np.array([0.61971232, 0.38028768]), np.array([0.6027177, 0.3972823]), np.array([0.39505855, 0.60494145]), np.array([0.43202537, 0.56797463]), np.array([0.58615866, 0.41384134]), np.array([0.51366971, 0.48633029]), np.array([0.51068872, 0.48931128]),
np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, 0.5], [0.5, 0.5]])
]

var_sizes = {'0': 2, '1': 2, '2': 2, '3': 2, '4': 2, '5': 2, '6': 2, '7': 2, '8': 2, '9': 2}

tree = jt.create_junction_tree(factors, var_sizes)
prop_values = tree.propagate(values) #run the junction tree algorithm

marginals = prop_values[:len(var_sizes)] #unitary marginals
marginals = [el / np.sum(el) for el in marginals] #renormalization

for el1, el2 in zip(marginals, values[:len(var_sizes)]):
print(np.round(el1 - el2, 15))`

returns

[0. 0.] [0. 0.] [0. 0.] [0. 0.] [ 0. -0.] [-0.17562959 0.17562959] [0. 0.] [ 0. -0.] [0. 0.] [0. 0.]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions