def f(x, rois, roi_indices):
     return functions.roi_max_pooling_2d(
         x,
         rois,
         roi_indices,
         outsize=self.outsize,
         spatial_scale=self.spatial_scale)
Esempio n. 2
0
    def test_forward_cpu_gpu_equal(self):
        # cpu
        x_cpu = chainer.Variable(self.x)
        rois_cpu = chainer.Variable(self.rois)
        roi_indices_cpu = chainer.Variable(self.roi_indices)
        y_cpu = functions.roi_max_pooling_2d(
            x_cpu, rois_cpu, roi_indices_cpu, outsize=self.outsize,
            spatial_scale=self.spatial_scale)

        # gpu
        x_gpu = chainer.Variable(cuda.to_gpu(self.x))
        rois_gpu = chainer.Variable(cuda.to_gpu(self.rois))
        roi_indices_gpu = chainer.Variable(cuda.to_gpu(self.roi_indices))
        y_gpu = functions.roi_max_pooling_2d(
            x_gpu, rois_gpu, roi_indices_gpu, outsize=self.outsize,
            spatial_scale=self.spatial_scale)
        testing.assert_allclose(y_cpu.data, cuda.to_cpu(y_gpu.data))
Esempio n. 3
0
    def check_forward(self, x_data, roi_data, roi_index_data):
        x = chainer.Variable(x_data)
        rois = chainer.Variable(roi_data)
        roi_indices = chainer.Variable(roi_index_data)
        y = functions.roi_max_pooling_2d(
            x, rois, roi_indices, outsize=self.outsize,
            spatial_scale=self.spatial_scale)
        self.assertEqual(y.data.dtype, self.dtype)
        y_data = cuda.to_cpu(y.data)

        self.assertEqual(self.gy.shape, y_data.shape)
Esempio n. 4
0
 def f(x, rois, roi_indices):
     y = functions.roi_max_pooling_2d(x,
                                      rois,
                                      roi_indices,
                                      outsize=self.outsize,
                                      spatial_scale=self.spatial_scale)
     xp = cuda.get_array_module(y)
     # replace -inf with zero for gradient_check
     y = functions.where(xp.isinf(y.array),
                         xp.zeros(y.shape, dtype=y.dtype), y)
     return y
Esempio n. 5
0
    def test_forward_cpu_gpu_equal(self):
        # cpu
        x_cpu = chainer.Variable(self.x)
        rois_cpu = chainer.Variable(self.rois)
        roi_indices_cpu = chainer.Variable(self.roi_indices)
        y_cpu = functions.roi_max_pooling_2d(x_cpu,
                                             rois_cpu,
                                             roi_indices_cpu,
                                             outsize=self.outsize,
                                             spatial_scale=self.spatial_scale)

        # gpu
        x_gpu = chainer.Variable(cuda.to_gpu(self.x))
        rois_gpu = chainer.Variable(cuda.to_gpu(self.rois))
        roi_indices_gpu = chainer.Variable(cuda.to_gpu(self.roi_indices))
        y_gpu = functions.roi_max_pooling_2d(x_gpu,
                                             rois_gpu,
                                             roi_indices_gpu,
                                             outsize=self.outsize,
                                             spatial_scale=self.spatial_scale)
        testing.assert_allclose(y_cpu.data, cuda.to_cpu(y_gpu.data))
Esempio n. 6
0
    def check_forward(self, x_data, roi_data, roi_index_data):
        x = chainer.Variable(x_data)
        rois = chainer.Variable(roi_data)
        roi_indices = chainer.Variable(roi_index_data)
        y = functions.roi_max_pooling_2d(x,
                                         rois,
                                         roi_indices,
                                         outsize=self.outsize,
                                         spatial_scale=self.spatial_scale)
        self.assertEqual(y.data.dtype, self.dtype)
        y_data = cuda.to_cpu(y.data)

        self.assertEqual(self.gy.shape, y_data.shape)
Esempio n. 7
0
 def f(x, rois, roi_indices):
     return functions.roi_max_pooling_2d(
         x, rois, roi_indices, outsize=self.outsize,
         spatial_scale=self.spatial_scale)