提交 f492fdab authored 作者: Razvan Pascanu's avatar Razvan Pascanu

fixing the test that was failing before once the optimization was activated

上级 4a02dec9
...@@ -42,7 +42,7 @@ class test_ifelse(unittest.TestCase): ...@@ -42,7 +42,7 @@ class test_ifelse(unittest.TestCase):
x = tensor.vector('x') x = tensor.vector('x')
y = tensor.vector('y') y = tensor.vector('y')
c = tensor.iscalar('c') c = tensor.iscalar('c')
f = theano.function([c, x, y], 2 * ifelse(c, x, y)) f = theano.function([c, x, y], ifelse(c, x, y))
rng = numpy.random.RandomState(utt.fetch_seed()) rng = numpy.random.RandomState(utt.fetch_seed())
xlen = rng.randint(200) xlen = rng.randint(200)
...@@ -50,10 +50,12 @@ class test_ifelse(unittest.TestCase): ...@@ -50,10 +50,12 @@ class test_ifelse(unittest.TestCase):
vx = numpy.asarray(rng.uniform(size=(xlen,)), theano.config.floatX) vx = numpy.asarray(rng.uniform(size=(xlen,)), theano.config.floatX)
vy = numpy.asarray(rng.uniform(size=(ylen,)), theano.config.floatX) vy = numpy.asarray(rng.uniform(size=(ylen,)), theano.config.floatX)
assert numpy.all(x.op.inplace for x in f.maker.env.toposort() if assert numpy.all([x.op.as_view for x in f.maker.env.toposort() if
x.op == IfElse) isinstance(x.op, IfElse)])
assert numpy.allclose(vx * 2, f(1, vx, vy)) assert len([x.op for x in f.maker.env.toposort()
assert numpy.allclose(vy * 2, f(0, vx, vy)) if isinstance(x.op, IfElse)]) > 0
assert numpy.allclose(vx, f(1, vx, vy))
assert numpy.allclose(vy, f(0, vx, vy))
def test_lazy_if_on_generics(self): def test_lazy_if_on_generics(self):
x = theano.generic() x = theano.generic()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论