提交 52c127c5 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Merge pull request #2948 from SinaHonari/issues2601

changing test_infer_shape in TestDownsampleFactorMax to include padding
...@@ -622,27 +622,41 @@ class TestDownsampleFactorMax(utt.InferShapeTester): ...@@ -622,27 +622,41 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
maxpoolshps = ((1, 1), (2, 2), (3, 3), (2, 3), (3, 2)) maxpoolshps = ((1, 1), (2, 2), (3, 3), (2, 3), (3, 2))
image_val = rng.rand(4, 6, 7, 9) image_val = rng.rand(4, 6, 7, 9)
out_shapes = [[[4, 6, 7, 9], [4, 6, 7, 9]], out_shapes = [[[[4, 6, 7, 9], [4, 6, 7, 9]],
[[4, 6, 3, 4], [4, 6, 4, 5]], [[4, 6, 3, 4], [4, 6, 4, 5]],
[[4, 6, 2, 3], [4, 6, 3, 3]], [[4, 6, 2, 3], [4, 6, 3, 3]],
[[4, 6, 3, 3], [4, 6, 4, 3]], [[4, 6, 3, 3], [4, 6, 4, 3]],
[[4, 6, 2, 4], [4, 6, 3, 5]]] [[4, 6, 2, 4], [4, 6, 3, 5]]],
[[None, None],
[[4, 6, 4, 5], None],
[[4, 6, 3, 3], None],
[[4, 6, 4, 3], None],
[[4, 6, 3, 5], None]],
[[None, None],
[None, None],
[[4, 6, 3, 4], None],
[[4, 6, 4, 4], None],
[None, None]]]
for i, maxpoolshp in enumerate(maxpoolshps): for i, maxpoolshp in enumerate(maxpoolshps):
for j, ignore_border in enumerate([True, False]): for j, ignore_border in enumerate([True, False]):
for k, padding in enumerate([(0,0), (1,1), (1,2)]):
if out_shapes[k][i][j] == None:
continue
# checking shapes generated by DownsampleFactorMax # checking shapes generated by DownsampleFactorMax
self._compile_and_check([image], self._compile_and_check([image],
[DownsampleFactorMax(maxpoolshp, [DownsampleFactorMax(maxpoolshp,
ignore_border=ignore_border)(image)], ignore_border=ignore_border,
padding=padding)(image)],
[image_val], DownsampleFactorMax) [image_val], DownsampleFactorMax)
# checking shapes generated by DownsampleFactorMaxGrad # checking shapes generated by DownsampleFactorMaxGrad
maxout_val = rng.rand(*out_shapes[i][j]) maxout_val = rng.rand(*out_shapes[k][i][j])
gz_val = rng.rand(*out_shapes[i][j]) gz_val = rng.rand(*out_shapes[k][i][j])
self._compile_and_check([image, maxout, gz], self._compile_and_check([image, maxout, gz],
[DownsampleFactorMaxGrad(maxpoolshp, [DownsampleFactorMaxGrad(maxpoolshp,
ignore_border=ignore_border) ignore_border=ignore_border,
padding=padding)
(image, maxout, gz)], (image, maxout, gz)],
[image_val, maxout_val, gz_val], [image_val, maxout_val, gz_val],
DownsampleFactorMaxGrad, DownsampleFactorMaxGrad,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论