message: Add test for using datasets for multi-input multi-output datasets.
diff: @@ -225,6 +225,66 @@ class TestTrainingWithDataset(keras_parameterized.TestCase):
  'the `steps` argument'):
  model.predict(dataset, verbose=0)
  + # TODO(b/123531973): Include tests using dataset_v1.
  + @keras_parameterized.run_with_all_model_types(exclude_models='sequential')
  + @keras_parameterized.run_all_keras_modes(always_skip_v1=True)
  + def test_training_and_eval_methods_on_multi_input_output_dataset(self):
  + input_a = keras.layers.Input(shape=(3,), name='input_1')
  + input_b = keras.layers.Input(shape=(3,), name='input_2')
  + dense = keras.layers.Dense(4, name='dense')
  + dropout = keras.layers.Dropout(0.5, name='dropout')
  + branch_a = [input_a, dense]
  + branch_b = [input_b, dense, dropout]
  +
  + model = testing_utils.get_multi_io_model(branch_a, branch_b)
  + model.compile(
  + optimizer='rmsprop',
  + loss='mse',
  + run_eagerly=testing_utils.should_run_eagerly())
  +
  + input_a_np = np.random.random((10, 3)).astype(dtype=np.float32)
  + input_b_np = np.random.random((10, 3)).astype(dtype=np.float32)
  + output_d_np = np.random.random((10, 4)).astype(dtype=np.float32)
  + output_e_np = np.random.random((10, 4)).astype(dtype=np.float32)
  +
  + # Test with tuples
  + dataset_tuple = dataset_ops.Dataset.from_tensor_slices((
  + (input_a_np, input_b_np), (output_d_np, output_e_np)))
  + dataset_tuple = dataset_tuple.repeat(100)
  + dataset_tuple = dataset_tuple.batch(10)
  +
  + model.fit(dataset_tuple, epochs=1, steps_per_epoch=2, verbose=1)
  + model.evaluate(dataset_tuple, steps=2, verbose=1)
  +
  + predict_dataset_tuple = dataset_ops.Dataset.from_tensor_slices(
  + (input_a_np, input_b_np))
  + # TODO(b/123360757): Remove below assertion once predict() supports
  + # muti-input datasets.
  + with self.assertRaisesRegexp(ValueError,
  + 'Error when checking model input'):
  + model.predict(predict_dataset_tuple, steps=1)
  +
  + # Test with dict
  + input_dict = {'input_1': input_a_np, 'input_2': input_b_np}
  + if testing_utils.get_model_type() == 'subclass':
  + output_dict = {'output_1': output_d_np, 'output_2': output_e_np}
  + else:
  + output_dict = {'dense': output_d_np, 'dropout': output_e_np}
  +
  + dataset_dict = dataset_ops.Dataset.from_tensor_slices((
  + input_dict, output_dict))
  + dataset_dict = dataset_dict.repeat(100)
  + dataset_dict = dataset_dict.batch(10)
  +
  + model.fit(dataset_dict, epochs=1, steps_per_epoch=2, verbose=1)
  + model.evaluate(dataset_dict, steps=2, verbose=1)
  +
  + predict_dataset_dict = dataset_ops.Dataset.from_tensor_slices(
  + input_dict)
  + predict_dataset_dict = predict_dataset_dict.repeat(100)
  + predict_dataset_dict = dataset_dict.batch(10)
  + model.predict(predict_dataset_dict, steps=1)
  +
  @keras_parameterized.run_with_all_model_types
  @keras_parameterized.run_all_keras_modes
  def test_dataset_with_sample_weights(self):
  