コード例 #1
0
ファイル: test_latent_crf.py プロジェクト: hushell/pystruct
def test_k_means_initialization_graph_crf():
    # with only 1 state per label, nothing happends
    X, Y = toy.generate_big_checker(n_samples=10)
    crf = LatentGraphCRF(n_labels=2, n_states_per_label=1, inference_method="lp")
    # convert grid model to graph model
    X = [(x.reshape(-1, x.shape[-1]), make_grid_edges(x, return_lists=False)) for x in X]

    H = crf.init_latent(X, Y)
    assert_array_equal(Y, H)
コード例 #2
0
def test_k_means_initialization_graph_crf():
    # with only 1 state per label, nothing happends
    X, Y = generate_big_checker(n_samples=10)
    crf = LatentGraphCRF(n_states_per_label=1, n_features=2, n_labels=2)
    # convert grid model to graph model
    X = [(x.reshape(-1, x.shape[-1]), make_grid_edges(x, return_lists=False))
         for x in X]

    H = crf.init_latent(X, Y)
    assert_array_equal(Y, H)