def check_backward(self, x_data, W_data, b_data, y_grad): xp = cuda.get_array_module(x_data) if not self.c_contiguous: x_data = xp.asfortranarray(x_data) W_data = xp.asfortranarray(W_data) y_grad = xp.asfortranarray(y_grad) self.assertFalse(x_data.flags.c_contiguous) self.assertFalse(W_data.flags.c_contiguous) self.assertFalse(y_grad.flags.c_contiguous) if b_data is not None: b = xp.empty((len(b_data) * 2, ), dtype=self.b.dtype) b[::2] = b_data b_data = b[::2] self.assertFalse(b_data.flags.c_contiguous) args = (x_data, W_data) if b_data is not None: args = args + (b_data, ) with chainer.using_config('use_cudnn', self.use_cudnn): with chainer.using_config('cudnn_deterministic', self.cudnn_deterministic): gradient_check.check_backward( deconvolution_2d.Deconvolution2DFunction( self.stride, self.pad, self.outsize), args, y_grad, **self.check_backward_options)
def check_backward(self, x_data, W_data, b_data, y_grad): xp = cuda.get_array_module(x_data) if not self.c_contiguous: x_data = xp.asfortranarray(x_data) W_data = xp.asfortranarray(W_data) y_grad = xp.asfortranarray(y_grad) self.assertFalse(x_data.flags.c_contiguous) self.assertFalse(W_data.flags.c_contiguous) self.assertFalse(y_grad.flags.c_contiguous) if b_data is not None: b = xp.empty((len(b_data) * 2, ), dtype=self.b.dtype) b[::2] = b_data b_data = b[::2] self.assertFalse(b_data.flags.c_contiguous) args = (x_data, W_data) if b_data is not None: args = args + (b_data, ) gradient_check.check_backward(deconvolution_2d.Deconvolution2DFunction( self.stride, self.pad, self.outsize, self.use_cudnn), args, y_grad, eps=1e-2)