comparison 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
comparison
equal deleted inserted replaced
1421:3dee72c3055d 1422:8c209c847087
1 import theano
2 from theano.compile.debugmode import DebugMode
3 from pylearn.gd import dbd
4
5 mode = theano.compile.mode.get_default_mode()
6 if isinstance(mode,DebugMode):
7 mode = 'FAST_RUN'
8
9 def test_dbd_basic():
10
11 x = theano.shared(5.0)
12 y = theano.shared(3.0)
13
14 cost = (1.0 - x * y)**2
15 ups = dbd.dbd_updates([x,y], grads=None, stepsizes=[.01,.01],
16 cost = cost)
17 fn = theano.function([], cost, updates=ups)
18 c_i = fn()
19 assert c_i > 20
20 for i in xrange(20):
21 c_i = fn()
22 assert c_i < 1.0e-10
23