def check_forward(self, x, offset, W, b, stride, pad): with chainer.using_config('use_cudnn', self.use_cudnn): x = chainer.Variable(x) offset = chainer.Variable(offset) out = deformable_convolution_2d_sampler(x, offset, W, b, stride, pad).data expeceted = convolution_2d(x, W, b, stride, pad).data testing.assert_allclose(out, expeceted)
def check_forward(self, x, offset, W, b, stride, pad): with chainer.using_config('use_cudnn', self.use_cudnn): x = chainer.Variable(x) offset = chainer.Variable(offset) out = deformable_convolution_2d_sampler( x, offset, W, b, stride, pad).data expeceted = convolution_2d( x, W, b, stride, pad).data testing.assert_allclose(out, expeceted)
def forward(self, x, offset): if self.W.array is None: self._initialize_params(x.shape[1]) pad_width = [(0, 0), (0, 0)] + list(map(lambda x: (x, x), self.pad)) x = F.pad(x, pad_width, self.pad_mode) return F.deformable_convolution_2d_sampler(x, offset, self.W, self.b, self.stride, 0)
def check_forward(self, x, offset, W, b, stride, pad): with chainer.using_config('use_cudnn', self.use_cudnn): _, _, h, w = x.shape _, _, kh, kw = W.shape offset[:, :kh * kw] = -1 * stride[1] offset[:, kh * kw:] = 1 * stride[0] x = chainer.Variable(x) offset = chainer.Variable(offset) out = deformable_convolution_2d_sampler(x, offset, W, b, stride, pad).data pad = (pad[0] + 1 * stride[0], pad[1] + 1 * stride[1]) expeceted = convolution_2d(x, W, b, stride, pad).data expeceted = expeceted[:, :, 2:, :-2] testing.assert_allclose(out, expeceted)
def check_forward(self, x, offset, W, b, stride, pad): with chainer.using_config('use_cudnn', self.use_cudnn): _, _, h, w = x.shape _, _, kh, kw = W.shape offset[:, :kh * kw] = -1 * stride[1] offset[:, kh * kw:] = 1 * stride[0] x = chainer.Variable(x) offset = chainer.Variable(offset) out = deformable_convolution_2d_sampler( x, offset, W, b, stride, pad).data pad = (pad[0] + 1 * stride[0], pad[1] + 1 * stride[1]) expeceted = convolution_2d( x, W, b, stride, pad).data expeceted = expeceted[:, :, 2:, :-2] testing.assert_allclose(out, expeceted)
def forward(self, x, offset): if self.W.array is None: self._initialize_params(x.shape[1]) return deformable_convolution_2d_sampler( x, offset, self.W, self.b, self.stride, self.pad)
def __call__(self, x, offset): if self.W.data is None: self._initialize_params(x.shape[1]) return deformable_convolution_2d_sampler( x, offset, self.W, self.b, self.stride, self.pad)