# HG changeset patch # User Olivier Delalleau # Date 1313590719 14400 # Node ID 0e6ca7eecc72b713e5a1b045212fd8db9dab2aad # Parent 8be8cdde97ee4199ae119ec8bfa2f984ccfbf0b8 Fix for python 2.4 compatibility diff -r 8be8cdde97ee -r 0e6ca7eecc72 pylearn/gd/sgd.py --- 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)))