Repository: keras-team/keras

Issue:
model.fit() fails with validation_split argument provided with TF backend
It seems with when `keras_core` used with TF backend, `model.fit()` with fails to train when provided with `validation_split` .
Without any `validation_split` it works fine.

Please refer sample code:

```
import keras_core as keras
import numpy as np
import tensorflow as tf

print('Keras_core version:',keras.__version__)
print('Tensorflow version:',tf.__version__)

mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

y_train = tf.one_hot(y_train, np.max(np.unique(y_train)))
y_test = tf.one_hot(y_test, np.max(np.unique(y_test)))

def get_model_keras():
    model = keras.Sequential(
        [
            keras.layers.Flatten(input_shape=(28, 28)),
            keras.layers.Dense(128, activation="relu"),
            keras.layers.Dense(9),
        ]
    )
    return model


model = get_model_keras()

model.summary()

model.compile(loss="categorical_crossentropy", optimizer="adam", metrics=["accuracy"])

model.fit(
    x_train,
    y_train,
    validation_split=0.2, #comment this line. It works
    epochs=2,
)
```

Got Error like below:

`ValueError: Argument `validation_split` is only supported for tensors or NumPy arrays. Found incompatible type in the input: {unsplitable}`


Discussion:

Resolving patch:
diff --git a/keras/trainers/data_adapters/data_adapter_utils.py b/keras/trainers/data_adapters/data_adapter_utils.py
--- a/keras/trainers/data_adapters/data_adapter_utils.py
+++ b/keras/trainers/data_adapters/data_adapter_utils.py
@@ -19,7 +19,7 @@
 if backend.backend() == "tensorflow":
     from keras.utils.module_utils import tensorflow as tf
 
-    ARRAY_TYPES = ARRAY_TYPES + (np.ndarray, tf.RaggedTensor)
+    ARRAY_TYPES = ARRAY_TYPES + (tf.Tensor, tf.RaggedTensor)
 if pandas:
     ARRAY_TYPES = ARRAY_TYPES + (pandas.Series, pandas.DataFrame)
 
@@ -164,8 +164,8 @@ def _can_split(t):
     if unsplitable:
         raise ValueError(
             "Argument `validation_split` is only supported "
-            "for tensors or NumPy "
-            "arrays. Found incompatible type in the input: {unsplitable}"
+            "for tensors or NumPy arrays."
+            f"Found incompatible type in the input: {unsplitable}"
         )
 
     if all(t is None for t in flat_arrays):


Test patch:
diff --git a/keras/trainers/trainer_test.py b/keras/trainers/trainer_test.py
--- a/keras/trainers/trainer_test.py
+++ b/keras/trainers/trainer_test.py
@@ -197,6 +197,53 @@ def test_fit_flow(self, run_eagerly, jit_compile, use_steps_per_epoch):
             [14.402393, 10.991339, 8.388159],
             atol=6.1051628e-1,
         )
+    
+    @parameterized.named_parameters(
+        [
+            ("eager", True, False, False),
+            ("graph_fn", False, False, False),
+            ("jit", False, True, False),
+            ("steps_per_epoch_eager", True, False, True),
+            ("steps_per_epoch_graph_fn", False, False, True),
+            ("steps_per_epoch_jit", False, True, True),
+        ]
+    )
+    @pytest.mark.requires_trainable_backend
+    def test_fit_with_val_split(self, run_eagerly, 
+                                jit_compile, use_steps_per_epoch):
+        if not run_eagerly and not jit_compile and use_steps_per_epoch:
+            if backend.backend() == "tensorflow":
+                self.skipTest(
+                    "TODO: Graph mode without XLA in TF backend leads to "
+                    "unexpected logs, need further checks."
+                )
+
+        model = ExampleModel(units=3)
+        epochs = 3
+        batch_size = 20
+        steps_per_epoch = 7
+        dataset_size = batch_size * (steps_per_epoch - 2)
+        x = np.ones((dataset_size, 4))
+        y = np.zeros((dataset_size, 3))
+
+        model.compile(
+            optimizer=optimizers.SGD(),
+            loss=losses.MeanSquaredError(),
+            metrics=[metrics.MeanSquaredError()],
+            run_eagerly=run_eagerly,
+            jit_compile=jit_compile,
+        )
+        history = model.fit(
+            x,
+            y,
+            batch_size=batch_size,
+            steps_per_epoch=steps_per_epoch if use_steps_per_epoch else None,
+            epochs=epochs,
+            validation_split=0.2,
+        )
+        history = history.history
+        self.assertIn("loss", history)
+        self.assertIn("val_loss", history)
 
     @parameterized.named_parameters(
         [