Beispiel #1
0
def test_lincg_fletcher():
    rval = lincg.linear_cg_fletcher_reeves(lambda x: [T.dot(symb['L'], x)],
                                           [symb['g']],
                                           rtol=1e-20,
                                           damp=0.,
                                           maxiter=10000,
                                           floatX=floatX,
                                           profile=0)

    f = theano.function([symb['L'], symb['g']], rval[0])
    t1 = time.time()
    Linv_g = f(vals['L'], vals['g'])
    print 'test_lincg runtime (s):', time.time() - t1
    numpy.testing.assert_almost_equal(Linv_g, vals['Linv_g'], decimal=3)
Beispiel #2
0
def test_lincg_fletcher():
    rval = lincg.linear_cg_fletcher_reeves(
            lambda x: [T.dot(symb['L'], x)],
            [symb['g']],
            rtol=1e-20,
            damp = 0.,
            maxiter = 10000,
            floatX = floatX,
            profile=0)

    f = theano.function([symb['L'], symb['g']], rval[0])
    t1 = time.time()
    Linv_g = f(vals['L'], vals['g'])
    print 'test_lincg runtime (s):', time.time() - t1
    numpy.testing.assert_almost_equal(Linv_g, vals['Linv_g'], decimal=3)
Beispiel #3
0
def test_lincg_fletcher_xinit():
    symb['xinit'] = T.vector('xinit')
    vals['xinit'] = rng.rand(nparams).astype(floatX)

    rval = lincg.linear_cg_fletcher_reeves(lambda x: [T.dot(symb['L'], x)],
                                           [symb['g']],
                                           rtol=1e-20,
                                           damp=0.,
                                           maxiter=10000,
                                           floatX=floatX,
                                           xinit=[symb['xinit']],
                                           profile=0)

    f = theano.function([symb['L'], symb['g'], symb['xinit']], rval[0])
    t1 = time.time()
    Linv_g = f(vals['L'], vals['g'], vals['xinit'])
    print 'test_lincg runtime (s):', time.time() - t1
    numpy.testing.assert_almost_equal(Linv_g, vals['Linv_g'], decimal=3)
Beispiel #4
0
def test_lincg_fletcher_xinit():
    symb['xinit'] = T.vector('xinit')
    vals['xinit'] = rng.rand(nparams).astype(floatX)

    rval = lincg.linear_cg_fletcher_reeves(
            lambda x: [T.dot(symb['L'], x)],
            [symb['g']],
            rtol=1e-20,
            damp = 0.,
            maxiter = 10000,
            floatX = floatX,
            xinit = [symb['xinit']],
            profile=0)

    f = theano.function([symb['L'], symb['g'], symb['xinit']], rval[0])
    t1 = time.time()
    Linv_g = f(vals['L'], vals['g'], vals['xinit'])
    print 'test_lincg runtime (s):', time.time() - t1
    numpy.testing.assert_almost_equal(Linv_g, vals['Linv_g'], decimal=3)