Mercurial > pylearn
changeset 444:9cfc2fc0f4d1
New tests for softmax.
author | Pascal Lamblin <lamblinp@iro.umontreal.ca> |
---|---|
date | Fri, 22 Aug 2008 17:33:19 -0400 |
parents | 060c12314734 |
children | 6eb0900fb553 |
files | _test_nnet_ops.py |
diffstat | 1 files changed, 53 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/_test_nnet_ops.py Fri Aug 22 17:33:06 2008 -0400 +++ b/_test_nnet_ops.py Fri Aug 22 17:33:19 2008 -0400 @@ -18,6 +18,59 @@ def test_elemwise(self): TT.verify_grad(self, softplus, [numpy.random.rand(3,4)]) +class T_Softmax(unittest.TestCase): + def setUp(self): + numpy.random.seed(9999) + def test0(self): + class Dummy(object): + def make_node(self, a): + return [softmax(a)[:,0]] + TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4)]) + def test1(self): + class Dummy(object): + def make_node(self, a): + return [softmax(a)[:,1]] + TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4)]) + def test2(self): + class Dummy(object): + def make_node(self, a): + return [softmax(a)[:,2]] + TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4)]) + def test3(self): + class Dummy(object): + def make_node(self, a): + return [softmax(a)[:,3]] + TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4)]) + + +class T_SoftmaxWithBias(unittest.TestCase): + def setUp(self): + numpy.random.seed(9999) + def test0(self): + class Dummy(object): + def make_node(self, a, b): + return [softmax_with_bias(a, b)[:,0]] + TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4), + numpy.random.rand(4)]) + def test1(self): + class Dummy(object): + def make_node(self, a, b): + return [softmax_with_bias(a, b)[:,1]] + TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4), + numpy.random.rand(4)]) + def test2(self): + class Dummy(object): + def make_node(self, a, b): + return [softmax_with_bias(a, b)[:,2]] + TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4), + numpy.random.rand(4)]) + def test3(self): + class Dummy(object): + def make_node(self, a, b): + return [softmax_with_bias(a, b)[:,3]] + TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4), + numpy.random.rand(4)]) + class T_CrossentropySoftmax1Hot(unittest.TestCase): def setUp(self): numpy.random.seed(9999)