Mercurial > pylearn
changeset 483:2c4738e5e4b2
merge
author | Olivier Breuleux <breuleuo@iro.umontreal.ca> |
---|---|
date | Tue, 28 Oct 2008 00:23:53 -0400 |
parents | b15dad843c8c (current diff) 267ec8baef9f (diff) |
children | 3daabc7f94ff 180d125dc7e2 |
files | |
diffstat | 3 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/algorithms/sgd.py Tue Oct 28 00:23:53 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)) +