view _test_xlogx.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 4e3629a894fa
children
line wrap: on
line source

from xlogx import xlogx

import unittest

from theano import compile
from theano import gradient
from theano import function
from theano.tensor import as_tensor
import theano.tensor.basic as TT

import random
import numpy.random

class T_XlogX(unittest.TestCase):
    def test0(self):
        x = as_tensor([1, 0])
        y = xlogx(x)
        f = function([],y)
        self.failUnless(numpy.all(f() == numpy.asarray([0, 0.])))
    def test1(self):
        class Dummy(object):
            def make_node(self, a):
                return [xlogx(a)[:,2]]
        TT.verify_grad(self, Dummy(), [numpy.random.rand(3,4)])


if __name__ == '__main__':
    unittest.main()