提交 b062ec20 authored 作者: Joseph Turian's avatar Joseph Turian

Upgraded test_xlogx.py

上级 96b86eb4
from xlogx import xlogx
from theano.tensor.xlogx import xlogx
import unittest
from theano import compile
from theano import gradient
import theano
from theano.tensor import as_tensor
import theano._test_tensor as TT
import test_basic as TT
import random
import numpy.random
......@@ -14,13 +13,13 @@ class T_XlogX(unittest.TestCase):
def test0(self):
x = as_tensor([1, 0])
y = xlogx(x)
y = compile.eval_outputs([y])
self.failUnless(numpy.all(y == numpy.asarray([0, 0.])))
f = theano.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)])
# class Dummy(object):
# def make_node(self, a):
# return [xlogx(a)[:,2]]
TT.verify_grad(self, xlogx, [numpy.random.rand(3,4)])
if __name__ == '__main__':
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论