TensorFlow.Keras ModelCheckpoint训练时保存模型,为什么? [英] TensorFlow.Keras ModelCheckpoint Saving model while training , why?

查看:993
本文介绍了TensorFlow.Keras ModelCheckpoint训练时保存模型,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道为什么我们在训练时需要保存模型? 仅在火车开始时保存一次,然后仅在火车期间保存重量还不够吗?

我的意思是,火车期间模型没有改变,为什么需要此布尔值?

class ModelCheckpoint(Callback):
...
save_weights_only: if True, then only the model's weights will be saved.
...

谢谢!

解决方案

这不是需求或要求,只是方便.在典型的DL/DS工作流程中,您训练了许多具有不同配置的模型,并且很容易迷失方向.也许您现在已经保存了最佳模型的权重,但是您不记得使用了哪种模型配置.该信息不是权重的一部分,必须单独记录.

然后Keras提供了一个简单的解决方案,用于存储模式(占用的空间少于10 KB)以及权重,因此在丢失原始模型配置的情况下,它仍保存在相同的HDF5文件中. /p>

还要考虑在没有模型配置的情况下将模型权重发送给其他人的情况,如何在没有模型的情况下加载权重?同样,这只是方便.

I was wondering why do we need to save the model while training ? isn't enough to save it once at the beginning of the train and then only save the weights during the train ?

I mean , The model isn't changing during the train , why this boolean is need for ?

class ModelCheckpoint(Callback):
...
save_weights_only: if True, then only the model's weights will be saved.
...

Thanks !

解决方案

Its not a need or requirement, its just convenience. In a typical DL/DS workflow, you train a lot of models with different configurations and it is quite easy to get lost. Maybe you now have saved the weights for the best model but you don't remember which model configuration it was used. That information is not part of the weights and has to be recorded separately.

Then Keras provides a simple solution, to store the mode (which takes less than 10 KB) along with the weights, so in the case that you lose the original model configuration, it is still saved in the same HDF5 file.

Also consider the case where you send the model weights to someone else without the model configuration, how can you load the weights without a model? Again its just convenience.

这篇关于TensorFlow.Keras ModelCheckpoint训练时保存模型,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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