Mercurial > pylearn
comparison _nnet_ops.py @ 117:3ef569b92fba
ported nnet_ops to new theano
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Wed, 07 May 2008 15:28:17 -0400 |
parents | 76e5c0f37165 |
children |
comparison
equal
deleted
inserted
replaced
116:9330d941fa1f | 117:3ef569b92fba |
---|---|
7 | 7 |
8 class T_sigmoid(unittest.TestCase): | 8 class T_sigmoid(unittest.TestCase): |
9 def setUp(self): | 9 def setUp(self): |
10 numpy.random.seed(9999) | 10 numpy.random.seed(9999) |
11 def test_elemwise(self): | 11 def test_elemwise(self): |
12 TT.verify_grad(self, Sigmoid, [numpy.random.rand(3,4)]) | 12 TT.verify_grad(self, sigmoid, [numpy.random.rand(3,4)]) |
13 | 13 |
14 class T_softplus(unittest.TestCase): | 14 class T_softplus(unittest.TestCase): |
15 def setUp(self): | 15 def setUp(self): |
16 numpy.random.seed(9999) | 16 numpy.random.seed(9999) |
17 def test_elemwise(self): | 17 def test_elemwise(self): |
18 TT.verify_grad(self, Softplus, [numpy.random.rand(3,4)]) | 18 TT.verify_grad(self, softplus, [numpy.random.rand(3,4)]) |
19 | 19 |
20 class T_CrossentropySoftmax1Hot(unittest.TestCase): | 20 class T_CrossentropySoftmax1Hot(unittest.TestCase): |
21 def setUp(self): | 21 def setUp(self): |
22 numpy.random.seed(9999) | 22 numpy.random.seed(9999) |
23 def test0(self): | 23 def test0(self): |
24 y_idx = [0,1,3] | 24 y_idx = [0,1,3] |
25 def output1(a,b): | 25 class Dummy(object): |
26 return crossentropy_softmax_1hot_with_bias(a, b, y_idx)[0:1] | 26 def make_node(self, a,b): |
27 TT.verify_grad(self, output1, [numpy.random.rand(3,4), | 27 return crossentropy_softmax_1hot_with_bias(a, b, y_idx)[0:1] |
28 TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4), | |
28 numpy.random.rand(4)]) | 29 numpy.random.rand(4)]) |
29 | 30 |
30 def test1(self): | 31 def test1(self): |
31 y_idx = [0,1,3] | 32 y_idx = [0,1,3] |
32 def output1(a): | 33 class Dummy(object): |
33 return crossentropy_softmax_1hot(a, y_idx)[0:1] | 34 def make_node(self, a): |
34 TT.verify_grad(self, output1, [numpy.random.rand(3,4)]) | 35 return crossentropy_softmax_1hot(a, y_idx)[0:1] |
36 TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4)]) | |
35 | 37 |
36 | 38 |
37 | 39 |
38 if __name__ == '__main__': | 40 if __name__ == '__main__': |
39 unittest.main() | 41 unittest.main() |