comparison _test_nnet_ops.py @ 444:9cfc2fc0f4d1

New tests for softmax.
author Pascal Lamblin <lamblinp@iro.umontreal.ca>
date Fri, 22 Aug 2008 17:33:19 -0400
parents 43d9aa93934e
children
comparison
equal deleted inserted replaced
443:060c12314734 444:9cfc2fc0f4d1
15 class T_softplus(unittest.TestCase): 15 class T_softplus(unittest.TestCase):
16 def setUp(self): 16 def setUp(self):
17 numpy.random.seed(9999) 17 numpy.random.seed(9999)
18 def test_elemwise(self): 18 def test_elemwise(self):
19 TT.verify_grad(self, softplus, [numpy.random.rand(3,4)]) 19 TT.verify_grad(self, softplus, [numpy.random.rand(3,4)])
20
21 class T_Softmax(unittest.TestCase):
22 def setUp(self):
23 numpy.random.seed(9999)
24 def test0(self):
25 class Dummy(object):
26 def make_node(self, a):
27 return [softmax(a)[:,0]]
28 TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4)])
29 def test1(self):
30 class Dummy(object):
31 def make_node(self, a):
32 return [softmax(a)[:,1]]
33 TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4)])
34 def test2(self):
35 class Dummy(object):
36 def make_node(self, a):
37 return [softmax(a)[:,2]]
38 TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4)])
39 def test3(self):
40 class Dummy(object):
41 def make_node(self, a):
42 return [softmax(a)[:,3]]
43 TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4)])
44
45
46 class T_SoftmaxWithBias(unittest.TestCase):
47 def setUp(self):
48 numpy.random.seed(9999)
49 def test0(self):
50 class Dummy(object):
51 def make_node(self, a, b):
52 return [softmax_with_bias(a, b)[:,0]]
53 TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4),
54 numpy.random.rand(4)])
55 def test1(self):
56 class Dummy(object):
57 def make_node(self, a, b):
58 return [softmax_with_bias(a, b)[:,1]]
59 TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4),
60 numpy.random.rand(4)])
61 def test2(self):
62 class Dummy(object):
63 def make_node(self, a, b):
64 return [softmax_with_bias(a, b)[:,2]]
65 TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4),
66 numpy.random.rand(4)])
67 def test3(self):
68 class Dummy(object):
69 def make_node(self, a, b):
70 return [softmax_with_bias(a, b)[:,3]]
71 TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4),
72 numpy.random.rand(4)])
20 73
21 class T_CrossentropySoftmax1Hot(unittest.TestCase): 74 class T_CrossentropySoftmax1Hot(unittest.TestCase):
22 def setUp(self): 75 def setUp(self):
23 numpy.random.seed(9999) 76 numpy.random.seed(9999)
24 def test0(self): 77 def test0(self):