解决模型加载NotFoundError (see above for traceback) Key v1 not found in checkp错误

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 重命名加载的问题:

模型保存的代码为:


                
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值