keras icon indicating copy to clipboard operation
keras copied to clipboard

keras.utils.timeseries_dataset_from_array bugs 1

Open zhangpanzhan opened this issue 6 months ago • 3 comments

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 (<tf.Tensor: shape=(2, 3), dtype=int64, numpy= array([[0, 1, 2], [1, 2, 3]])>, <tf.Tensor: shape=(2,), dtype=int64, numpy=array([1, 2])>) (<tf.Tensor: shape=(2, 3), dtype=int64, numpy= array([[2, 3, 4], [3, 4, 5]])>, <tf.Tensor: shape=(2,), dtype=int64, numpy=array([3, 4])>) (<tf.Tensor: shape=(2, 3), dtype=int64, numpy= array([[4, 5, 6], [5, 6, 7]])>, <tf.Tensor: shape=(2,), dtype=int64, numpy=array([5, 6])>) (<tf.Tensor: shape=(1, 3), dtype=int64, numpy=array([[6, 7, 8]])>, <tf.Tensor: shape=(1,), dtype=int64, numpy=array([7])>) 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: <function AtomicFunction.del at 0x1128772e0> 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: <function AtomicFunction.del at 0x1128772e0> 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: <function AtomicFunction.del at 0x1128772e0> 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: <function AtomicFunction.del at 0x1128772e0> 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

zhangpanzhan avatar May 20 '25 08:05 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)

zhangpanzhan avatar May 20 '25 08:05 zhangpanzhan

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.

dhantule avatar May 21 '25 04:05 dhantule

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.

github-actions[bot] avatar Jun 05 '25 02:06 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.

github-actions[bot] avatar Jun 19 '25 02:06 github-actions[bot]