Mercurial > pylearn
comparison algorithms/tests/test_stacker.py @ 476:8fcd0f3d9a17
added a few algorithms
author | Olivier Breuleux <breuleuo@iro.umontreal.ca> |
---|---|
date | Mon, 27 Oct 2008 17:26:00 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
475:11e0357f06f4 | 476:8fcd0f3d9a17 |
---|---|
1 | |
2 import models | |
3 import theano | |
4 import numpy | |
5 import time | |
6 | |
7 | |
8 def test_train(mode = theano.Mode('c|py', 'fast_run')): | |
9 | |
10 reg = models.Stacker([(models.BinRegressor, 'output'), (models.BinRegressor, 'output')], | |
11 regularize = False) | |
12 #print reg.global_update[1].pretty(mode = mode.excluding('inplace')) | |
13 | |
14 model = reg.make([100, 200, 1], | |
15 lr = 0.01, | |
16 mode = mode, | |
17 seed = 10) | |
18 | |
19 R = numpy.random.RandomState(100) | |
20 t1 = time.time() | |
21 for i in xrange(1001): | |
22 data = R.random_integers(0, 1, size = (10, 100)) | |
23 targets = data[:, 6].reshape((10, 1)) | |
24 cost = model.update(data, targets) | |
25 if i % 100 == 0: | |
26 print i, '\t', cost, '\t', 1*(targets.T == model.classify(data).T) | |
27 t2 = time.time() | |
28 return t2 - t1 | |
29 | |
30 if __name__ == '__main__': | |
31 print 'optimized:' | |
32 t1 = test_train(theano.Mode('c|py', 'fast_run')) | |
33 print 'time:',t1 | |
34 print | |
35 | |
36 print 'not optimized:' | |
37 t2 = test_train(theano.Mode('c|py', 'fast_compile')) | |
38 print 'time:',t2 | |
39 | |
40 | |
41 | |
42 | |
43 |