我一直在开发一个项目,使用时间序列数据与天气数据结合来估计交通流量。我的时间序列窗口为30个值,我使用了20个与天气相关的特征。我使用功能性API来实现这个项目,但是我一直遇到同样的错误,不知道该如何解决。我看过其他类似的帖子,比如这个Input 0 of layer conv1d_1 is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: [None, 200],但是没有帮助。
这是我的模型,
series_input = Input(shape = (series_input_train.shape[1], ), name = 'series_input')
x = Conv1D(filters=32, kernel_size=5, strides=1, padding="causal", activation="relu")(series_input)
x = LSTM(32, return_sequences = True)(x)
x = LSTM(32, return_sequences = True)(x)
x = Dense(1, activation = 'relu')(x)
series_output = Lambda(lambda w: w * 200)(x)
weather_input = Input(shape = (weather_input_train.shape[1], ), name = 'weather_input')
x = Dense(32, activation = 'relu')(weather_input)
x = Dense(32, activation = 'relu')(x)
weather_output = Dense(1, activation = 'relu')(x)
concatenate = concatenate([series_output, weather_output], axis=1, name = 'concatenate')
output = Dense(1, name = 'output')(concatenate)
model = Model([series_input, weather_input], output)
series_input_train
和weather_input_train
的形状分别为(34970, 30)和(34970, 20)。
我不断收到的错误是这个:
ValueError: Input 0 of layer conv1d is incompatible with the layer: : expected min_ndim=3, found ndim=2. Full shape received: (None, 30)
我做错了什么?
老实说,我一直有困难弄清楚TensorFlow中输入的形状是如何工作的。如果你能指导我正确方向,我将不胜感激,但现在我需要的是修复我的模型。