* fix for 3D input tensors in ConvOp's grad function

* typo in c_code (comparing type instead of type.dtype) * added test case for 3D input tensor in test_ConvOpGrad
上级 6ca33324
......@@ -119,8 +119,8 @@ class ConvOp(Op):
####### Determine gradient on kernels ########
mode = self.out_mode
if inputs.ndim == 3:
# TODO
img = tensor.shape_padleft(inputs,1)
inputs = tensor.shape_padleft(inputs,1)
print 'self.imshp = ', self.imshp
img = tensor.DimShuffle(inputs.broadcastable, (1,0,2,3))(inputs)
imshp = N.hstack((self.bsize, self.imshp[1:]))
......@@ -170,7 +170,7 @@ class ConvOp(Op):
using namespace std;
"""
def c_code(self, node, name, (img2d, filtersflipped), (z, ), sub):
if node.inputs[0].type != node.inputs[1].type:
if node.inputs[0].type.dtype != node.inputs[1].type.dtype:
raise NotImplementedError()
code="""
int mode=-1,typenum;
......
......@@ -309,8 +309,9 @@ class TestConvOp(unittest.TestCase):
kerns = T.dmatrix('kerns')
for mode in 'valid', 'full':
for imshp in (2,5,5),(2,10,10): # (12,10), (3,12,11):
for imshp in (5,5),(2,5,5),(2,10,10): # (12,10), (3,12,11):
visdim = 1 if len(imshp)!=3 else imshp[0]
print 'visdim = ', visdim
for kshp in (3,3),:# (6,7):
imgvals = N.random.random(N.hstack((bsize,imshp)))
print 'imgvals.shape = ', imgvals.shape
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论