我是这个领域的新手。我尝试使用两个输入:价格和情绪来预测下一个小时的价格。搜索后,我发现有一个教程,这是def:
import keras
def buildModel(dataLength, labelLength):
price = Input(shape = (dataLength,1),name='price')
sentiment = Input(shape=(dataLength,1),name='sentiment')
priceLayers = LSTM(64, return_sequences=False)(price)
sentimentLayers = LSTM(64, return_sequences=False)(sentiment)
output = keras.layers.concatenate(
[
priceLayers,
sentimentLayers,
]
)
output = Dense(labelLength, activation='linear',name='output')(output)
model = Model(
inputs = [
price,
sentiment
],
outputs=[
output
]
)
model.compile(optimizer='rmsprop',loss='mse')
return model
我的两个输入的形状是:
trainX = (1, 22234, 51)
trainS = (1, 22285, 1)
我执行def:
lstm = buildModel(22234,1)
lstm.fit([trainX,trainS],[trainX],validation_data=(
[testX,testS],
[testX]),epochs = 10
)
但是我得到Error when checking input: expected price to have shape (22234, 1) but got array with shape (22234, 51)
实际上,我对形状非常困惑,所以我的问题是:
3。
在lstm.fit
中,我不知道应该输入什么输出,因此我标记为粗体的地方正确吗?
lstm.fit([trainX,trainS],**[trainX]**,validation_data=(
[testX,testS],
**[testX]**),epochs = 10
)