简体   繁体   English

如何将 tensorflow .meta .data .index 转换为 .ckpt 文件?

[英]how to convert tensorflow .meta .data .index to .ckpt file?

As we know, when using tensorflow to save checkpoint, we have 3 files, for eg:众所周知,在使用tensorflow保存检查点时,我们有 3 个文件,例如:

model.ckpt.data-00000-of-00001 model.ckpt.data-00000-of-00001

model.ckpt.index模型.ckpt.index

model.ckpt.meta模型.ckpt.meta

I check on the faster rcn n and found that they have an evaluation.py script which helps evaluate the pre-trained model, but the script only accept .ckpt file (as they provided some pre-trained models above).我检查了更快的rcn n,发现他们有一个evaluation.py 脚本可以帮助评估预训练模型,但该脚本只接受 .ckpt 文件(因为他们提供了上面的一些预训练模型)。

I have run some finetuning from their pre-trained model我已经从他们的预训练模型中进行了一些微调

And then I wonder if there's a way to convert all the .data-00000-of-00001 , .index and .meta into one single .ckpt file to run the evaluate.py script on the checkpoint?然后我想知道是否有一种方法可以将所有.data-00000-of-00001 、 .index 和 .meta 转换为一个 .ckpt 文件以在检查点上运行评估.py 脚本?

(I also notice that the pre-trained models they provided in the repo do have only 1 .ckpt file, how can they do that when the save-checkpoint function generates 3 files?) (我还注意到他们在 repo 中提供的预训练模型确实只有 1 个.ckpt文件,当 save-checkpoint 函数生成 3 个文件时,他们如何做到这一点?)

These这些

{ model.ckpt.data-00000-of-00001 { model.ckpt.data-00000-of-00001

model.ckpt.index模型.ckpt.index

model.ckpt.meta }模型.ckpt.meta }

are the more recent checkpoint format是最近的检查点格式

while尽管

{model.ckpt} {模型.ckpt}

is a previous checkpoint format是以前的检查点格式

It will be in the same concept as to convert a Nintendo Switch to NES ... Or a 3 pieces CD bundle to a single ROM cartridge...它将与将 Nintendo Switch 转换为 NES 的概念相同......或者将 3 片 CD 包转换为单个 ROM 盒式磁带......

You don't need to convert, You can save the variables in the network using你不需要转换,你可以使用保存网络中的变量

saver = tf.train.Saver() 
saver.save(sess, 'path of save/fileName.ckpt')

To restore the network for reuse later or in another script, use:要恢复网络以供稍后或在另一个脚本中重用,请使用:

saver = tf.train.Saver()
saver.restore(sess, tf.train.latest_checkpoint('path of save/')
sess.run(....) 

Important points:要点:

  1. sess must be same between first and later runs (coherent structure).第一次和以后的运行之间的 sess 必须相同(连贯结构)。

  2. saver.restore needs the path of the folder of the saved files, not an individual file path. saver.restore 需要保存文件的文件夹路径,而不是单个文件路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Tensorflow:.ckpt文件和.ckpt.meta和.ckpt.index以及.pb文件之间的关系是什么 - Tensorflow : What is the relationship between .ckpt file and .ckpt.meta and .ckpt.index , and .pb file 如何在tensorflow中找到给定.ckpt.meta文件的输出节点名称 - How to find the output node name of given .ckpt.meta file in tensorflow 来自 model.ckpt.meta 文件的 Tensorflow 视图图 - Tensorflow view graph from model.ckpt.meta file 如何使用.ckpt.data和.ckpt.index加载模型 - How to load a model using .ckpt.data and .ckpt.index 如何恢复 tensorflow inceptions 检查点文件(ckpt)? - How to restore tensorflow inceptions checkpoint file (ckpt)? 如何将.ckpt文件转换为HD5文件? - How to convert .ckpt file to Hd5 file? .pb 文件到 .ckpt 的转换(tensorflow) - Conversion of .pb file to .ckpt (tensorflow) 如何在tensorflow对象检测api中生成用于训练和推理的.ckpt文件 - How to generate .ckpt file for training and inference in tensorflow object detection api 如何在没有索引文件和元文件的情况下恢复Tensorflow模型? - How to restore tensorflow model without index file and meta file? 如何在不丢失 metagraphdef 的情况下将 a.meta.index 和.data 文件转换为 SavedModel (.pb) 格式? - How do I convert a .meta .index and .data file into SavedModel (.pb) format without losing metagraphdef?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM