def forward_cpu(self, inputs):
x, W = inputs[:2]
b = inputs[2] if len(inputs) == 3 else None
kh, kw = W.shape[2:]
self.col = conv.im2col_cpu(
x, kh, kw, self.sy, self.sx, self.ph, self.pw,
cover_all=self.cover_all)
Xb = numpy.where(self.col>0,1,self.col).astype(x.dtype, copy=False)
Xb = numpy.where(self.col<0,-1,Xb).astype(x.dtype, copy=False)
Wb = numpy.where(W>=0,1,-1).astype(W.dtype, copy=False)
y = numpy.tensordot(
Xb, Wb, ((1, 2, 3), (1, 2, 3))).astype(x.dtype, copy=False)
if b is not None:
y += b
return numpy.rollaxis(y, 3, 1),
评论列表
文章目录