[英]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:要点:
sess must be same between first and later runs (coherent structure).第一次和以后的运行之间的 sess 必须相同(连贯结构)。
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.