提交 9bb2c28b authored 作者: --global's avatar --global

Add check for function output

上级 dd4c1c33
......@@ -2436,10 +2436,10 @@ class T_Scan(unittest.TestCase):
# recurrent output of a scan node associated with a state with a
# state with broadcastable dimensions
x = tensor.col()
seq = tensor.col()
x = tensor.dcol()
seq = tensor.dcol()
outputs_info=[x, tensor.zeros_like(x)]
(out1, out2), updates = theano.scan(lambda a, b, c : (a + b, b + c),
(out1, out2), updates = theano.scan(lambda a, b, c : (a + b, a + c),
sequences=seq,
outputs_info=outputs_info)
......@@ -2452,6 +2452,22 @@ class T_Scan(unittest.TestCase):
fct = theano.function([x, seq],
[out1_direct, out2_direct])
# Test that the function returns valid outputs
x_val = numpy.arange(0, 4)[:, None]
seq_val = numpy.arange(4, 8)[:, None]
out1, out2 = fct(x_val, seq_val)
expected_out1 = numpy.zeros((5, 4, 1))
expected_out2 = numpy.zeros((5, 4, 1))
for i in range(4):
expected_out2[i + 1] = expected_out2[i] + seq_val[i]
for i in range(5):
expected_out1[i] = expected_out2[i] + x_val
utt.assert_allclose(out1, expected_out1)
utt.assert_allclose(out2, expected_out2)
def test_infer_shape(self):
# Test for a crash in scan.infer_shape when using both
# an until condition and random sampling in the inner function.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论