TensorFlow 0.12型号文件(TensorFlow 0.12 Model Files)

编程入门 行业动态 更新时间:2024-10-27 02:18:42
TensorFlow 0.12型号文件(TensorFlow 0.12 Model Files)

我训练模型并使用以下方法保存:

saver = tf.train.Saver() saver.save(session, './my_model_name')

除了仅包含指向模型最近检查点的指针的检查点文件之外,这将在当前路径中创建以下3个文件:

my_model_name.meta my_model_name.index my_model_name.data 00000-的-00001

我想知道每个文件包含什么。

我想用C ++加载这个模型并运行推理。 label_image示例使用ReadBinaryProto()从单个.bp文件加载模型。 我想知道如何从这3个文件中加载它。 以下是C ++的等价物?

new_saver = tf.train.import_meta_graph('./my_model_name.meta') new_saver.restore(session, './my_model_name')

I train a model and save it using:

saver = tf.train.Saver() saver.save(session, './my_model_name')

Besides the checkpoint file, which simply contains pointers to the most recent checkpoints of the model, this creates the following 3 files in the current path:

my_model_name.meta my_model_name.index my_model_name.data-00000-of-00001

I wonder what each of these files contains.

I'd like to load this model in C++ and run the inference. The label_image example loads the model from a single .bp file using ReadBinaryProto(). I wonder how I can load it from these 3 files. What is the C++ equivalent of the following?

new_saver = tf.train.import_meta_graph('./my_model_name.meta') new_saver.restore(session, './my_model_name')

最满意答案

我目前正在努力解决这个问题,我发现目前不太直截了当。 关于这个主题的两个最常见的教程是: https: //medium.com/jim-fleming/loading-a-tensorflow-graph-with-the-c-api-4caaff88463f#.goxwm1e5j和https:// medium。 com/@hamedmp/exporting-trained-tensorflow-models-to-c-the-right-way-cf24b609d183#.g1gak956i

相当于

new_saver = tf.train.import_meta_graph('./my_model_name.meta') new_saver.restore(session, './my_model_name')

只是

Status load_graph_status = LoadGraph(graph_path, &session);

假设你已经“冻结了图形”(使用了一个将图形文件和检查点值结合在一起的脚本)。 此外,请参阅此处的讨论: Tensorflow以不同的方式导出和运行C ++中的图形

I'm currently struggling with this myself, I've found it's not very straightforward to do currently. The two most commonly cited tutorials on the subject are: https://medium.com/jim-fleming/loading-a-tensorflow-graph-with-the-c-api-4caaff88463f#.goxwm1e5j and https://medium.com/@hamedmp/exporting-trained-tensorflow-models-to-c-the-right-way-cf24b609d183#.g1gak956i

The equivalent of

new_saver = tf.train.import_meta_graph('./my_model_name.meta') new_saver.restore(session, './my_model_name')

Is just

Status load_graph_status = LoadGraph(graph_path, &session);

Assuming you've "frozen the graph" (Used a script with combines the graph file with the checkpoint values). Also, see the discussion here: Tensorflow Different ways to Export and Run graph in C++

更多推荐

本文发布于:2023-07-31 00:12:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1340295.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:型号   文件   TensorFlow   Model   Files

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!