【发布时间】:2020-11-19 19:17:31
【问题描述】:
当我尝试在我的 LSTM 模型中添加 validation_split 时,我收到了这个错误
ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found: (<tensorflow.python.keras.preprocessing.sequence.TimeseriesGenerator object)
这是代码
from keras.preprocessing.sequence import TimeseriesGenerator
train_generator = TimeseriesGenerator(df_scaled, df_scaled, length=n_timestamp, batch_size=1)
model.fit(train_generator, epochs=50,verbose=2,callbacks=[tensorboard_callback], validation_split=0.1)
----------
ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found: (<tensorflow.python.keras.preprocessing.sequence.TimeseriesGenerator object)
我能想到的一个原因是,使用 validation_split 需要张量或 numpy 数组,如错误中所述,但是,当通过 TimeSeriesGenerator 传递训练数据时,它将训练数据的维度更改为 3D 数组
而且由于 TimeSeriesGenerator 是在使用 LSTM 时必须使用的,这是否意味着对于 LSTM 我们不能使用validation_split
【问题讨论】:
标签: python tensorflow keras lstm