def test_latent_consistency_graph(): crf = LatentGraphCRF(n_labels=2, n_features=2, n_states_per_label=2) for i in range(10): w = np.random.normal(size=18) y = np.random.randint(2, size=(4)) x = np.random.normal(size=(4, 2)) e = np.array([[0, 1], [1, 2], [2, 0]], dtype=np.int) h = crf.latent((x, e), y, w) assert_array_equal(h // 2, y)
def test_latent_consistency_graph(): crf = LatentGraphCRF(n_labels=2, n_features=2, n_states_per_label=2) for i in xrange(10): w = np.random.normal(size=18) y = np.random.randint(2, size=(4)) x = np.random.normal(size=(4, 2)) e = np.array([[0, 1], [1, 2], [2, 0]], dtype=np.int) h = crf.latent((x, e), y, w) assert_array_equal(h / 2, y)
def test_latent_consistency_zero_pw_graph(): crf = LatentGraphCRF(n_labels=2, n_features=2, n_states_per_label=2) for i in range(10): w = np.zeros(18) w[:8] = np.random.normal(size=8) y = np.random.randint(2, size=(5)) x = np.random.normal(size=(5, 2)) h = crf.latent((x, np.zeros((0, 2), dtype=np.int)), y, w) assert_array_equal(h // 2, y)
def test_latent_consistency_zero_pw_graph(): crf = LatentGraphCRF(n_labels=2, n_features=2, n_states_per_label=2) for i in xrange(10): w = np.zeros(18) w[:8] = np.random.normal(size=8) y = np.random.randint(2, size=(5)) x = np.random.normal(size=(5, 2)) h = crf.latent((x, np.zeros((0, 2), dtype=np.int)), y, w) assert_array_equal(h / 2, y)