Mercurial > pylearn
comparison algorithms/tests/test_regressor.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 | |
3 import models | |
4 import theano | |
5 import numpy | |
6 import time | |
7 | |
8 | |
9 def test_train(mode = theano.Mode('c|py', 'fast_run')): | |
10 | |
11 reg = models.BinRegressor(regularize = False) | |
12 | |
13 model = reg.make(lr = 0.01, | |
14 input_size = 100, | |
15 mode = mode, | |
16 seed = 10) | |
17 | |
18 # data = [[0, 1, 0, 0, 1, 1, 1, 0, 1, 0]*10]*10 | |
19 # targets = [[1]]*10 | |
20 #data = numpy.random.rand(10, 100) | |
21 | |
22 R = numpy.random.RandomState(100) | |
23 t1 = time.time() | |
24 for i in xrange(1001): | |
25 data = R.random_integers(0, 1, size = (10, 100)) | |
26 targets = data[:, 6].reshape((10, 1)) | |
27 cost = model.update(data, targets) | |
28 if i % 100 == 0: | |
29 print i, '\t', cost, '\t', 1*(targets.T == model.classify(data).T) | |
30 t2 = time.time() | |
31 return t2 - t1 | |
32 | |
33 if __name__ == '__main__': | |
34 print 'optimized:' | |
35 t1 = test_train(theano.Mode('c|py', 'fast_run')) | |
36 print 'time:',t1 | |
37 print | |
38 | |
39 print 'not optimized:' | |
40 t2 = test_train(theano.Mode('c|py', 'fast_compile')) | |
41 print 'time:',t2 | |
42 | |
43 | |
44 | |
45 | |
46 |