NotFoundError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a Variable name or other graph key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:
Key v1 not found in checkpoint
[[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]
出现这样的问题,大多是在使用时,checkpoint文件中的变量名和调用的文件名不匹配造成的。解决方法就是查看checkpoint文件中的变量名,将程序调用变量名修改为checkpoint文件中的变量名即可解决问题。下边具体讲如何查看checkpoint文件中的变量名、修改程序调用变量名
下边例子是《TensorFlow实战Google深度学习框架》中模型持久化的例子,同时也解决书中ch5 重命名加载的问题:
模型保存的代码为: