def check_forward(self, y):
y = upsampling_2d.upsampling_2d(
self.pooled_y, self.p.indexes, ksize=(self.p.kh, self.p.kw),
stride=(self.p.sy, self.p.sx), pad=(self.p.ph, self.p.pw),
outsize=self.in_shape[2:], cover_all=self.p.cover_all)
if isinstance(y.data, numpy.ndarray):
y = conv.im2col_cpu(y.data, self.p.kh, self.p.kw,
self.p.sy, self.p.sx, self.p.ph, self.p.pw)
else:
y = conv.im2col_gpu(y.data, self.p.kh, self.p.kw,
self.p.sy, self.p.sx, self.p.ph, self.p.pw)
for i in numpy.ndindex(y.shape):
n, c, ky, kx, oy, ox = i
up_y = y[n, c, ky, kx, oy, ox]
if ky * y.shape[3] + kx == self.p.indexes[n, c, oy, ox]:
in_y = self.pooled_y.data[n, c, oy, ox]
testing.assert_allclose(in_y, up_y)
else:
testing.assert_allclose(up_y, 0)
test_upsampling_2d.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录