annotate _test_xlogx.py @ 463:8df9179b3239

Updated file locations
author Joseph Turian <turian@iro.umontreal.ca>
date Wed, 08 Oct 2008 17:31:26 -0400
parents 117e5b09cf31
children 242efecefd70
rev   line source
450
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
1 from xlogx import xlogx
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
2
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
3 import unittest
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
4 from theano import compile
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
5 from theano import gradient
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
6
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
7 from theano.tensor import as_tensor
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
8 import theano._test_tensor as TT
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
9
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
10 import random
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
11 import numpy.random
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
12
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
13 class T_XlogX(unittest.TestCase):
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
14 def test0(self):
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
15 x = as_tensor([1, 0])
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
16 y = xlogx(x)
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
17 y = compile.eval_outputs([y])
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
18 self.failUnless(numpy.all(y == numpy.asarray([0, 0.])))
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
19 def test1(self):
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
20 class Dummy(object):
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
21 def make_node(self, a):
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
22 return [xlogx(a)[:,2]]
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
23 TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4)])
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
24
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
25
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
26 if __name__ == '__main__':
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
27 unittest.main()