【发布时间】:2022-01-20 22:10:58
【问题描述】:
我对 LSTM 的维度有疑问。我有一个矩阵 [168, 6, 7] 作为输入。我想得到一个大小为 [6, 7] 的输出矩阵。但是我收到了这个错误:
ValueError: Input 0 of layer lstm is incompatible with the layer: expected ndim=3, found ndim=4. Full shape received: (None, 168, 6, 7)
是什么问题或我该如何解决?我也尝试了不同的输入形状,但我无法解决这个问题。
model = Sequential()
model.add(LSTM(4, input_shape=(d1,d2),return_sequences = True))
model.add(Flatten())
model.add(Dense(d1*d2, activation="relu"))
model.add(Reshape((d1,d2)))
model.compile(optimizer= "Adam", loss="mse", metrics=["mse"])
model.fit(xtrain, ytrain, batch_size=100, epochs=100, verbose=1)
【问题讨论】:
标签: python tensorflow keras lstm