繁体   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