def test_calculating_batch_params(self):
    with self.cached_session():
        inputs = np.zeros((64, 3), dtype=np.float32)
        strategy = mirrored_strategy.MirroredStrategy(['/device:GPU:0', '/device:CPU:0', '/device:GPU:1'])
        with self.assertRaisesRegexp(ValueError, 'Please specify a batch_size that is smaller than'):
            distributed_training_utils.get_input_batch_params(inputs, 128, strategy)
        with self.assertRaisesRegexp(ValueError, 'is smaller than the number of replicas'):
            distributed_training_utils.get_input_batch_params(inputs, 32, strategy)
        strategy = mirrored_strategy.MirroredStrategy(['/device:GPU:0', '/device:CPU:0'])
        steps = distributed_training_utils.get_input_batch_params(inputs, 32, strategy)
        self.assertEqual(steps, 1)
        steps = distributed_training_utils.get_input_batch_params(inputs, 16, strategy)
        self.assertEqual(steps, 2)
def test_calculating_batch_params(self):
    with self.cached_session():
        inputs = np.zeros((64, 3), dtype=np.float32)
        strategy = mirrored_strategy.MirroredStrategy(['/device:GPU:0', '/device:CPU:0', '/device:GPU:1'])
        with self.assertRaisesRegexp(ValueError, 'Please specify a batch_size that is smaller than'):
            distributed_training_utils.get_input_batch_params(inputs, 128, strategy)
        with self.assertRaisesRegexp(ValueError, 'is smaller than the number of replicas'):
            distributed_training_utils.get_input_batch_params(inputs, 32, strategy)
        strategy = mirrored_strategy.MirroredStrategy(['/device:GPU:0', '/device:CPU:0'])
        steps = distributed_training_utils.get_input_batch_params(inputs, 32, strategy)
        self.assertEqual(steps, 1)
        steps = distributed_training_utils.get_input_batch_params(inputs, 16, strategy)
        self.assertEqual(steps, 2)