コード例 #1
0
    def check_backward(self, x_data, W_data, b_data, y_grad):
        args = (x_data, W_data)
        if b_data is not None:
            args = args + (b_data, )

        gradient_check.check_backward(
            depthwise_convolution_2d.DepthwiseConvolution2D(
                self.stride, self.pad), args, y_grad,
            **self.check_backward_options)
コード例 #2
0
    def check_forward(self, x_data, W_data, b_data):
        args1 = (x_data, W_data)
        args2 = (x_data, W_data)
        if b_data is not None:
            args1 = args1 + (b_data, )
            b_data = sum(numpy.split(b_data, W_data.shape[1]))
            args2 = args2 + (b_data, )

        f1 = depthwise_convolution_2d.DepthwiseConvolution2D(
            self.stride, self.pad)
        y1 = f1(*args1)
        arys = numpy.split(y1.data, self.W.shape[1], axis=1)
        y1 = sum(arys)

        f2 = convolution_2d.Convolution2DFunction(self.stride, self.pad)
        y2 = f2.apply(args2)[0].data
        testing.assert_allclose(y1, y2, **self.check_forward_options)