Пример #1
0
 def test_rand_affine(self, input_param, input_data, expected_val):
     g = RandAffine(**input_param)
     g.set_random_state(123)
     result = g(**input_data)
     if input_param.get("cache_grid", False):
         self.assertTrue(g._cached_grid is not None)
     assert_allclose(result, expected_val, rtol=_rtol, atol=1e-4)
Пример #2
0
 def test_rand_affine(self, input_param, input_data, expected_val):
     g = RandAffine(**input_param)
     g.set_random_state(123)
     result = g(**input_data)
     self.assertEqual(torch.is_tensor(result), torch.is_tensor(expected_val))
     if torch.is_tensor(result):
         np.testing.assert_allclose(result.cpu().numpy(), expected_val.cpu().numpy(), rtol=1e-4, atol=1e-4)
     else:
         np.testing.assert_allclose(result, expected_val, rtol=1e-4, atol=1e-4)
Пример #3
0
 def test_rand_affine(self, input_param, input_data, expected_val):
     g = RandAffine(**input_param)
     g.set_random_state(123)
     result = g(**input_data)
     if input_param.get("cache_grid", False):
         self.assertTrue(g._cached_grid is not None)
     self.assertEqual(isinstance(result, torch.Tensor),
                      isinstance(expected_val, torch.Tensor))
     if isinstance(result, torch.Tensor):
         np.testing.assert_allclose(result.cpu().numpy(),
                                    expected_val.cpu().numpy(),
                                    rtol=1e-4,
                                    atol=1e-4)
     else:
         np.testing.assert_allclose(result,
                                    expected_val,
                                    rtol=1e-4,
                                    atol=1e-4)