提交 41075539 authored 作者: Frederic's avatar Frederic

Move test to where it should

上级 5ae5123d
import numpy
import theano
import theano.tensor as T
from theano.tensor.opt import Assert
def test_assert_op_gradient():
x = T.vector('x')
assert_op = Assert()
cost = T.sum(assert_op(x, x.size < 2))
grad = T.grad(cost, x)
func = theano.function([x], grad)
x_val = numpy.ones(shape=(1,), dtype=theano.config.floatX)
assert func(x_val) == 1
...@@ -5173,6 +5173,18 @@ class TestShapeFeature(unittest.TestCase): ...@@ -5173,6 +5173,18 @@ class TestShapeFeature(unittest.TestCase):
self.assertRaises(IndexError, shape_feature.same_shape, x, o, 1, 0) self.assertRaises(IndexError, shape_feature.same_shape, x, o, 1, 0)
self.assertRaises(IndexError, shape_feature.same_shape, x, o, 0, 1) self.assertRaises(IndexError, shape_feature.same_shape, x, o, 0, 1)
def test_assert_op_gradient():
x = T.vector('x')
assert_op = Assert()
cost = T.sum(assert_op(x, x.size < 2))
grad = T.grad(cost, x)
func = theano.function([x], grad)
x_val = numpy.ones(shape=(1,), dtype=theano.config.floatX)
assert func(x_val) == 1
if __name__ == '__main__': if __name__ == '__main__':
t = TestMakeVector('setUp') t = TestMakeVector('setUp')
t.setUp() t.setUp()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论