Mercurial > pylearn
comparison _test_onehotop.py @ 530:844bad76459c
replaced the use of removed function compile.eval_outputs with theano.function.
author | Frederic Bastien <bastienf@iro.umontreal.ca> |
---|---|
date | Mon, 17 Nov 2008 14:18:28 -0500 |
parents | 18702ceb2096 |
children |
comparison
equal
deleted
inserted
replaced
529:4e3629a894fa | 530:844bad76459c |
---|---|
1 from onehotop import one_hot | 1 from onehotop import one_hot |
2 | 2 |
3 import unittest | 3 import unittest |
4 from theano import compile | 4 from theano import compile |
5 from theano import gradient | 5 from theano import gradient |
6 | 6 from theano import function |
7 from theano.tensor import as_tensor | 7 from theano.tensor import as_tensor |
8 | 8 |
9 import random | 9 import random |
10 import numpy.random | 10 import numpy.random |
11 | 11 |
12 class T_OneHot(unittest.TestCase): | 12 class T_OneHot(unittest.TestCase): |
13 def test0(self): | 13 def test0(self): |
14 x = as_tensor([3, 2, 1]) | 14 x = as_tensor([3, 2, 1]) |
15 y = as_tensor(5) | 15 y = as_tensor(5) |
16 o = one_hot(x, y) | 16 o = one_hot(x, y) |
17 y = compile.eval_outputs([o]) | 17 f = function([],o) |
18 self.failUnless(numpy.all(y == numpy.asarray([[0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0]]))) | 18 self.failUnless(numpy.all(f() == numpy.asarray([[0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0]]))) |
19 | 19 |
20 if __name__ == '__main__': | 20 if __name__ == '__main__': |
21 unittest.main() | 21 unittest.main() |