def test_calling_with_unsupported_predefined_callbacks(self):
    with self.cached_session():
        model = get_model()
        optimizer = gradient_descent.GradientDescentOptimizer(0.001)
        loss = 'mse'
        metrics = ['mae']
        strategy = mirrored_strategy.MirroredStrategy(['/device:GPU:1', '/device:GPU:0'])
        model.compile(optimizer, loss, metrics=metrics, distribute=strategy)
        dataset = get_dataset(strategy)

        def schedule(_):
            return 0.001
        with self.assertRaisesRegexp(ValueError, 'LearningRateScheduler callback is not supported with DistributionStrategy.'):
            model.fit(dataset, epochs=1, steps_per_epoch=2, verbose=0, callbacks=[keras.callbacks.LearningRateScheduler(schedule)])
        with self.assertRaisesRegexp(ValueError, 'ReduceLROnPlateau callback is not supported with DistributionStrategy.'):
            model.fit(dataset, epochs=1, steps_per_epoch=2, verbose=0, callbacks=[keras.callbacks.ReduceLROnPlateau()])
        with self.assertRaisesRegexp(ValueError, 'histogram_freq in the TensorBoard callback is not supported when using DistributionStrategy.'):
            model.fit(dataset, epochs=1, steps_per_epoch=2, verbose=0, callbacks=[keras.callbacks.TensorBoard(histogram_freq=10)])
def test_calling_with_unsupported_predefined_callbacks(self):
    with self.cached_session():
        model = get_model()
        optimizer = gradient_descent.GradientDescentOptimizer(0.001)
        loss = 'mse'
        metrics = ['mae']
        strategy = mirrored_strategy.MirroredStrategy(['/device:GPU:1', '/device:GPU:0'])
        model.compile(optimizer, loss, metrics=metrics, distribute=strategy)
        dataset = get_dataset(strategy)

        def schedule(_):
            return 0.001
        with self.assertRaisesRegexp(ValueError, 'LearningRateScheduler callback is not supported with DistributionStrategy.'):
            model.fit(dataset, epochs=1, steps_per_epoch=2, verbose=0, callbacks=[keras.callbacks.LearningRateScheduler(schedule)])
        with self.assertRaisesRegexp(ValueError, 'ReduceLROnPlateau callback is not supported with DistributionStrategy.'):
            model.fit(dataset, epochs=1, steps_per_epoch=2, verbose=0, callbacks=[keras.callbacks.ReduceLROnPlateau()])
        with self.assertRaisesRegexp(ValueError, 'histogram_freq in the TensorBoard callback is not supported when using DistributionStrategy.'):
            model.fit(dataset, epochs=1, steps_per_epoch=2, verbose=0, callbacks=[keras.callbacks.TensorBoard(histogram_freq=10)])