Beispiel #1
0
 def f(x, rois, roi_indices):
     return functions.roi_max_align_2d(
         x,
         rois,
         roi_indices,
         outsize=self.outsize,
         spatial_scale=self.spatial_scale,
         sampling_ratio=self.sampling_ratio)
Beispiel #2
0
 def f(x, rois, roi_indices):
     y = functions.roi_max_align_2d(
         x, rois, roi_indices, outsize=self.outsize,
         spatial_scale=self.spatial_scale,
         sampling_ratio=self.sampling_ratio)
     xp = chainer.backend.get_array_module(y)
     y = functions.where(
         xp.isinf(y.array), xp.zeros(y.shape, dtype=y.dtype), y)
     return y
 def f(x, rois, roi_indices):
     y = functions.roi_max_align_2d(
         x, rois, roi_indices, outsize=self.outsize,
         spatial_scale=self.spatial_scale,
         sampling_ratio=self.sampling_ratio)
     xp = cuda.get_array_module(y)
     y = functions.where(
         xp.isinf(y.array), xp.zeros(y.shape, dtype=y.dtype), y)
     return y
Beispiel #4
0
    def test_forward_cpu_gpu_equal(self):
        # cpu
        x_cpu = chainer.Variable(self.x)
        rois_cpu = chainer.Variable(self.rois)
        roi_index_cpu = chainer.Variable(self.roi_indices)
        y_cpu = functions.roi_max_align_2d(
            x_cpu, rois_cpu, roi_index_cpu,
            outsize=self.outsize, spatial_scale=self.spatial_scale,
            sampling_ratio=self.sampling_ratio,
        )

        # gpu
        x_gpu = chainer.Variable(cuda.to_gpu(self.x))
        rois_gpu = chainer.Variable(cuda.to_gpu(self.rois))
        roi_index_gpu = chainer.Variable(cuda.to_gpu(self.roi_indices))
        y_gpu = functions.roi_max_align_2d(
            x_gpu, rois_gpu, roi_index_gpu,
            outsize=self.outsize, spatial_scale=self.spatial_scale,
            sampling_ratio=self.sampling_ratio,
        )
        testing.assert_allclose(y_cpu.data, cuda.to_cpu(y_gpu.data))
    def test_forward_cpu_gpu_equal(self):
        # cpu
        x_cpu = chainer.Variable(self.x)
        rois_cpu = chainer.Variable(self.rois)
        roi_index_cpu = chainer.Variable(self.roi_indices)
        y_cpu = functions.roi_max_align_2d(
            x_cpu, rois_cpu, roi_index_cpu,
            outsize=self.outsize, spatial_scale=self.spatial_scale,
            sampling_ratio=self.sampling_ratio,
        )

        # gpu
        x_gpu = chainer.Variable(cuda.to_gpu(self.x))
        rois_gpu = chainer.Variable(cuda.to_gpu(self.rois))
        roi_index_gpu = chainer.Variable(cuda.to_gpu(self.roi_indices))
        y_gpu = functions.roi_max_align_2d(
            x_gpu, rois_gpu, roi_index_gpu,
            outsize=self.outsize, spatial_scale=self.spatial_scale,
            sampling_ratio=self.sampling_ratio,
        )
        testing.assert_allclose(y_cpu.data, cuda.to_cpu(y_gpu.data))
Beispiel #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_align_2d(
            x, rois, roi_indices, outsize=self.outsize,
            spatial_scale=self.spatial_scale,
            sampling_ratio=self.sampling_ratio,
        )
        self.assertEqual(y.data.dtype, numpy.float32)
        y_data = cuda.to_cpu(y.data)

        self.assertEqual(self.gy.shape, y_data.shape)
    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_align_2d(
            x, rois, roi_indices, outsize=self.outsize,
            spatial_scale=self.spatial_scale,
            sampling_ratio=self.sampling_ratio,
        )
        self.assertEqual(y.data.dtype, numpy.float32)
        y_data = cuda.to_cpu(y.data)

        self.assertEqual(self.gy.shape, y_data.shape)
 def f(x, rois, roi_indices):
     return functions.roi_max_align_2d(
         x, rois, roi_indices, outsize=self.outsize,
         spatial_scale=self.spatial_scale,
         sampling_ratio=self.sampling_ratio)