提交 2b5c33f0 authored 作者: Razvan Pascanu's avatar Razvan Pascanu

another test including sequences

上级 54817f81
...@@ -32,8 +32,29 @@ def test_002(): ...@@ -32,8 +32,29 @@ def test_002():
assert numpy.all(fn(val_x0)[0] == val_x0) assert numpy.all(fn(val_x0)[0] == val_x0)
def test_003():
x0 = theano.tensor.fvector('x0')
sq = theano.tensor.fvector('sq')
state = theano.tensor.alloc(
theano.tensor.constant(numpy.float32(0)),
6,
x0.shape[0])
state = theano.tensor.set_subtensor(state[0], x0)
out, _ = scan.scan(lambda s, x:x+s,
sequences=sq,
states = state,
n_steps = 5)
fn = theano.function([sq, x0], out)
val_x0 = numpy.float32([1,2,3])
val_sq = numpy.float32([1,2,3,4,5])
assert numpy.all(fn(val_sq, val_x0)[-1] == val_x0 +15)
assert numpy.all(fn(val_sq, val_x0)[0] == val_x0)
if __name__=='__main__': if __name__=='__main__':
test_001() test_001()
test_002() test_002()
test_003()
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论