def test_pushout3(self):
raise SkipTest("Optimization temporarily disabled")
x1 = tensor.scalar('x1')
y1 = tensor.scalar('x2')
y2 = tensor.scalar('y2')
c = tensor.iscalar('c')
two = numpy.asarray(2, dtype=theano.config.floatX)
x, y = ifelse(c, (x1, y1), (two, y2), name='f1')
o3 = numpy.asarray(0.3, dtype=theano.config.floatX)
o2 = numpy.asarray(0.2, dtype=theano.config.floatX)
z = ifelse(c, o3, o2, name='f2')
out = x * z * y
f = theano.function([x1, y1, y2, c], out,
allow_input_downcast=True)
assert isinstance(f.maker.fgraph.toposort()[-1].op, IfElse)
rng = numpy.random.RandomState(utt.fetch_seed())
vx1 = rng.uniform()
vy1 = rng.uniform()
vy2 = rng.uniform()
assert numpy.allclose(f(vx1, vy1, vy2, 1), vx1 * vy1 * 0.3)
assert numpy.allclose(f(vx1, vy1, vy2, 0), 2 * vy2 * 0.2)
评论列表
文章目录