comparison algorithms/tests/test_daa.py @ 533:de974b4fc4ea

Bugfix in pylearn.embeddings.length()
author Joseph Turian <turian@gmail.com>
date Tue, 18 Nov 2008 03:25:54 -0500
parents 4fb6f7320518
children
comparison
equal deleted inserted replaced
532:34ee3aff3e8f 533:de974b4fc4ea
26 for l in range(3): 26 for l in range(3):
27 for i in range(10): 27 for i in range(10):
28 model.local_update[l]([[0, 1, 0, 1]]) 28 model.local_update[l]([[0, 1, 0, 1]])
29 model.local_update[l]([[1, 0, 1, 0]]) 29 model.local_update[l]([[1, 0, 1, 0]])
30 30
31 for i in range(1): 31 for i in range(10):
32 model.update([[0, 1, 0, 1]], [[1]]) 32 model.update([[0, 1, 0, 1]], [[1]])
33 model.update([[1, 0, 1, 0]], [[0]]) 33 model.update([[1, 0, 1, 0]], [[0]])
34 print model.classify([[0, 1, 0, 1]]) 34 print model.classify([[0, 1, 0, 1]])
35 print model.classify([[1, 0, 1, 0]]) 35 print model.classify([[1, 0, 1, 0]])
36 36
39 39
40 ndaa = 3 40 ndaa = 3
41 daa = models.Stacker([(models.SigmoidXEDenoisingAA, 'hidden')] * ndaa + [(pylearn.algorithms.logistic_regression.Module_Nclass, 'pred')], 41 daa = models.Stacker([(models.SigmoidXEDenoisingAA, 'hidden')] * ndaa + [(pylearn.algorithms.logistic_regression.Module_Nclass, 'pred')],
42 regularize = False) 42 regularize = False)
43 43
44 model = daa.make([4, 20, 20, 20, 10], 44 model = daa.make([4] + [20] * ndaa + [10],
45 lr = 0.01, 45 lr = 0.01,
46 mode = mode, 46 mode = mode,
47 seed = 10) 47 seed = 10)
48 48
49 model.layers[0].noise_level = 0.3 49 for l in range(ndaa): model.layers[l].noise_level = 0.3
50 model.layers[1].noise_level = 0.3
51 model.layers[2].noise_level = 0.3
52 50
53 for l in range(3): 51 instances = [([[0, 1, 0, 1]], [1]), ([[1, 0, 1, 0]], [0])]
52
53 for l in range(ndaa):
54 for i in range(10): 54 for i in range(10):
55 model.local_update[l]([[0, 1, 0, 1]]) 55 for (input, output) in instances:
56 model.local_update[l]([[1, 0, 1, 0]]) 56 model.local_update[l](input)
57 57
58 for i in range(1): 58 for i in range(10):
59 model.update([[0, 1, 0, 1]], [1]) 59 for (input, output) in instances:
60 model.update([[1, 0, 1, 0]], [0]) 60 # model.update(input, output)
61 print "OLD:",
62 print model.validate(input, output)
63 oldloss = model.update(input, output)
64 print oldloss
65 print "NEW:"
66 print model.validate(input, output)
67 print
68
61 print model.apply([[0, 1, 0, 1]]) 69 print model.apply([[0, 1, 0, 1]])
62 print model.apply([[1, 0, 1, 0]]) 70 print model.apply([[1, 0, 1, 0]])
63 71
64 72
65 73