def test_resize3d_nearest_values(self): tensorflow_output = np.squeeze( resize_3d(self.tensorflow_array, (4, 4, 4), 'nearest').numpy()) torch_output = np.squeeze( resize_3d(self.pytorch_array, (4, 4, 4), 'nearest').numpy()) print(tensorflow_output) np.testing.assert_array_equal(tensorflow_output[0, 0, :], [0, 0, 1, 1]) np.testing.assert_array_equal(torch_output[0, 0, :], [0, 0, 1, 1])
def test_resize3d_tf(self): np.testing.assert_equal( resize_3d(self.tensorflow_array, (4, 4, 4)).numpy().shape, (1, 4, 4, 4, 1))
def test_resize3d_torch(self): image_shape = resize_3d(self.pytorch_array, (4, 4, 4)).numpy().shape np.testing.assert_equal(image_shape, (1, 1, 4, 4, 4))
def test_resize3d_bicubic(self): with self.assertRaises(AssertionError): _ = np.squeeze( resize_3d(self.tensorflow_array, (4, 4, 4), 'bicubic').numpy())
def test_resize3d_nearest(self): tensorflow_output = np.squeeze( resize_3d(self.tensorflow_array, (4, 4, 4), 'nearest').numpy()) torch_output = np.squeeze( resize_3d(self.pytorch_array, (4, 4, 4), 'nearest').numpy()) np.testing.assert_array_almost_equal(tensorflow_output, torch_output)
def forward(self, data: List[Tensor], state: Dict[str, Any]) -> Union[Tensor, List[Tensor]]: return [ resize_3d(elem, self.output_shape, self.resize_mode) for elem in data ]