4
我能够使用keras成功地训练我的有状态LSTM。我的批量大小为60,每输入我在网络中发送是的batch_size 以下整除是我的片断:由于batch_size问题,有状态LSTM无法预测
model = Sequential()
model.add(LSTM(80,input_shape = trainx.shape[1:],batch_input_shape=(60,
trainx.shape[1], trainx.shape[2]),stateful=True,return_sequences=True))
model.add(Dropout(0.15))
model.add(LSTM(40,return_sequences=False))
model.add(Dense(40))
model.add(Dropout(0.3))
model.add(Dense(output_dim=1))
model.add(Activation("linear"))
keras.optimizers.RMSprop(lr=0.005, rho=0.9, epsilon=1e-08, decay=0.0)
model.compile(loss="mse", optimizer="rmsprop")
我的训练线,成功运行:
model.fit(trainx[:3000,:],trainy[:3000],validation_split=0.1,shuffle=False,nb_epoch=9,batch_size=60)
现在我试图预测在测试集上可以再被60整除,但是我得到的错误:
ValueError: In a stateful network, you should only pass inputs with a number of samples that can be divided by the batch size. Found: 240 samples. Batch size: 32.
有谁能告诉我上面有什么问题吗?我很困惑,尝试了很多东西,但没有任何帮助。
谢谢,我认为模型会记住批量大小是显而易见的 – Harshit