簡體   English   中英

具有Keras數據形狀問題的LSTM自動編碼器

[英]LSTM autoencoder with Keras data shape issue

我正在嘗試使用帶有LSTM自動編碼器的Keras制作模型。 這是我嘗試過的

data = df.values
timesteps = 10
dim = data.shape[1]
samples = data.shape[0]
data.shape = (int(samples/timesteps),timesteps,dim)

接着

model = Sequential()
model.add(LSTM(50,input_shape=(timesteps,dim),return_sequences=True))
model.add(LSTM(50,input_shape=(timesteps,dim),return_sequences=True))
model.add(LSTM(50,input_shape=(timesteps,dim),return_sequences=True))
model.add(LSTM(50,input_shape=(timesteps,dim),return_sequences=True))
model.add(LSTM(50,input_shape=(timesteps,dim),return_sequences=True))
model.add(LSTM(50,input_shape=(timesteps,dim),return_sequences=True))
model.add(LSTM(50,input_shape=(timesteps,dim),return_sequences=True))
model.add(LSTM(50,input_shape=(timesteps,dim),return_sequences=True))
model.add(LSTM(50,input_shape=(timesteps,dim),return_sequences=True))
model.add(LSTM(50,input_shape=(timesteps,dim),return_sequences=True))
model.add(LSTM(50,input_shape=(timesteps,dim),return_sequences=True))
model.compile(loss='mae', optimizer='adam')

這是我的模特適合

model.fit(data, data, epochs=50, batch_size=72, validation_data=(data, data), verbose=0, shuffle=False)

這是我收到的錯誤消息

ValueError: Error when checking target: expected lstm_33 to have shape (None, 10, 50) but got array with shape (711, 10, 1)

我怎樣才能解決這個問題 ?

我只有數據集

更新

輸入數據形狀我有= (7110, 1)

這是一個單變量時間序列數據

該錯誤是由為所有層指定input_shape=(timesteps,dim)引起的。 您只需要為第一層執行此操作,其余部分將由上一層推斷。 發生的事情是你正在覆蓋導致錯誤的輸入形狀。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM