Mercurial > pylearn
comparison algorithms/_test_logistic_regression.py @ 470:bd937e845bbb
new stuff: algorithms/logistic_regression, datasets/MNIST
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Wed, 22 Oct 2008 15:56:53 -0400 |
parents | |
children | c7ce66b4e8f4 |
comparison
equal
deleted
inserted
replaced
469:4335309f4924 | 470:bd937e845bbb |
---|---|
1 from logistic_regression import * | |
2 import sys, time | |
3 | |
4 if __name__ == '__main__': | |
5 pprint.assign(nnet_ops.crossentropy_softmax_1hot_with_bias_dx, printing.FunctionPrinter('xsoftmaxdx')) | |
6 pprint.assign(nnet_ops.crossentropy_softmax_argmax_1hot_with_bias, printing.FunctionPrinter('nll', 'softmax', 'argmax')) | |
7 if 1: | |
8 lrc = Module_Nclass() | |
9 | |
10 print '================' | |
11 print lrc.update.pretty() | |
12 print '================' | |
13 print lrc.update.pretty(mode = theano.Mode('py', 'fast_run')) | |
14 print '================' | |
15 # print lrc.update.pretty(mode = compile.FAST_RUN.excluding('inplace')) | |
16 # print '================' | |
17 | |
18 # sys.exit(0) | |
19 | |
20 lr = lrc.make(10, 2, mode=theano.Mode('c|py', 'fast_run')) | |
21 #lr = lrc.make(10, 2, mode=compile.FAST_RUN.excluding('fast_run')) | |
22 #lr = lrc.make(10, 2, mode=theano.Mode('py', 'merge')) #'FAST_RUN') | |
23 | |
24 data_x = N.random.randn(5, 10) | |
25 data_y = (N.random.randn(5) > 0) | |
26 | |
27 t = time.time() | |
28 for i in xrange(10000): | |
29 lr.lr = 0.02 | |
30 xe = lr.update(data_x, data_y) | |
31 #if i % 100 == 0: | |
32 # print i, xe | |
33 | |
34 print 'training time:', time.time() - t | |
35 print 'final error', xe | |
36 | |
37 #print | |
38 #print 'TRAINED MODEL:' | |
39 #print lr | |
40 | |
41 if 0: | |
42 lrc = Module() | |
43 | |
44 lr = lrc.make(10, mode=theano.Mode('c|py', 'merge')) #'FAST_RUN') | |
45 | |
46 data_x = N.random.randn(5, 10) | |
47 data_y = (N.random.randn(5, 1) > 0) | |
48 | |
49 for i in xrange(10000): | |
50 xe = lr.update(data_x, data_y) | |
51 if i % 100 == 0: | |
52 print i, xe | |
53 | |
54 print | |
55 print 'TRAINED MODEL:' | |
56 print lr | |
57 | |
58 | |
59 | |
60 |