我對 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)
uj5u.com熱心網友回復:
您的 LSTM 層需要以這種方式塑造的 3D 輸入:
( number of observations , lenght of input sequence , number of features )
要了解更多資訊,建議您查看以下內容:
https://shiva-verma.medium.com/understanding-input-and-output-shape-in??-lstm-keras-c501ee95c65e
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/386343.html
上一篇:如何解決:ValueError:InputcontainsNaN,infinityoravaluetoolargefordtype('float32')?
下一篇:如何從csv檔案中洗掉雙引號
