def setUp(self):
        # Spacial pyramid pooling uses max pooling in its implementation.
        # To avoid instability of numerical gradient, use enough different
        # values.
        shape = (self.n, self.c, self.h, self.w)
        self.x = pooling_nd_helper.shuffled_linspace(shape, self.dtype)

        self.one = numpy.ones(
            (self.n, self.c, self.h, self.w)).astype(self.dtype)
        self.gy = numpy.random.uniform(
            -1, 1, (self.n, self.output_dim, 1, 1)).astype(self.dtype)
        self.ggx = numpy.random.uniform(-1, 1, shape).astype(self.dtype)
예제 #2
0
    def setUp(self):
        self.N = 2
        self.n_channels = 3
        inh, inw = self.insize
        self.x = pooling_nd_helper.shuffled_linspace(
            (self.N, self.n_channels, inh, inw), self.dtype)

        outh, outw = self.outsize or self.expected_outsize
        self.gy = numpy.random.uniform(
            -1, 1, (self.N, self.n_channels, outh, outw)).astype(self.dtype)
        self.check_backward_options = {'atol': 1e-4, 'rtol': 1e-3}
        self.check_double_backward_options = {}
        if self.dtype == numpy.float16:
            self.check_backward_options = {'atol': 2e-3, 'rtol': 2e-2}
            self.check_double_backward_options = {'atol': 3e-3, 'rtol': 3e-2}
        self.ggx = numpy.random.uniform(-1, 1, self.x.shape).astype(self.dtype)
예제 #3
0
 def setUp(self):
     N = 3
     n_channels = 3
     self.x = pooling_nd_helper.shuffled_linspace(
         (N, n_channels, 12, 8), numpy.float32)
     self.rois = numpy.array([
         [1, 1, 6, 6],
         [6, 2, 7, 11],
         [3, 1, 5, 10],
         [3, 3, 3, 3],
         [1.1, 2.2, 3.3, 4.4],
     ], dtype=numpy.float32)
     self.roi_indices = numpy.array([0, 2, 1, 0, 2], dtype=numpy.int32)
     n_rois = self.rois.shape[0]
     outsize = _pair(self.outsize)
     self.gy = numpy.random.uniform(
         -1, 1, (n_rois, n_channels,
                 outsize[0], outsize[1])).astype(numpy.float32)
     self.check_backward_options = {'atol': 5e-4, 'rtol': 5e-3}
 def setUp(self):
     N = 3
     n_channels = 3
     self.x = pooling_nd_helper.shuffled_linspace(
         (N, n_channels, 12, 8), self.dtype)
     self.rois = numpy.array([
         [1, 1, 7, 7],
         [2, 6, 12, 8],
         [1, 3, 11, 6],
         [3, 3, 4, 4]
     ], dtype=self.dtype)
     self.roi_indices = numpy.array([0, 2, 1, 0], dtype=numpy.int32)
     n_rois = self.rois.shape[0]
     outsize = _pair(self.outsize)
     self.gy = numpy.random.uniform(
         -1, 1, (n_rois, n_channels,
                 outsize[0], outsize[1])).astype(self.dtype)
     if self.dtype == numpy.float16:
         self.check_backward_options = {
             'dtype': numpy.float64, 'atol': 1e-2, 'rtol': 1e-2}
     else:
         self.check_backward_options = {'atol': 1e-3, 'rtol': 1e-2}
예제 #5
0
 def setUp(self):
     N = 3
     n_channels = 3
     self.x = pooling_nd_helper.shuffled_linspace((N, n_channels, 12, 8),
                                                  self.dtype)
     self.rois = numpy.array([[0, 1, 1, 6, 6], [2, 6, 2, 7, 11],
                              [1, 3, 1, 5, 10], [0, 3, 3, 3, 3]],
                             dtype=self.dtype)
     n_rois = self.rois.shape[0]
     self.outh, self.outw = 5, 7
     self.spatial_scale = 0.6
     self.gy = numpy.random.uniform(
         -1, 1,
         (n_rois, n_channels, self.outh, self.outw)).astype(self.dtype)
     if self.dtype == numpy.float16:
         self.check_backward_options = {
             'dtype': numpy.float64,
             'atol': 1e-2,
             'rtol': 1e-2
         }
     else:
         self.check_backward_options = {'atol': 1e-3, 'rtol': 1e-2}
예제 #6
0
 def generate_inputs(self):
     return pooling_nd_helper.shuffled_linspace((2, 3, 4, 3), self.dtype),
예제 #7
0
 def setUp(self):
     self.x = pooling_nd_helper.shuffled_linspace((2, 3, 4, 4),
                                                  numpy.float32)