annotate _test_xlogx.py @ 672:27b1344a57b1

Added preprocessing back in
author Joseph Turian <turian@gmail.com>
date Thu, 20 Nov 2008 06:38:06 -0500
parents 4e3629a894fa
children
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
529
4e3629a894fa the function compile.eval_outputs was retired. Now use function instead.
Frederic Bastien <bastienf@iro.umontreal.ca>
parents: 526
diff changeset
4
450
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
5 from theano import compile
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
6 from theano import gradient
529
4e3629a894fa the function compile.eval_outputs was retired. Now use function instead.
Frederic Bastien <bastienf@iro.umontreal.ca>
parents: 526
diff changeset
7 from theano import function
450
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
8 from theano.tensor import as_tensor
526
242efecefd70 corrected import.
Frederic Bastien <bastienf@iro.umontreal.ca>
parents: 450
diff changeset
9 import theano.tensor.basic as TT
450
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
10
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
11 import random
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
12 import numpy.random
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
13
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
14 class T_XlogX(unittest.TestCase):
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
15 def test0(self):
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
16 x = as_tensor([1, 0])
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
17 y = xlogx(x)
529
4e3629a894fa the function compile.eval_outputs was retired. Now use function instead.
Frederic Bastien <bastienf@iro.umontreal.ca>
parents: 526
diff changeset
18 f = function([],y)
4e3629a894fa the function compile.eval_outputs was retired. Now use function instead.
Frederic Bastien <bastienf@iro.umontreal.ca>
parents: 526
diff changeset
19 self.failUnless(numpy.all(f() == numpy.asarray([0, 0.])))
450
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
20 def test1(self):
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
21 class Dummy(object):
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
22 def make_node(self, a):
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
23 return [xlogx(a)[:,2]]
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
24 TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4)])
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
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
27 if __name__ == '__main__':
117e5b09cf31 Added an XlogX op.
Joseph Turian <turian@gmail.com>
parents:
diff changeset
28 unittest.main()