Mercurial > pylearn
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 | 1 from xlogx import xlogx |
2 | |
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 | 5 from theano import compile |
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 | 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 | 10 |
11 import random | |
12 import numpy.random | |
13 | |
14 class T_XlogX(unittest.TestCase): | |
15 def test0(self): | |
16 x = as_tensor([1, 0]) | |
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 | 20 def test1(self): |
21 class Dummy(object): | |
22 def make_node(self, a): | |
23 return [xlogx(a)[:,2]] | |
24 TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4)]) | |
25 | |
26 | |
27 if __name__ == '__main__': | |
28 unittest.main() |