提交 1e02792a authored 作者: Razvan Pascanu's avatar Razvan Pascanu

better clipping of sequences to the right length

上级 186cd0e0
...@@ -220,17 +220,29 @@ def canonical_arguments(sequences, ...@@ -220,17 +220,29 @@ def canonical_arguments(sequences,
# We cut the sequence such that seq[i] to correspond to # We cut the sequence such that seq[i] to correspond to
# seq[i-k] # seq[i-k]
if maxtap < 0: if maxtap < 0:
offset = abs(maxtap) offset_max = abs(maxtap)
else: else:
offset = 0 offset_max = 0
if mintap < 0:
offset_min = abs(mintap)
else:
offset_min = 0
nw_input = orig_input nw_input = orig_input
if maxtap == mintap and maxtap != 0: if maxtap == mintap and maxtap != 0:
nw_input = nw_input[:abs(maxtap)] if maxtap > 0:
elif maxtap - k != 0: nw_input = nw_input[maxtap:]
nw_input = nw_input[offset + k - mintap:\ else:
-(maxtap - k)] nw_input = nw_input[:maxtap]
else:
st = k + offset_min
if maxtap > 0:
ed = - (maxtap + offset_min - st)
else:
ed = - (offset_min -st)
if ed != 0:
nw_input = nw_input[st:ed]
else: else:
nw_input = nw_input[offset + k - mintap:] nw_input = nw_input[st:]
inputs.append(nw_input) inputs.append(nw_input)
else: else:
raise ValueError('Provided sequence makes no sense', str(input)) raise ValueError('Provided sequence makes no sense', str(input))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论