save_path is not a valid checkpoint
save_path is not a valid checkpoint
这句代码还是获取模型的字符串路径:
aaa = tf.train.latest_checkpoint(model_path)
自己写对了,就不需要。
model_path结尾到文件名,.data前面的部分,加载预训练:
tf.train.Saver(self.network.vars).restore(self.sess, model_path)
tensorflow版本1.4写的,
用1.13去读,识别不了了。
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
1 Tensorflow模型文件
我们在checkpoint_dir目录下保存的文件结构如下:
--checkpoint_dir
--checkpoint
--MyModel.meta
--MyModel.data-00000-of-00001
--MyModel.index
1.1 meta文件
MyModel.meta文件保存的是图结构,meta文件是pb(protocol buffer)格式文件,包含变量、op、集合等。
1.2 ckpt文件
ckpt文件是二进制文件,保存了所有的weights、biases、gradients等变量。在tensorflow 0.11之前,保存在.ckpt文件中。0.11后,通过两个文件保存,如:
MyModel.data-00000-of-00001
MyModel.index
1.3 checkpoint文件
我们还可以看,checkpoint_dir目录下还有checkpoint文件,该文件是个文本文件,里面记录了保存的最新的checkpoint文件以及其它checkpoint文件列表。在inference时,可以通过修改这个文件,指定使用哪个model
还没有评论,来说两句吧...