BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / ml-dm / #34887同步于 2019/7/30
该镜像源已超过 30 天没有更新,可能在源站已被删除。
ML_DM机器人发帖

求解救,LSTM时间序列预测

jxsrlsl1234
2019/7/30镜像同步5 回复
参数不知道怎么填呀,问题如下: 现在有一组时间序列数据,每个时间点的features为7,想通过前三组时间序列数据预测后两组,于是我把数据reshape成如下的鬼样子: train_X(43796, 3, 7) [[[0.12977867 0.35294122 0.24590163 ... 0.00229001 0. 0. ] [0.14889336 0.36764708 0.24590163 ... 0.00381099 0. 0. ] [0.15995975 0.4264706 0.22950819 ... 0.00533197 0. 0. ]] [[0.14889336 0.36764708 0.24590163 ... 0.00381099 0. 0. ] [0.15995975 0.4264706 0.22950819 ... 0.00533197 0. 0. ] [0.18209255 0.48529413 0.22950819 ... 0.00839101 0.03703704 0. ]] [[0.15995975 0.4264706 0.22950819 ... 0.00533197 0. 0. ] [0.18209255 0.48529413 0.22950819 ... 0.00839101 0.03703704 0. ] [0.13883299 0.48529413 0.22950819 ... 0.00991199 0.07407407 0. ]] ... train_y(43796, 2, 7) [[[0.18209255 0.48529413 0.22950819 ... 0.00839101 0.03703704 0. ] [0.13883299 0.48529413 0.22950819 ... 0.00991199 0.07407407 0. ]] [[0.13883299 0.48529413 0.22950819 ... 0.00991199 0.07407407 0. ] [0.10965794 0.48529413 0.21311474 ... 0.01143297 0.11111111 0. ]] [[0.10965794 0.48529413 0.21311474 ... 0.01143297 0.11111111 0. ] [0.1056338 0.48529413 0.21311474 ... 0.01449201 0.14814815 0. ]] ... 好的,我觉得没什么问题啊,但是天要搞我,LSTM模型如下: ``` # design network model = Sequential() model.add(LSTM(50,input_shape=(train_X.shape[1], train_X.shape[2]),return_sequences=True)) model.add(Dense(train_y.shape[2])) model.summary() model.compile(loss='mae', optimizer='adam') # fit network # history = model.fit(train_X, train_y, epochs=50, batch_size=1, validation_data=(test_X, test_y), verbose=2, shuffle=False) history = model.fit(train_X, train_y, epochs=50, batch_size=72, verbose=2, shuffle=False) ``` 求问这里面的参数到底怎么写 ``` model.add(LSTM(50,input_shape=(train_X.shape[1], train_X.shape[2]),return_sequences=True)) model.add(Dense(train_y.shape[2])) ``` 因为现在跑的话都是这个错误 ``` _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= lstm_51 (LSTM) (None, 3, 50) 11600 _________________________________________________________________ dense_47 (Dense) (None, 3, 7) 357 ================================================================= Total params: 11,957 Trainable params: 11,957 Non-trainable params: 0 _________________________________________________________________ ValueError: Error when checking target: expected dense_47 to have shape (3, 7) but got array with shape (2, 7) ``` 我想要的是3*7输入预测出2*7 毕不了业了,救命啊
订阅后,新回复会通过你的通知中心匿名送达。
5 条回复
jxsrlsl1234机器人#1 · 2019/7/30
@kyle0510 @jaegerstar @juniornen 救命啊
jxsrlsl1234机器人#2 · 2019/7/30
为啥把return_sequences改为FALSE就可以了
juniornen机器人#3 · 2019/7/30
【 在 jxsrlsl1234 的大作中提到: 】 : 为啥把return_sequences改为FALSE就可以了 记不太清了,但是return_sequence=true是用于多层LSTM的,意思是参数传递给下一层LSTM,你只有一层 所以wrong
juniornen机器人#4 · 2019/7/30
【 在 jxsrlsl1234 的大作中提到: 】 : 为啥把return_sequences改为FALSE就可以了 最后一层大概就是全连接??也就是你的输出格式 所以你如果不强调输入格式 程序应该自动把你的那个什么shape转换成目标shape 感觉是这样
jxsrlsl1234机器人#5 · 2019/7/31
谢谢 【 在 juniornen (haonen) 的大作中提到: 】 : 最后一层大概就是全连接??也就是你的输出格式 所以你如果不强调输入格式 程序应该自动把你的那个什么shape转换成目标shape 感觉是这样