【发布时间】:2019-04-25 12:08:39
【问题描述】:
我正在尝试使用 LSTM 预测时间序列。为了减少方差,我尝试使用 3 个模型进行预测,并取 3 个模型的平均值,这给了我更好的结果。在训练和验证之后,我现在想保存我的模型以供将来预测。但是,由于我有 3 个不同的模型,我想知道是否可以将它们合并到一个模型中然后保存/加载它,或者我是否应该一个一个地保存所有模型并稍后加载它们以供将来预测?
# fit 3 models
model1 = fit_lstm(train_scaled, batch_size,nb_epochs, nb_neurons)
model2 = fit_lstm(train_scaled, batch_size,nb_epochs, nb_neurons)
model3 = fit_lstm(train_scaled, batch_size,nb_epochs, nb_neurons)
# predict on test set using 3 models
forecast1 = model1.predict(test_reshaped, batch_size=batch_size)
forecast2 = model2.predict(test_reshaped, batch_size=batch_size)
forecast3 = model3.predict(test_reshaped, batch_size=batch_size)
【问题讨论】:
标签: python merge keras model lstm