# HG changeset patch # User James Bergstra # Date 1224869280 14400 # Node ID 8ff412852d667d3916e5c1439705606cf1884633 # Parent 11e0357f06f41d37bac416a44238eaa841df8768 added sgd diff -r 11e0357f06f4 -r 8ff412852d66 algorithms/sgd.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/algorithms/sgd.py Fri Oct 24 13:28:00 2008 -0400 @@ -0,0 +1,13 @@ + +from theano.compile import module + +class StochasticGradientDescent(module.FancyModule): + def __init__(self, params, gparams, lr=None): + super(StochasticGradientDescent, self).__init__() + + self.lr = lr if lr is not None else module.Member(T.dscalar()) + self.params = params + self.gparams = gparams + + self.updates = dict((p, p - self.lr * g) for p, g in zip(self.params, self.gparams)) +