[英]ERROR:tensorflow:Couldn't match files for checkpoint
我正在训练一个张量流模型,在每个时期之后,我保存模型状态并腌制一些数组。 到目前为止,我的模型完成了2个纪元,保存状态的文件夹包含以下文件:
checkpoint
model_e_knihy_preprocessed.txt_e0.ckpt-1134759.data-00000-of-00001
model_e_knihy_preprocessed.txt_e0.ckpt-1134759.index
model_e_knihy_preprocessed.txt_e0.ckpt-1134759.meta
model_e_knihy_preprocessed.txt_e1.ckpt-2269536.data-00000-of-00001
model_e_knihy_preprocessed.txt_e1.ckpt-2269536.index
model_e_knihy_preprocessed.txt_e1.ckpt-2269536.meta
topgrads_e_knihy_preprocessed.txt_[it0].pkl
topgrads_e_knihy_preprocessed.txt_[it1].pkl
toppositions_e_knihy_preprocessed.txt_[it0].pkl
toppositions_e_knihy_preprocessed.txt_[it1].pkl
vocab.txt
我没有移动文件夹,也没有对文件结构进行任何外部修改。 checkpoint
文件包含以下内容:
model_checkpoint_path: "model_e_knihy_preprocessed.txt_e1.ckpt-2269536"
all_model_checkpoint_paths: "model_e_knihy_preprocessed.txt_e0.ckpt-1134759"
all_model_checkpoint_paths: "model_e_knihy_preprocessed.txt_e1.ckpt-2269536"
我以以下方式还原模型
with tf.Session() as session:
model = Word2Vec(opts, session)
model.saver.restore(session, tf.train.latest_checkpoint(path_to_model))
但是tf.train.latest_checkpoint(path_to_model)
方法中已经存在错误 。
ERROR:tensorflow:Couldn't match files for checkpoint /mnt/minerva1/nlp/projects/deep_learning/word2vec/trainedmodels/tf_w2vopt_[CS]ebooks_topgradients_iterative/model_e_knihy_preprocessed.txt_e1.ckpt-2269536
所以我偷看了这个方法
def latest_checkpoint(checkpoint_dir, latest_filename=None):
ckpt = get_checkpoint_state(checkpoint_dir, latest_filename)
if ckpt and ckpt.model_checkpoint_path:
# Look for either a V2 path or a V1 path, with priority for V2.
v2_path = _prefix_to_checkpoint_path(ckpt.model_checkpoint_path,
saver_pb2.SaverDef.V2)
v1_path = _prefix_to_checkpoint_path(ckpt.model_checkpoint_path,
saver_pb2.SaverDef.V1)
if file_io.get_matching_files(v2_path) or file_io.get_matching_files(
v1_path):
return ckpt.model_checkpoint_path
else:
logging.error("Couldn't match files for checkpoint %s",
ckpt.model_checkpoint_path)
return None
并发现file_io.get_matching_files(v2_path)没有发现任何东西(v2_path包含值/ /mnt/minerva1/nlp/projects/deep_learning/word2vec/trainedmodels/tf_w2vopt_[CS]ebooks_topgradients_iterative/model_e_knihy_preprocessed.txt_e1.ckpt-2269536.index
minerva1 / nlp / projects / deep_learning / word2vec / trainedmodels / tf_w2vopt_ [CS] ebooks_topgradients_iterative / /mnt/minerva1/nlp/projects/deep_learning/word2vec/trainedmodels/tf_w2vopt_[CS]ebooks_topgradients_iterative/model_e_knihy_preprocessed.txt_e1.ckpt-2269536.index
。该文件夹!可悲的是我没有太大的进一步跟进,因为这种方法的控制通向tensorflow包装。这是一个错误tensorflow?
我正在使用Tensorflow版本1.5.0-rc0。
因此,答案是不要在文件路径中使用方括号 。 Tensorflow无法处理它们。 参见https://github.com/tensorflow/tensorflow/issues/6082#issuecomment-265055615
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.