diff 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 diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pylearn/gd/tests/test_dbd.py	Fri Feb 04 16:07:27 2011 -0500
@@ -0,0 +1,23 @@
+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
+