Esempio n. 1
0
def test_spn_construction_by_add_and_evaluation():
    spn = Spn()

    # building the same levels
    input_layer = build_spn_indicator_layer(vars)
    sum_layer, prod_layer = build_spn_layers(input_layer)

    # adding all layers to the spn
    spn.set_input_layer(input_layer)
    spn.add_layer(sum_layer)
    spn.add_layer(prod_layer)

    res = spn.eval(I)
    print('First evaluation')
    print(res)
    assert_log_array_almost_equal(root_vals, res)
Esempio n. 2
0
def test_spn_construction_by_add_and_evaluation_II():
    spn = Spn()

    # print('empty spn')
    # print(spn)

    input_layer = build_spn_smoothed_layer(vars, dicts, alpha)
    prod_layer = build_spn_layers_II(input_layer)

    # adding all layers to the spn
    spn.set_input_layer(input_layer)
    spn.add_layer(prod_layer)

    # print('created spn')
    # print(spn)

    res = spn.eval(I)
    print('First smoothed evaluation')
    print(res)
    assert_log_array_almost_equal(root_vals, res)