我从 Keras 收到非常令人困惑的错误消息。我使用以下模型并将形状传递给它 input (num_examples, n, 1)。
def create_model():
model = Sequential()
model.add(LSTM(64, input_shape=(n,1), return_sequences=False))
model.add(Dense(units=n, activation='linear'))
return model
我收到此错误消息: ValueError: Error when checking target: expected dense_16 to have 2 dimensions, but got array with shape (11030, 50, 1)。
但这怎么可能呢?如果我使用model.summary(),则显示LSTM输出具有以下形状:(None, 64)。那么它如何将具有形状的数组传递(11030, 50, 1)给 Dense 层呢?
此外,如果我尝试model.add(Flatten())在 LSTM 和 Dense 之间添加,我会收到此错误:ValueError: Input 0 is incompatible with layer flatten_3: expected min_ndim=3, found ndim=2.
因此,它将 2D 传递给 Flatten,但是它怎么可能将 3D 传递给 Dense?
慕尼黑5688855
相关分类