def test_crop_idempotent(self): crop_0_lt = ops.random_crop( self.original_lt, {'probs': 3, 'channel': 2}, seed=0) crop_1_lt = ops.random_crop(crop_0_lt, {'probs': 3, 'channel': 2}, seed=1) self.assertLabeledTensorsEqual(crop_0_lt, crop_1_lt)
def test_different_seeds(self): crop_0_lt = ops.random_crop( self.original_lt, {'probs': 3, 'channel': 2}, seed=0) crop_1_lt = ops.random_crop( self.original_lt, {'probs': 3, 'channel': 2}, seed=1) self.assertEqual(crop_0_lt.axes, crop_1_lt.axes) [crop_0, crop_1] = self.eval([crop_0_lt.tensor, crop_1_lt.tensor]) self.assertFalse((crop_0 == crop_1).all())
def test_double(self): crop_lt = ops.random_crop(self.original_lt, {'probs': 3, 'channel': 2}) self.assertEqual( core.Axes( [self.a0, ('channel', 2), self.a2_resolved, ('probs', 3)]), crop_lt.axes)
def test_invalid_input(self): with self.assertRaises(ValueError): ops.random_crop(self.original_lt, {'foobar': 2})
def test_size1(self): crop_lt = ops.random_crop(self.original_lt, {'probs': 1}) self.assertEqual( core.Axes([self.a0, self.a1, self.a2_resolved, ('probs', 1)]), crop_lt.axes)
def test_name(self): crop_lt = ops.random_crop(self.original_lt, {'probs': 3}) self.assertIn('lt_random_crop', crop_lt.name)
def test_double(self): crop_lt = ops.random_crop(self.original_lt, {'probs': 3, 'channel': 2}) self.assertEqual( core.Axes([self.a0, ('channel', 2), self.a2_resolved, ('probs', 3)]), crop_lt.axes)