Search code examples
pythontensorflowkeras

Error when calling the method timeseries_dataset_from_array from Keras


I'm going through the tutorial given in:

https://www.tensorflow.org/tutorials/structured_data/time_series

Funny thing, when I ran the code I got the error:

AttributeError: module 'tensorflow_core.keras.preprocessing' has no attribute 'timeseries_dataset_from_array'

I tried explicitly importing the method like:

from tensorflow.keras.preprocessing import timeseries_dataset_from_array

but then:

ImportError: cannot import name 'timeseries_dataset_from_array'

I'm using Spyder 4, Python 3.6.9, TensorFlow 2.1.0 and Keras 2.2.4-tf. Can anyone clarify this to me?


Solution

  • I think it's introduced in tensorflow 2.3.0, so you need to update your tensorflow. tf.keras.preprocessing.timeseries_dataset_from_array