Mercurial > pylearn
comparison algorithms/tests/test_aa.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 | 267ec8baef9f |
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 aa = models.SigmoidXEAutoEncoder(regularize = False) | |
11 # print aa.update.pretty(mode = theano.Mode('py', 'fast_run').excluding('inplace')) | |
12 | |
13 model = aa.make(lr = 0.01, | |
14 input_size = 100, | |
15 hidden_size = 1000, | |
16 mode = mode) | |
17 | |
18 data = [[0, 1, 0, 0, 1, 1, 1, 0, 1, 0]*10]*10 | |
19 #data = numpy.random.rand(10, 100) | |
20 | |
21 t1 = time.time() | |
22 for i in xrange(1001): | |
23 cost = model.update(data) | |
24 if i % 100 == 0: | |
25 print i, cost | |
26 t2 = time.time() | |
27 return t2 - t1 | |
28 | |
29 if __name__ == '__main__': | |
30 numpy.random.seed(10) | |
31 print 'optimized:' | |
32 t1 = test_train(theano.Mode('c|py', 'fast_run')) | |
33 print 'time:',t1 | |
34 print | |
35 | |
36 numpy.random.seed(10) | |
37 print 'not optimized:' | |
38 t2 = test_train(theano.Mode('c|py', 'fast_compile')) | |
39 print 'time:',t2 | |
40 | |
41 | |
42 |