提交 264cb8f6 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Added regression test

上级 8f9f093a
...@@ -3310,3 +3310,26 @@ if __name__ == '__main__': ...@@ -3310,3 +3310,26 @@ if __name__ == '__main__':
print 37 print 37
scan_tst.test_save_mem_store_steps() scan_tst.test_save_mem_store_steps()
#''' #'''
def test_compute_test_value():
"""
Verify that test values can be used with scan.
"""
backup = theano.config.compute_test_value
theano.config.compute_test_value = 'raise'
try:
x = tensor.vector()
xv = numpy.ones(3, dtype=theano.config.floatX)
x.tag.test_value = xv
y = theano.shared(numpy.arange(3, dtype=theano.config.floatX))
z, _ = theano.scan(
fn=lambda u, v: u + v,
sequences=[x, y])
assert not _
# The gradient computation used to crash before 6af465e.
g = tensor.grad(z.sum(), x)
#f = theano.function([x], g)
#print f(xv)
finally:
theano.config.compute_test_value = backup
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论