提交 c1e7546a authored 作者: nouiz's avatar nouiz

Merge pull request #702 from pascanur/bug_nicolas

Bug reported by Nicolas regarding taps of scan sequences
...@@ -492,7 +492,10 @@ def scan(fn, ...@@ -492,7 +492,10 @@ def scan(fn,
else: else:
offset = 0 offset = 0
if maxtap == mintap and maxtap != 0: if maxtap == mintap and maxtap != 0:
nw_seq = seq['input'][:abs(maxtap)] if maxtap < 0:
nw_seq = seq['input'][:maxtap]
else:
nw_seq = seq['input'][maxtap:]
elif maxtap - k != 0: elif maxtap - k != 0:
nw_seq = seq['input'][offset + k - mintap: -(maxtap - k)] nw_seq = seq['input'][offset + k - mintap: -(maxtap - k)]
else: else:
......
...@@ -683,6 +683,19 @@ class T_Scan(unittest.TestCase): ...@@ -683,6 +683,19 @@ class T_Scan(unittest.TestCase):
ny1[4] = (ny1[3] + ny1[1]) * numpy.dot(ny0[3], vWout) ny1[4] = (ny1[3] + ny1[1]) * numpy.dot(ny0[3], vWout)
ny2[4] = numpy.dot(v_u1[4], vW_in1) ny2[4] = numpy.dot(v_u1[4], vW_in1)
def test_using_taps_sequence(self):
# this test refers to a bug reported by Nicolas
# Boulanger-Lewandowski June 6th
x = theano.tensor.dvector()
y, updates = theano.scan(lambda x: [x],
sequences=dict(input=x, taps=[-1]),
outputs_info = [None])
inp = numpy.arange(5).astype('float64')
rval = theano.function([x], y, updates=updates)(inp)
import ipdb; ipdb.set_trace()
assert numpy.all(rval == inp[:-1])
# simple rnn, one input, one state, weights for each; input/state are # simple rnn, one input, one state, weights for each; input/state are
# vectors, weights are scalars; using shared variables and past # vectors, weights are scalars; using shared variables and past
# taps (sequences and outputs) # taps (sequences and outputs)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论