提交 1ad6fae7 authored 作者: Cesar Laurent's avatar Cesar Laurent

Adapted the new DownsampleFactorMaxGradGrad gradient.

上级 96a96b6f
......@@ -1089,13 +1089,18 @@ class DownsampleFactorMaxGradGrad(OpenMPOp):
return [in_shapes[1]]
def grad(self, inp, grads):
x, maxout, ggx = inp
x, maxout, ggx, ws, stride, pad = inp
gz, = grads
return [theano.tensor.zeros_like(x),
theano.tensor.zeros_like(maxout),
MaxPoolGrad(
self.ds, ignore_border=self.ignore_border,
st=self.st, padding=self.padding)(x, maxout, gz)]
MaxPoolGrad(ignore_border=self.ignore_border)(x, maxout, gz,
ws, stride, pad),
DisconnectedType()(),
DisconnectedType()(),
DisconnectedType()()]
def connection_pattern(self, node):
return [[1], [1], [1], [0], [0], [0]]
def c_code(self, node, name, inp, out, sub):
if self.mode != 'max':
......
......@@ -644,16 +644,12 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
paddingsize = paddingsizes[i]
def mp(input1, input2):
pooled_out = Pool(
maxpoolsize, ignore_border=True,
st=stridesize,
padding=paddingsize,
)(input1)
out = DownsampleFactorMaxGradGrad(
ds=maxpoolsize,
ignore_border=True,
st=stridesize,
padding=paddingsize)(input1, pooled_out, input2)
op1 = Pool(ignore_border=True)
pooled_out = op1(input1, maxpoolsize, stride=stridesize,
pad=paddingsize)
op2 = DownsampleFactorMaxGradGrad(ignore_border=True)
out = op2(input1, pooled_out, input2, ws=maxpoolsize,
stride=stridesize, pad=paddingsize)
return out
utt.verify_grad(mp, [imval1, imval2], rng=rng)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论