def test_clone(self):
def test(x, y, mention_y):
if mention_y:
d = 0.1 + 0 * y
else:
d = 0.1
out = theano.clone(y, replace={x: x + d})
# theano.printing.debugprint(out)
return theano.function([], out)()
x = theano.shared(numpy.asarray(0., dtype=theano.config.floatX))
utt.assert_allclose(test(x, tensor.sum((x+1)**2), mention_y=False),
1.21000003815)
utt.assert_allclose(test(x, tensor.sum((x+1)**2), mention_y=True),
1.21000003815)
评论列表
文章目录