使用 preprocessing.timeseries_dataset_from_array 函数需要什么版本的 keras?

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

在 keras 文档中找到 this page 后,我决定 timeseries_dataset_from_array 函数适合我想要做的事情。但是当尝试使用

导入它时

from keras.preprocessing import timeseries_dataset_from_array

from tensorflow.keras.preprocessing import timeseries_dataset_from_array

我收到以下消息:ImportError: cannot import name 'timeseries_dataset_from_array' from 'keras.preprocessing'

Here it is在tensorflow源代码中。这是在 Tensorflow 2.3 上,但也尝试过 2.1 和 2.2。凯拉斯是 2.4.3

如何导入函数?

根据 Tensorflow 的文档,它目前在 nightly 版本中。 您可以查看使用此 API here.

的示例

您可以通过以下命令安装每晚构建。

pip install -q tf-nightly

理想情况下,根据 documentation,它应该在 v2.3.0 中。但正如您提到的,您已经尝试使用 2.3.0,我建议安装每晚构建并检查它。