Mercurial > pylearn
comparison algorithms/tests/test_daa.py @ 500:3c60c2db0319
Added new daa test
author | Joseph Turian <turian@gmail.com> |
---|---|
date | Tue, 28 Oct 2008 13:36:27 -0400 |
parents | 32509c479e2d |
children | 4fb6f7320518 |
comparison
equal
deleted
inserted
replaced
499:a419edf4e06c | 500:3c60c2db0319 |
---|---|
3 from pylearn import algorithms as models | 3 from pylearn import algorithms as models |
4 import theano | 4 import theano |
5 import numpy | 5 import numpy |
6 import time | 6 import time |
7 | 7 |
8 import pylearn.algorithms.logistic_regression | |
8 | 9 |
9 def test_train_daa(mode = theano.Mode('c|py', 'fast_run')): | 10 def test_train_daa(mode = theano.Mode('c|py', 'fast_run')): |
10 | 11 |
11 ndaa = 3 | 12 ndaa = 3 |
12 daa = models.Stacker([(models.SigmoidXEDenoisingAA, 'hidden')] * ndaa + [(models.BinRegressor, 'output')], | 13 daa = models.Stacker([(models.SigmoidXEDenoisingAA, 'hidden')] * ndaa + [(models.BinRegressor, 'output')], |
28 | 29 |
29 model.update([[0, 1, 0, 1]], [[0]]) | 30 model.update([[0, 1, 0, 1]], [[0]]) |
30 print model.classify([[0, 1, 0, 1]]) | 31 print model.classify([[0, 1, 0, 1]]) |
31 | 32 |
32 | 33 |
34 def test_train_daa2(mode = theano.Mode('c|py', 'fast_run')): | |
35 | |
36 ndaa = 3 | |
37 daa = models.Stacker([(models.SigmoidXEDenoisingAA, 'hidden')] * ndaa + [(pylearn.algorithms.logistic_regression.Module_Nclass, 'output')], | |
38 regularize = False) | |
39 | |
40 model = daa.make([4, 20, 20, 20, 1], | |
41 lr = 0.01, | |
42 mode = mode, | |
43 seed = 10) | |
44 | |
45 model.layers[0].noise_level = 0.3 | |
46 model.layers[1].noise_level = 0.3 | |
47 model.layers[2].noise_level = 0.3 | |
48 | |
49 # Update the first hidden layer | |
50 model.local_update[0]([[0, 1, 0, 1]]) | |
51 model.local_update[1]([[0, 1, 0, 1]]) | |
52 model.local_update[2]([[0, 1, 0, 1]]) | |
53 | |
54 model.update([[0, 1, 0, 1]], [0]) | |
55 print model.classify([[0, 1, 0, 1]]) | |
56 | |
57 | |
33 | 58 |
34 | 59 |
35 | 60 |
36 if __name__ == '__main__': | 61 if __name__ == '__main__': |
37 # print 'optimized:' | 62 # print 'optimized:' |
44 # t2 = test_train_daa(theano.Mode('c|py', 'fast_compile')) | 69 # t2 = test_train_daa(theano.Mode('c|py', 'fast_compile')) |
45 ## print 'time:',t2 | 70 ## print 'time:',t2 |
46 | 71 |
47 # test_train_daa(theano.compile.Mode('c&py', 'merge')) | 72 # test_train_daa(theano.compile.Mode('c&py', 'merge')) |
48 test_train_daa(theano.compile.Mode('c|py', 'merge')) | 73 test_train_daa(theano.compile.Mode('c|py', 'merge')) |
74 test_train_daa2(theano.compile.Mode('c|py', 'merge')) |