Keras,优化时保存状态的最佳方法 [英] Keras, best way to save state when optimizing

查看:79
本文介绍了Keras,优化时保存状态的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道在模型优化时保存模型状态的最佳方法是什么.我想要执行此操作,因此可以将其运行一段时间,保存并在一段时间后返回.我知道有一个功能来保存权重,另一个功能是将模型保存为JSON.在学习期间,我需要保存模型的权重和参数.这包括动量和学习率等参数.有没有一种方法可以将模型和权重保存在同一文件中.我读到,使用泡菜被认为不是好习惯.还会在模型JSON或权重中包含使体面象样的动量吗?

I was just wondering what is the best way to save the state of a model while it it optimizing. I want to do this so I can run it for a while, save it, and come back to it some time later. I know there is a function to save the weights and another function to save the model as JSON. During learning I would need to save both the weights and the parameters of the model. This includes parameters like the momentum and learning rate. Is there a way to save both the model and weights in the same file. I read that it is not considered good practice to use pickle. Also would the momentums for the graident decent be included with the models JSON or in the weights?

推荐答案

您可以创建一个包含权重和体系结构的tar存档,以及一个包含 model.optimizer.get_state返回的优化器状态的pickle文件.().

You could create a tar archive containing the weights and the architecture, as well as a pickle file containing the optimizer state returned by model.optimizer.get_state().

这篇关于Keras,优化时保存状态的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆