在张量流中保存模型 [英] Saving model in tensorflow

查看:102
本文介绍了在张量流中保存模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Tensorflow 允许我们使用 tf.train.write_graph 方法保存/加载模型的结构,以便我们可以在将来恢复它以继续我们的训练课程.但是,我想知道这是否有必要,因为我可以创建一个模块,例如 GraphDefinition.py,并使用此模块重新创建模型.那么,保存模型结构的更好方法是什么,或者是否有任何经验法则建议我在保存模型时应该使用哪种方法?

Tensorflow allows us to save/load model's structure, using method tf.train.write_graph, so that we can restore it in the future to continue our training session. However, I'm wondering that if this is necessary because I can create a module, e.g GraphDefinition.py, and use this module to re-create the model. So, which is the better way to save the model structure or are there any rule of thumb that suggest which way should I use when saving a model?

推荐答案

首先你必须明白,张量流图中没有当前权重(直到你手动将它们保存在那里),如果你从graph.pb,您将从一开始就开始训练.但是如果你想继续训练或使用你训练过的模型,你必须保存检查点(使用 tf Saver),其中包含变量的值,而不仅仅是结构.看看这个步骤:Tensorflow:如何恢复以前保存的模型(蟒蛇)

First of all you have to understand, that tensorflow graph does not have current weights in it (until you save them manually there) and if you load model structure from graph.pb, you will start you train from the very beginning. But if you want to continue train or use your trained model, you have to save checkpoint (using tf Saver) with the values of the variables in it, not only the structure. Check out this tread: Tensorflow: How to restore a previously saved model (python)

这篇关于在张量流中保存模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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