提交 4925a648 authored 作者: Gijs van Tulder's avatar Gijs van Tulder

Reduce number of inconsistent-shape tests.

上级 c655fb73
...@@ -500,11 +500,17 @@ class BaseTestConv2d(BaseTestConv): ...@@ -500,11 +500,17 @@ class BaseTestConv2d(BaseTestConv):
True) True)
def test_gradinput_impossible_output_shapes(self): def test_gradinput_impossible_output_shapes(self):
for i in range(1, 10): def run_for_output_offsets(image_shape, kernel_shape, s, border_mode, d):
for k in range(1, 5): # outputs that are too large or too small should be rejected
for o in (-3, -1, 1, 2):
output_shape = (1, 1, computed_shape[2] + o, computed_shape[3] + o)
# expect an error
self.tcase_gi(image_shape, kernel_shape, output_shape,
(s, s), border_mode, True, True, (d, d), True)
for (i, k) in ((1, 1), (1, 2), (2, 1), (4, 2), (4, 3), (7, 3), (9, 5)):
for border_mode in ('valid', 'half', 'full', (0, 2)): for border_mode in ('valid', 'half', 'full', (0, 2)):
for s in (1, 2, 3): for (s, d) in ((1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (1, 3)):
for d in (1, 2, 3):
image_shape = (1, 1, i, i) image_shape = (1, 1, i, i)
kernel_shape = (1, 1, k, k) kernel_shape = (1, 1, k, k)
...@@ -512,20 +518,8 @@ class BaseTestConv2d(BaseTestConv): ...@@ -512,20 +518,8 @@ class BaseTestConv2d(BaseTestConv):
computed_shape = get_conv_output_shape( computed_shape = get_conv_output_shape(
image_shape, kernel_shape, border_mode, (s, s), (d, d)) image_shape, kernel_shape, border_mode, (s, s), (d, d))
# outputs that are too large or too small should be rejected yield (run_for_output_offsets,
for o in (-3, -2, -1, 1, 2, 3): image_shape, kernel_shape, s, border_mode, d)
output_shape = (1, 1, computed_shape[2] + o, computed_shape[3] + o)
# expect an error
yield (self.tcase_gi,
image_shape,
kernel_shape,
output_shape,
(s, s),
border_mode,
True,
True,
(d, d),
True)
def run_fwd(self, inputs_shape, filters_shape, def run_fwd(self, inputs_shape, filters_shape,
conv_fn=conv.conv2d, conv_op=conv.AbstractConv2d, conv_fn=conv.conv2d, conv_op=conv.AbstractConv2d,
...@@ -862,11 +856,18 @@ class BaseTestConv3d(BaseTestConv): ...@@ -862,11 +856,18 @@ class BaseTestConv3d(BaseTestConv):
True) True)
def test_gradinput_impossible_output_shapes(self): def test_gradinput_impossible_output_shapes(self):
for i in range(1, 10): def run_for_output_offsets(image_shape, kernel_shape, s, border_mode, d):
for k in range(1, 5): # outputs that are too large or too small should be rejected
for o in (-3, -1, 1, 2):
output_shape = (1, 1, computed_shape[2] + o,
computed_shape[3] + o, computed_shape[4] + o)
# expect an error
self.tcase_gi(image_shape, kernel_shape, output_shape,
(s, s), border_mode, True, True, (d, d), True)
for (i, k) in ((1, 1), (1, 2), (2, 1), (4, 2), (4, 3), (7, 3), (9, 5)):
for border_mode in ('valid', 'half', 'full', (0, 2, 1)): for border_mode in ('valid', 'half', 'full', (0, 2, 1)):
for s in (1, 2, 3): for (s, d) in ((1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (1, 3)):
for d in (1, 2, 3):
image_shape = (1, 1, i, i, i) image_shape = (1, 1, i, i, i)
kernel_shape = (1, 1, k, k, k) kernel_shape = (1, 1, k, k, k)
...@@ -874,20 +875,8 @@ class BaseTestConv3d(BaseTestConv): ...@@ -874,20 +875,8 @@ class BaseTestConv3d(BaseTestConv):
computed_shape = get_conv_output_shape( computed_shape = get_conv_output_shape(
image_shape, kernel_shape, border_mode, (s, s, s), (d, d, d)) image_shape, kernel_shape, border_mode, (s, s, s), (d, d, d))
# outputs that are too large or too small should be rejected yield (run_for_output_offsets,
for o in (-3, -2, -1, 1, 2, 3): image_shape, kernel_shape, s, border_mode, d)
output_shape = (1, 1, computed_shape[2] + o,
computed_shape[3] + o, computed_shape[4] + o)
yield (self.tcase_gi,
image_shape,
kernel_shape,
output_shape,
(s, s, s),
border_mode,
True,
True,
(d, d, d),
True)
def run_fwd(self, inputs_shape, filters_shape, def run_fwd(self, inputs_shape, filters_shape,
conv_fn=conv.conv3d, conv_op=conv.AbstractConv3d, conv_fn=conv.conv3d, conv_op=conv.AbstractConv3d,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论