Mercurial > pylearn
changeset 480:1babf35fcef5
merged
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Mon, 27 Oct 2008 17:29:03 -0400 |
parents | fbfd3932fd00 (diff) 8fcd0f3d9a17 (current diff) |
children | 267ec8baef9f |
files | |
diffstat | 2 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/algorithms/sgd.py Mon Oct 27 17:29:03 2008 -0400 @@ -0,0 +1,14 @@ + +from theano.compile import module +from theano import tensor as T + +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)) +