提交 3805e3b5 authored 作者: Vincent Michalski's avatar Vincent Michalski

applied fixes mentioned by Pascal L, abstractconv unit test passes without failure

上级 a41fc8b0
......@@ -81,7 +81,6 @@ class TestConv2d(unittest.TestCase):
filter_flip=filter_flip,
input_shape=imshp,
filter_shape=kshp)
self.assertTrue(hasattr(c.tag, 'trace'))
f_ref = theano.function([], c_ref, mode=mode)
f = theano.function([], c, mode)
......@@ -89,11 +88,13 @@ class TestConv2d(unittest.TestCase):
assert any([isinstance(n.op, target_op) for n
in f.maker.fgraph.toposort()])
self.assertTrue(hasattr(f.maker.fgraph.outputs[0].tag, 'trace'))
res_ref = numpy.array(f_ref())
res = numpy.array(f())
utt.assert_allclose(res_ref, res)
if verify_grad:
utt.verify_grad(conv.AbstractConv2d(border_mode="valid", imshp=imshp, kshp=kshp,
utt.verify_grad(conv.AbstractConv2d(border_mode="valid",
imshp=imshp, kshp=kshp,
subsample=subsample),
[inputs_val, filters_val],
mode=mode)
......@@ -125,7 +126,6 @@ class TestConv2d(unittest.TestCase):
filter_flip=filter_flip,
subsample=subsample,
imshp=imshp, kshp=kshp)
self.assertTrue(hasattr(c.tag, 'trace'))
c = c(inputs, output, filters_shape[-2:])
c_ref = ref(inputs, output,
filters_shape,
......@@ -133,6 +133,7 @@ class TestConv2d(unittest.TestCase):
subsample=subsample,
conv_mode=conv_mode)
f = theano.function([], c, mode)
self.assertTrue(hasattr(f.maker.fgraph.outputs[0].tag, 'trace'))
f_ref = theano.function([], c_ref, mode)
if target_op is not None:
......@@ -178,12 +179,12 @@ class TestConv2d(unittest.TestCase):
subsample=subsample,
filter_flip=filter_flip,
imshp=imshp, kshp=kshp)
self.assertTrue(hasattr(c.tag, 'trace'))
c = c(filters, output, inputs_shape[-2:])
c_ref = ref(filters, output, inputs_shape,
border_mode=border_mode, subsample=subsample,
conv_mode=conv_mode)
f = theano.function([], c, mode)
self.assertTrue(hasattr(f.maker.fgraph.outputs[0].tag, 'trace'))
f_ref = theano.function([], c_ref, mode)
if target_op is not None:
......
......@@ -94,6 +94,8 @@ def local_abstractconv_gradweight_gemm(node):
rval = CorrMM_gradWeights(border_mode=node.op.border_mode,
subsample=node.op.subsample)(img, topgrad, shape)
copy_stack_trace(node.outputs[0], rval)
# need to flip the kernel if necessary
if node.op.filter_flip:
rval = rval[:, :, ::-1, ::-1]
......@@ -181,6 +183,7 @@ def local_conv2d_gradweight_cpu(node):
shape[0], shape[1], 1,
shuffled_img.shape[4]),
dCdH=shuffled_topgrad)
copy_stack_trace(node.outputs[0], rval)
rval = theano.tensor.addbroadcast(rval, 3)
rval = rval.dimshuffle(0, 4, 1, 2)
......@@ -253,6 +256,8 @@ def local_conv2d_gradweight_cpu(node):
kshp_logical_top_aligned=kshp_logical_top_aligned,
direction_hint='bprop weights')
res = dw(img, filters)
copy_stack_trace(node.outputs[0], res)
if node.op.border_mode == 'valid':
res = res.dimshuffle((1, 0, 2, 3))
res = res[:, :, ::-1, ::-1]
......@@ -289,6 +294,7 @@ def local_conv2d_gradinputs_cpu(node):
d=(node.op.subsample[0], node.op.subsample[1], 1),
H=shuffled_topgrad,
RShape=(shape[0], shape[1], 1))
copy_stack_trace(node.outputs[0], rval)
rval = theano.tensor.addbroadcast(rval, 3)
rval = rval.dimshuffle(0, 4, 1, 2)
rval = theano.tensor.patternbroadcast(rval,
......@@ -343,6 +349,7 @@ def local_conv2d_gradinputs_cpu(node):
version=-1,
direction_hint='bprop inputs')
din = din(topgrad, filters)
copy_stack_trace(node.outputs[0], din)
din = theano.tensor.patternbroadcast(din, node.outputs[0].broadcastable)
copy_stack_trace(node.outputs[0], din)
return [din]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论