def backward_cpu(self, inputs, grad_outputs):
x, V, g = inputs[:3]
b = inputs[3] if len(inputs) == 4 else None
if b is None:
gb = None
gx, gW = super(Deconvolution2DFunction, self).backward_cpu((x, self.W), grad_outputs)
else:
gx, gW, gb = super(Deconvolution2DFunction, self).backward_cpu((x, self.W, b), grad_outputs)
xp = cuda.get_array_module(x)
gg = xp.sum(gW * self.normalizedV, axis=(0, 2, 3), keepdims=True).astype(g.dtype, copy=False)
gV = g * (gW - gg * self.normalizedV) / self.normV
gV = gV.astype(V.dtype, copy=False)
if b is None:
return gx, gV, gg
else:
return gx, gV, gg, gb
评论列表
文章目录