Beispiel #1
0
def test_graph_crf_inference():
    # create two samples with different graphs
    # two states only, pairwise smoothing
    for inference_method in get_installed(['qpbo', 'lp', 'ad3', 'dai', 'ogm']):
        crf = GraphCRF(n_states=2, n_features=2,
                       inference_method=inference_method)
        assert_array_equal(crf.inference((x_1, g_1), w), y_1)
        assert_array_equal(crf.inference((x_2, g_2), w), y_2)

    print crf._get_pairwise_potentials((x_1, g_1), w)
Beispiel #2
0
def test_graph_crf_inference():
    # create two samples with different graphs
    # two states only, pairwise smoothing
    for inference_method in get_installed(['qpbo', 'lp', 'ad3', 'dai', 'ogm']):
        crf = GraphCRF(n_states=2, n_features=2,
                       inference_method=inference_method)
        assert_array_equal(crf.inference((x_1, g_1), w), y_1)
        assert_array_equal(crf.inference((x_2, g_2), w), y_2)

    print crf._get_pairwise_potentials((x_1, g_1), w)
Beispiel #3
0
def test_directed_graph_crf_inference():
    # create two samples with different graphs
    # two states only, pairwise smoothing
    # same as above, only with full symmetric matrix
    for inference_method in get_installed(['qpbo', 'lp', 'ad3', 'dai', 'ogm']):
        crf = GraphCRF(n_states=2, n_features=2,
                       inference_method=inference_method, directed=True)
        assert_array_equal(crf.inference((x_1, g_1), w_sym), y_1)
        assert_array_equal(crf.inference((x_2, g_2), w_sym), y_2)

    print crf._get_pairwise_potentials((x_1, g_1), w_sym)
Beispiel #4
0
def test_directed_graph_crf_inference():
    # create two samples with different graphs
    # two states only, pairwise smoothing
    # same as above, only with full symmetric matrix
    for inference_method in get_installed(['qpbo', 'lp', 'ad3', 'dai', 'ogm']):
        crf = GraphCRF(n_states=2, n_features=2,
                       inference_method=inference_method, directed=True)
        assert_array_equal(crf.inference((x_1, g_1), w_sym), y_1)
        assert_array_equal(crf.inference((x_2, g_2), w_sym), y_2)

    print crf._get_pairwise_potentials((x_1, g_1), w_sym)