Issue with 'split_dataset' and string dataset

I am trying to split a dataset of strings using the split_dataset, but it fails and raising the error:

Failed to convert a NumPy array to a Tensor (Unsupported object type tensorflow.python.framework.ops.EagerTensor).

steps to reproduce:

dataset =[['a', 'b', 'c'], ['d', 'e', 'f'] ,['g', 'h', 'i']]).astype('str'))
keras.utils.split_dataset(dataset, left_size=0.8)

I am using Keras and Tensorflow on version: 2.11.0

Hi @nhruo123, You can split dataset by using below code

import tensorflow as tf
import numpy as np
dataset =[['a', 'b', 'c'], ['d', 'e', 'f'] ,['g', 'h', 'i']]).astype('str'))
num_samples =

train_dataset = dataset.take(int(0.8 * num_samples))
val_dataset = dataset.skip(int(0.8 * num_samples))

for x in train_dataset:
  print('train: ',x)

for y in val_dataset:
  print('val: ',y)

train:  tf.Tensor([b'a' b'b' b'c'], shape=(3,), dtype=string)
train:  tf.Tensor([b'd' b'e' b'f'], shape=(3,), dtype=string)
val:  tf.Tensor([b'g' b'h' b'i'], shape=(3,), dtype=string)

Thank You.