Search code examples
pythontensorflowkeraslstm

What version of keras is required to use preprocessing.timeseries_dataset_from_array function?


After finding this page in the keras documentation, I decided that the timeseries_dataset_from_array function would suit what I was trying to do. But when trying to import it using

from keras.preprocessing import timeseries_dataset_from_array

or from tensorflow.keras.preprocessing import timeseries_dataset_from_array

I get the following message: ImportError: cannot import name 'timeseries_dataset_from_array' from 'keras.preprocessing'

Here it is in the tensorflow source code. This is on Tensorflow 2.3, but have also tried 2.1 and 2.2. Keras is 2.4.3

How can I import the function?


Solution

  • As per the documentation of Tensorflow it is in the nightly build currently. You can check the example that uses this API here.

    You can install the nightly build by the following command.

    pip install -q tf-nightly
    

    Ideally, it is supposed to be in v2.3.0 as per the documentation. But as you have mentioned that you have already tried using 2.3.0, I will suggest to install the nightly build and check it out.