add Upscal test
@@ -31,7 +31,7 @@ class TestResizeImagesForwardIdentity(unittest.TestCase):
self.check_forward(cuda.to_gpu(self.x), output_shape=self.in_shape[2:])
-class TestResizeImagesForwardScale(unittest.TestCase):
+class TestResizeImagesForwardDownScale(unittest.TestCase):
in_shape = (2, 2, 4, 4)
output_shape = (2, 2, 2, 2)
@@ -62,6 +62,38 @@ class TestResizeImagesForwardScale(unittest.TestCase):
cuda.to_gpu(self.x), output_shape=self.output_shape[2:])
+class TestResizeImagesForwardUpScale(unittest.TestCase):
+
+ in_shape = (1, 1, 2, 2)
+ output_shape = (1, 1, 3, 3)
+
+ def setUp(self):
+ self.x = numpy.zeros(self.in_shape, dtype=numpy.float32)
+ self.x[:, :, 0, 0] = 1
+ self.x[:, :, 1, 0] = 2
+ self.x[:, :, 0, 1] = 3
+ self.x[:, :, 1, 1] = 4
+
+ self.out = numpy.zeros(self.output_shape, dtype=numpy.float32)
+ self.out[0, 0, :, :] = numpy.array(
+ [[1., 2., 3.],
+ [1.5, 2.5, 3.5],
+ [2., 3., 4.]],
+ dtype=numpy.float32)
+
+ def check_forward(self, x, output_shape):
+ y = functions.resize_images(x, output_shape)
+ testing.assert_allclose(y.data, self.out)
+
+ def test_forward_cpu(self):
+ self.check_forward(self.x, output_shape=self.output_shape[2:])
+
+ @attr.gpu
+ def test_forward_gpu(self):
+ self.check_forward(
+ cuda.to_gpu(self.x), output_shape=self.output_shape[2:])
+
+
@testing.parameterize(*testing.product({
'in_shape': [(2, 3, 8, 6), (2, 1, 4, 6)],
'output_shape': [(10, 5), (3, 4)]
