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

Reduce number of inconsistent-shape tests.

上级 c655fb73
...@@ -500,32 +500,26 @@ class BaseTestConv2d(BaseTestConv): ...@@ -500,32 +500,26 @@ 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 border_mode in ('valid', 'half', 'full', (0, 2)): for o in (-3, -1, 1, 2):
for s in (1, 2, 3): output_shape = (1, 1, computed_shape[2] + o, computed_shape[3] + o)
for d in (1, 2, 3): # expect an error
image_shape = (1, 1, i, i) self.tcase_gi(image_shape, kernel_shape, output_shape,
kernel_shape = (1, 1, k, k) (s, s), border_mode, True, True, (d, d), True)
# compute the output that these inputs and parameters would produce for (i, k) in ((1, 1), (1, 2), (2, 1), (4, 2), (4, 3), (7, 3), (9, 5)):
computed_shape = get_conv_output_shape( for border_mode in ('valid', 'half', 'full', (0, 2)):
image_shape, kernel_shape, border_mode, (s, s), (d, d)) for (s, d) in ((1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (1, 3)):
image_shape = (1, 1, i, i)
# outputs that are too large or too small should be rejected kernel_shape = (1, 1, k, k)
for o in (-3, -2, -1, 1, 2, 3):
output_shape = (1, 1, computed_shape[2] + o, computed_shape[3] + o) # compute the output that these inputs and parameters would produce
# expect an error computed_shape = get_conv_output_shape(
yield (self.tcase_gi, image_shape, kernel_shape, border_mode, (s, s), (d, d))
image_shape,
kernel_shape, yield (run_for_output_offsets,
output_shape, image_shape, kernel_shape, s, border_mode, d)
(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,32 +856,27 @@ class BaseTestConv3d(BaseTestConv): ...@@ -862,32 +856,27 @@ 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 border_mode in ('valid', 'half', 'full', (0, 2, 1)): for o in (-3, -1, 1, 2):
for s in (1, 2, 3): output_shape = (1, 1, computed_shape[2] + o,
for d in (1, 2, 3): computed_shape[3] + o, computed_shape[4] + o)
image_shape = (1, 1, i, i, i) # expect an error
kernel_shape = (1, 1, k, k, k) self.tcase_gi(image_shape, kernel_shape, output_shape,
(s, s), border_mode, True, True, (d, d), True)
# compute the output that these inputs and parameters would produce
computed_shape = get_conv_output_shape( for (i, k) in ((1, 1), (1, 2), (2, 1), (4, 2), (4, 3), (7, 3), (9, 5)):
image_shape, kernel_shape, border_mode, (s, s, s), (d, d, d)) for border_mode in ('valid', 'half', 'full', (0, 2, 1)):
for (s, d) in ((1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (1, 3)):
# outputs that are too large or too small should be rejected image_shape = (1, 1, i, i, i)
for o in (-3, -2, -1, 1, 2, 3): kernel_shape = (1, 1, k, k, k)
output_shape = (1, 1, computed_shape[2] + o,
computed_shape[3] + o, computed_shape[4] + o) # compute the output that these inputs and parameters would produce
yield (self.tcase_gi, computed_shape = get_conv_output_shape(
image_shape, image_shape, kernel_shape, border_mode, (s, s, s), (d, d, d))
kernel_shape,
output_shape, yield (run_for_output_offsets,
(s, s, s), image_shape, kernel_shape, s, border_mode, d)
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论