如何腌制Keras模型? [英] How to pickle Keras model?
本文介绍了如何腌制Keras模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
官方文件指出不建议使用pickle或cPickle保存Keras模型."
Official documents state that "It is not recommended to use pickle or cPickle to save a Keras model."
但是,我对Keras模型进行酸洗的需求源于使用sklearn的RandomizedSearchCV(或任何其他超参数优化器)进行的超参数优化.必须将结果保存到文件中,因为这样可以在分离的会话中远程执行脚本.
However, my need for pickling Keras model stems from hyperparameter optimization using sklearn's RandomizedSearchCV (or any other hyperparameter optimizers). It's essential to save the results to a file, since then the script can be executed remotely in a detached session etc.
本质上,我想:
trial_search = RandomizedSearchCV( estimator=keras_model, ... )
pickle.dump( trial_search, open( "trial_search.pickle", "wb" ) )
推荐答案
到目前为止,Keras模型是可腌制的.但是我们仍然建议使用model.save()
将模型保存到磁盘.
As of now, Keras models are pickle-able. But we still recommend using model.save()
to save model to disk.
这篇关于如何腌制Keras模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文