Found another bug for this api.

If I import timeseries_dataset_from_array like "from keras.utils import timeseries_dataset_from_array", some errors occur with logs below. However, if I import it like "from tensorflow.keras.utils import timeseries_dataset_from_array", it works pefect. My tensorflow version and keras version are 2.16.1 and 3.9.2. Hopefully it can be worked out.

2025-05-20 16:28:52.495337: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2.16.1 3.9.2 (, ) (, ) (, ) (, ) 2025-05-20 16:28:56.665240: W tensorflow/core/framework/local_rendezvous.cc:404] Local rendezvous is aborting with status: OUT_OF_RANGE: End of sequence Exception ignored in: Traceback (most recent call last): File "/Users/zhangpan/anaconda3/envs/tf_2/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/atomic_function.py", line 291, in del TypeError: 'NoneType' object is not subscriptable Exception ignored in: Traceback (most recent call last): File "/Users/zhangpan/anaconda3/envs/tf_2/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/atomic_function.py", line 291, in del TypeError: 'NoneType' object is not subscriptable Exception ignored in: Traceback (most recent call last): File "/Users/zhangpan/anaconda3/envs/tf_2/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/atomic_function.py", line 291, in del TypeError: 'NoneType' object is not subscriptable Exception ignored in: Traceback (most recent call last): File "/Users/zhangpan/anaconda3/envs/tf_2/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/atomic_function.py", line 291, in del TypeError: 'NoneType' object is not subscriptable

Comment From: zhangpanzhan

Forget to copy the code. It is simple and just test this api.

import numpy as np
import keras
from keras.utils import timeseries_dataset_from_array
import tensorflow as tf

print(tf.__version__)
print(keras.__version__)

x = np.arange(9)
y = np.arange(9) + 1

dataset = timeseries_dataset_from_array(
    data=x,
    targets=y,
    sequence_length=3,
    batch_size=2,
)

for batch in dataset:
    print(batch)

Comment From: dhantule

Hi @zhangpanzhan, thanks for reporting this.

I've tested the code with the Keras 3.9.2 and TensorFlow 2.16.1 and it is working fine in this colab gist, if you are still facing issues, please try upgrading to the latest tensorflow and keras versions in a new environment.

Comment From: github-actions[bot]

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

Comment From: github-actions[bot]

This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.