function_binary_xnor_convolution_2d.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:XNOR-Net 作者: rarilurelo 项目源码 文件源码
def backward_cpu(self, inputs, grad_outputs):
        x, W = inputs[:2]
        Wb = binarize_cpu(W)
        b = inputs[2] if len(inputs) == 3 else None
        gy = grad_outputs[0]
        h, w = x.shape[2:]

        gW = numpy.tensordot(gy, self.col, ((0, 2, 3), (0, 4, 5)))
        gcol = numpy.tensordot(Wb, gy, (0, 1))
        gcol = numpy.rollaxis(gcol, 3)
        gx = conv.col2im_cpu(gcol, self.sy, self.sx, self.ph, self.pw, h, w)

        if b is None:
            return gx, gW
        else:
            gb = gy.sum(axis=(0, 2, 3))
            return gx, gW, gb
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号