我正在玩机器学习,并试图跟随一些例子,但我坚持试图让我的数据进入Keras LSTM层。Keras LSTM Shape for Pandas DataFrame
我在Pandas DataFrame中有一些股票行情数据,它以15分钟的时间间隔对ohlc进行重新采样,并为每行加载其他指标。
我的代码如下。 DF是我的数据框:
x = df.iloc[:, :-1].values
y = df.iloc[:, -1:].values
dimof_input = x.shape[1]
dimof_output = len(set(y.flat))
model = Sequential()
model.add(LSTM(4, input_dim=dimof_input, return_sequences=True))
model.compile(loss='mse', optimizer='rmsprop')
model.fit(x, y, nb_epoch=1, batch_size=1, verbose=2)
当我尝试和适应,我得到:
Error when checking input: expected lstm_16_input to have 3 dimensions,
but got array with shape (33, 100)
我从其他地方的例子复制本。我不太明白如何将正确的数据形状引入此模型。谁能帮忙?
谢谢加载。
你真的想用LSTM实现什么? – DarkCygnus
我正在关注股票价格预测的一些教程。虽然不是什么严肃的事情,但这只是一个问题。 – Ludo
好的......也许它和你通过'x.shape [1]'得到的'dimof_input'有关......'x'的形状是什么?通常我只是没有索引的'x.shape' ... – DarkCygnus