def test_compare(): from vsm import corpus n = 4 c = corpus.random_corpus(1e3, 20, 1, 10, tok_name='sentences') c = c.to_maskedcorpus() c.mask_terms(['0']) em = be.BeagleEnvironment() em.train(c, n_columns=n) env_matrix = em.matrix psi = rand_pt_unit_sphere(n) rand_perm = two_rand_perm(n) print 'Training single processor model' sm = BeagleOrderSingle() sm.train(c, psi=psi, env_matrix=env_matrix, rand_perm=rand_perm) print 'Training multiprocessor model' mm = BeagleOrderMulti() mm.train(c, psi=psi, env_matrix=env_matrix, rand_perm=rand_perm) assert np.allclose(sm.matrix, mm.matrix, atol=1e-07)
def test_compare(): from vsm import corpus n = 4 c = corpus.random_corpus(1e3, 20, 1, 10, tok_name='sentences') em = be.BeagleEnvironment() em.train(c, n_columns=n) env_matrix = em.matrix print 'Training single processor model' sm = BeagleContextSingle() sm.train(c, env_matrix=env_matrix) print 'Training multiprocessor model' mm = BeagleContextMulti() mm.train(c, env_matrix=env_matrix) assert np.allclose(sm.matrix, mm.matrix, atol=1e-07), (sm.matrix[:2], mm.matrix[:2])
def test_BeagleComposite(): from vsm import corpus n = 256 c = corpus.random_corpus(1e5, 1e2, 1, 10, tok_name='sentences') m = BeagleComposite() m.train(c, n_columns=n) return m
def test_BeagleOrderSingle(): from vsm import corpus n = 5 c = corpus.random_corpus(1e2, 10, 1, 10, tok_name='sentences') c = c.to_maskedcorpus() c.mask_terms(['0']) m = BeagleOrderSingle() m.train(c, n_columns=n) return c, m.matrix
def test_BeagleContextSingle(): from vsm import corpus n = 5 c = corpus.random_corpus(1e5, 1e4, 1, 20, tok_name='sentences') c = c.to_maskedcorpus() c.mask_terms(['0']) m = BeagleContextSingle() m.train(c, n_columns=n) return m.matrix
def test_BeagleOrderMulti(): from vsm import corpus n = 5 print 'Generating corpus' c = corpus.random_corpus(1e2, 10, 1, 10, tok_name='sentences') c = c.to_maskedcorpus() c.mask_terms(['0']) m = BeagleOrderMulti() m.train(c, n_columns=n) return m.matrix