view pylearn/gd/tests/test_dbd.py @ 1422:8c209c847087

adding delta-bar-delta optimization updates to gd module
author James Bergstra <bergstrj@iro.umontreal.ca>
date Fri, 04 Feb 2011 16:07:27 -0500
parents
children
line wrap: on
line source

import theano
from theano.compile.debugmode import DebugMode
from pylearn.gd import dbd

mode = theano.compile.mode.get_default_mode()
if isinstance(mode,DebugMode):
    mode = 'FAST_RUN'

def test_dbd_basic():

    x = theano.shared(5.0)
    y = theano.shared(3.0)

    cost = (1.0 - x * y)**2
    ups = dbd.dbd_updates([x,y], grads=None, stepsizes=[.01,.01],
            cost = cost)
    fn = theano.function([], cost, updates=ups)
    c_i = fn()
    assert c_i > 20
    for i in xrange(20):
        c_i = fn()
    assert c_i < 1.0e-10