changeset 1494:0e6ca7eecc72

Fix for python 2.4 compatibility
author Olivier Delalleau <delallea@iro>
date Wed, 17 Aug 2011 10:18:39 -0400
parents 8be8cdde97ee
children 625fe86e3d5e
files pylearn/gd/sgd.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/gd/sgd.py	Wed Jul 27 13:27:00 2011 -0400
+++ b/pylearn/gd/sgd.py	Wed Aug 17 10:18:39 2011 -0400
@@ -79,7 +79,10 @@
             raise TypeError('stepsize must be a scalar', stepsize)
 
         self.params = params
-        self.gparams = [theano.tensor.grad(cost, self.params)] if gradients is None else gradients
+        if gradients is None:
+            self.gparams = [theano.tensor.grad(cost, self.params)]
+        else:
+            self.gparams = gradients
         assert len(self.params) == len(self.gparams)
 
         self._updates = (dict((p, p - self.stepsize * g) for p, g in zip(self.params, self.gparams)))