从 Keras 调用方法 timeseries_dataset_from_array 时出错

Dar*_*rip 2 python keras tensorflow

我正在阅读以下教程:

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

有趣的是,当我运行代码时出现错误:

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

我尝试显式导入方法,如:

from tensorflow.keras.preprocessing import timeseries_dataset_from_array

但是之后:

ImportError: cannot import name 'timeseries_dataset_from_array'

我使用的是 Spyder 4、Python 3.6.9、TensorFlow 2.1.0 和 Keras 2.2.4-tf。任何人都可以向我澄清这一点吗?

小智 6

我认为它是在 tensorflow 2.3.0 中引入的,所以你需要更新你的 tensorflow。 tf.keras.preprocessing.timeseries_dataset_from_array