Skip to content

keras.utils.timeseries_dataset_from_array bugs 1 #21306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
zhangpanzhan opened this issue May 20, 2025 · 2 comments
Open

keras.utils.timeseries_dataset_from_array bugs 1 #21306

zhangpanzhan opened this issue May 20, 2025 · 2 comments

Comments

@zhangpanzhan
Copy link

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
Copy link
Author

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)

@dhantule
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants