Beispiel #1
0
 def test_no_flip(self):
     a = np.array([[0, 1], [2, 3]])
     flip_layer = RandomFlipLayer(flip_axes=[0], flip_probability=0)
     flip_layer.randomise(spatial_rank=2)
     transformed_a = flip_layer._apply_transformation(a)
     with self.cached_session() as sess:
         self.assertTrue(np.array_equal(transformed_a, a))
Beispiel #2
0
 def test_no_flip(self):
     a = np.array([[0, 1], [2, 3]])
     flip_layer = RandomFlipLayer(flip_axes=[0], flip_probability=0)
     flip_layer.randomise(spatial_rank=2)
     transformed_a = flip_layer._apply_transformation(a)
     with self.test_session() as sess:
         self.assertTrue(np.array_equal(transformed_a, a))
Beispiel #3
0
 def test_3d_flip(self):
     a = np.zeros(24).reshape(2, 3, 4)
     a[0, 0, 0] = 1
     flip_layer = RandomFlipLayer(flip_axes=[0, 1, 2], flip_probability=1)
     flip_layer.randomise(spatial_rank=3)
     transformed_a = flip_layer._apply_transformation(a)
     with self.cached_session() as sess:
         # cube of zeros with opposite corner as 1
         expected_a = np.zeros(24).reshape(2, 3, 4)
         expected_a[-1, -1, -1] = 1
         self.assertTrue(np.array_equal(transformed_a, expected_a))
Beispiel #4
0
 def test_3d_flip(self):
     a = np.zeros(24).reshape(2, 3, 4)
     a[0, 0, 0] = 1
     flip_layer = RandomFlipLayer(flip_axes=[0, 1, 2], flip_probability=1)
     flip_layer.randomise(spatial_rank=3)
     transformed_a = flip_layer._apply_transformation(a)
     with self.test_session() as sess:
         # cube of zeros with opposite corner as 1
         expected_a = np.zeros(24).reshape(2, 3, 4)
         expected_a[-1, -1, -1] = 1
         self.assertTrue(np.array_equal(transformed_a, expected_a))