当前位置:   article > 正文

[Keras] 使用多 gpu 并行训练并使用 ModelCheckpoint() 可能遇到的问题_callbacks.modelcheckpoint()有什么缺点

callbacks.modelcheckpoint()有什么缺点

问题描述

在使用 callbacks.ModelCheckpoint() 并进行多 gpu 并行计算时,callbacks 函数会报错:

TypeError: can't pickle ...(different text at different situation) objects
  • 1

这个错误形式其实跟使用多 gpu 训练时保存模型不当造成的错误比较相似:

To save the multi-gpu model, use .save(fname) or .save_weights(fname)
with the template model (the argument you passed to multi_gpu_model),
rather than the model returned by multi_gpu_model.

这个问题在我之前的文章中也有提到:[Keras] 使用Keras调用多GPU,并保存模型
。显然,在使用检查点时,默认还是使用了 paralleled_model.save() ,进而导致错误。为了解决这个问题,我们需要自己定义一个召回函数。

解决方法

法一

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/53749
推荐阅读
相关标签
  

闽ICP备14008679号