示例#1
0
def benchmark_pca(ctx, timer):
    DIM = (1280, 512)
    data = np.random.randn(*DIM)
    A = expr.from_numpy(data)
    #A = expr.randn(*DIM, dtype=np.float64)
    t1 = datetime.now()
    m = PCA(N_COMPONENTS)
    m.fit(A)
    t2 = datetime.now()
    cost_time = millis(t1, t2)

    print "total cost time:%s ms" % (cost_time)
示例#2
0
    def test_pca(self):
        FLAGS.opt_parakeet_gen = 0
        data = np.random.randn(*DIM)
        A = expr.from_numpy(data, tile_hint=util.calc_tile_hint(DIM, axis=0))

        m = PCA(N_COMPONENTS)
        m2 = SK_PCA(N_COMPONENTS)

        m.fit(A)
        m2.fit(data)
        print m2.components_ - m.components_
        assert np.allclose(absolute(m.components_), absolute(m2.components_))