【发布时间】:2021-06-17 11:05:16
【问题描述】:
我一直在做一个项目,使用时间序列数据和天气数据来估计交通流量。我正在为我的时间序列使用 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 中是如何工作的。如果您能指出我正确的方向,我们将不胜感激,但我现在需要的是修复我的模型。
【问题讨论】:
标签: python tensorflow time-series lstm convolution