我试着用LSTMs预测时间序列。为了减少方差,我试着用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)
你在追求一个合奏模特。你知道吗
如下所示:
保存集合模型:
加载和预测:
Source
同时检查this article。你知道吗
相关问题 更多 >
编程相关推荐