Mercurial > pylearn
comparison mlp_factory_approach.py @ 190:aa7a3ecbcc90
progress toward early stopping
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Wed, 14 May 2008 16:24:10 -0400 |
parents | 8f58abb943d4 |
children | e816821c1e50 |
comparison
equal
deleted
inserted
replaced
189:8f58abb943d4 | 190:aa7a3ecbcc90 |
---|---|
1 import dataset | 1 import copy |
2 import numpy | |
3 | |
2 import theano | 4 import theano |
3 import theano.tensor as t | 5 import theano.tensor as t |
4 import numpy | 6 |
7 import dataset | |
5 import nnet_ops | 8 import nnet_ops |
6 | 9 |
7 def _randshape(*shape): | 10 def _randshape(*shape): |
8 return (numpy.random.rand(*shape) -0.5) * 0.001 | 11 return (numpy.random.rand(*shape) -0.5) * 0.001 |
9 | 12 |
11 | 14 |
12 class _Model(object): | 15 class _Model(object): |
13 def __init__(self, nnet, params): | 16 def __init__(self, nnet, params): |
14 self.nnet = nnet | 17 self.nnet = nnet |
15 self.params = params | 18 self.params = params |
19 | |
20 def __copy__(self): | |
21 return _Model(self.nnet, [copy.copy(p) for p in params]) | |
16 | 22 |
17 def update(self, trainset, stopper=None): | 23 def update(self, trainset, stopper=None): |
18 """Update this model from more training data.""" | 24 """Update this model from more training data.""" |
19 v = self.nnet.v | 25 v = self.nnet.v |
20 params = self.params | 26 params = self.params |