提交 e8e1dcef authored 作者: Vikram's avatar Vikram

Modified gradinput test. Changed position of %(fail)

上级 f39431ff
...@@ -449,9 +449,9 @@ class BaseCorrMM(gof.OpenMPOp): ...@@ -449,9 +449,9 @@ class BaseCorrMM(gof.OpenMPOp):
(long int)out_dim[3], (long int)out_dim[4], (long int)out_dim[5], (long int)out_dim[3], (long int)out_dim[4], (long int)out_dim[5],
(long int)PyArray_DIMS(top)[0], (long int)PyArray_DIMS(top)[1], (long int)PyArray_DIMS(top)[0], (long int)PyArray_DIMS(top)[1],
(long int)PyArray_DIMS(top)[2], (long int)PyArray_DIMS(top)[3]); (long int)PyArray_DIMS(top)[2], (long int)PyArray_DIMS(top)[3]);
}
%(fail)s %(fail)s
} }
}
else { else {
if (out_dim[0] < 0 || out_dim[1] < 0 || out_dim[2] <= 0 || out_dim[3] <= 0) if (out_dim[0] < 0 || out_dim[1] < 0 || out_dim[2] <= 0 || out_dim[3] <= 0)
{ {
......
...@@ -1860,10 +1860,8 @@ class TestUnsharedConv(unittest.TestCase): ...@@ -1860,10 +1860,8 @@ class TestUnsharedConv(unittest.TestCase):
self.border_mode, self.subsample, self.num_groups, self.border_mode, self.subsample, self.num_groups,
self.verify_flags): self.verify_flags):
single_kshp = kshp[:1] + kshp[3:] single_kshp = kshp[:1] + kshp[3:]
single_kern = np.random.random(single_kshp).astype(theano.config.floatX)
kern = single_kern.reshape((kshp[:1] + (1, 1) + kshp[3:]))
kern = np.tile(kern, (1, kshp[1], kshp[2], 1, 1, 1))
kern = np.random.random(kshp).astype(theano.config.floatX)
top = np.random.random(topshp).astype(theano.config.floatX) top = np.random.random(topshp).astype(theano.config.floatX)
unshared_conv_op = self.conv2d_gradi(border_mode=mode, subsample=sub, unshared_conv_op = self.conv2d_gradi(border_mode=mode, subsample=sub,
...@@ -1880,7 +1878,15 @@ class TestUnsharedConv(unittest.TestCase): ...@@ -1880,7 +1878,15 @@ class TestUnsharedConv(unittest.TestCase):
num_groups=groups, unshared=False) num_groups=groups, unshared=False)
ref_out_sym = ref_conv_op(ref_kern_sym, top_sym, tensor.as_tensor_variable(imshp[-2:])) ref_out_sym = ref_conv_op(ref_kern_sym, top_sym, tensor.as_tensor_variable(imshp[-2:]))
ref_func = theano.function([ref_kern_sym, top_sym], ref_out_sym, mode=self.mode) ref_func = theano.function([ref_kern_sym, top_sym], ref_out_sym, mode=self.mode)
ref_output = ref_func(single_kern, top)
ref_output = np.zeros(imshp)
for i in range(0, topshp[2]):
for j in range(0, topshp[3]):
single_kern = kern[:, i, j, ...].reshape(single_kshp)
top_single = np.zeros_like(top)
top_single[:, :, i, j] = top[:, :, i, j]
ref_output += ref_func(single_kern, top_single)
utt.assert_allclose(ref_output, unshared_output) utt.assert_allclose(ref_output, unshared_output)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论