提交 2ce0646e authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Explicitly specify the output ndim in reshape

The whole code expects the shape to be of length 4, and the output to be 4D already
上级 bcf2d7dc
...@@ -620,7 +620,7 @@ def neibs2images(neibs, neib_shape, original_shape, mode='valid'): ...@@ -620,7 +620,7 @@ def neibs2images(neibs, neib_shape, original_shape, mode='valid'):
valid_shape = list(original_shape) valid_shape = list(original_shape)
valid_shape[2] = (valid_shape[2] // neib_shape[0]) * neib_shape[0] valid_shape[2] = (valid_shape[2] // neib_shape[0]) * neib_shape[0]
valid_shape[3] = (valid_shape[3] // neib_shape[1]) * neib_shape[1] valid_shape[3] = (valid_shape[3] // neib_shape[1]) * neib_shape[1]
output_4d = output_2d.reshape(valid_shape) output_4d = output_2d.reshape(valid_shape, ndim=4)
# padding the borders with zeros # padding the borders with zeros
for d in [2, 3]: for d in [2, 3]:
pad_shape = list(output_4d.shape) pad_shape = list(output_4d.shape)
...@@ -629,7 +629,7 @@ def neibs2images(neibs, neib_shape, original_shape, mode='valid'): ...@@ -629,7 +629,7 @@ def neibs2images(neibs, neib_shape, original_shape, mode='valid'):
elif mode == 'valid': elif mode == 'valid':
# TODO: we do not implement all mode with this code. # TODO: we do not implement all mode with this code.
# Add a check for the good cases. # Add a check for the good cases.
output_4d = output_2d.reshape(original_shape) output_4d = output_2d.reshape(original_shape, ndim=4)
else: else:
raise NotImplementedError("neibs2images do not support mode=%s" % mode) raise NotImplementedError("neibs2images do not support mode=%s" % mode)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论