@combinations.generate(strategy_combinations())
def test_model_interleaved_eval_same_as_direct_eval(self, distribution):
    with self.cached_session():
        user_controlled_model = get_model()
        user_controlled_model.compile(gradient_descent.GradientDescentOptimizer(0.001), loss='mse', metrics=['mae', keras.metrics.CategoricalAccuracy()], distribute=distribution)
        interleaved_model = get_model()
        interleaved_model.set_weights(user_controlled_model.get_weights())
        interleaved_model.compile(gradient_descent.GradientDescentOptimizer(0.001), loss='mse', metrics=['mae', keras.metrics.CategoricalAccuracy()], distribute=distribution)
        dataset = get_dataset(distribution)
        interleaved_output = interleaved_model.fit(dataset, epochs=2, steps_per_epoch=2, verbose=1, validation_data=dataset, validation_steps=2, shuffle=False)
        user_controlled_output = []
        for _ in range(2):
            user_controlled_model.fit(dataset, epochs=1, steps_per_epoch=2, verbose=1, shuffle=False)
            user_controlled_output.append(user_controlled_model.evaluate(dataset, steps=2))
        self.assertEqual(interleaved_output.history['val_loss'], [x[0] for x in user_controlled_output])
        self.assertEqual(interleaved_output.history['val_mean_absolute_error'], [x[1] for x in user_controlled_output])
        self.assertEqual(interleaved_output.history['val_categorical_accuracy'], [x[2] for x in user_controlled_output])
@combinations.generate(strategy_combinations())
def test_model_interleaved_eval_same_as_direct_eval(self, distribution):
    with self.cached_session():
        user_controlled_model = get_model()
        user_controlled_model.compile(gradient_descent.GradientDescentOptimizer(0.001), loss='mse', metrics=['mae', keras.metrics.CategoricalAccuracy()], distribute=distribution)
        interleaved_model = get_model()
        interleaved_model.set_weights(user_controlled_model.get_weights())
        interleaved_model.compile(gradient_descent.GradientDescentOptimizer(0.001), loss='mse', metrics=['mae', keras.metrics.CategoricalAccuracy()], distribute=distribution)
        dataset = get_dataset(distribution)
        interleaved_output = interleaved_model.fit(dataset, epochs=2, steps_per_epoch=2, verbose=1, validation_data=dataset, validation_steps=2, shuffle=False)
        user_controlled_output = []
        for _ in range(2):
            user_controlled_model.fit(dataset, epochs=1, steps_per_epoch=2, verbose=1, shuffle=False)
            user_controlled_output.append(user_controlled_model.evaluate(dataset, steps=2))
        self.assertEqual(interleaved_output.history['val_loss'], [x[0] for x in user_controlled_output])
        self.assertEqual(interleaved_output.history['val_mean_absolute_error'], [x[1] for x in user_controlled_output])
        self.assertEqual(interleaved_output.history['val_categorical_accuracy'], [x[2] for x in user_controlled_output])