首页 > 解决方案 > Tensorflow Python:无法使用 tf.train.Saver() 恢复变量:错误::未找到:检查点中未找到关键变量/亚当

问题描述

我很困惑。我不知道发生了什么。我无法恢复我的检查点。奇怪的是有时我可以恢复它们,然后 1-2 小时后我就不能了。

我使用此代码保存

saver = tf.train.Saver()
with tf.Session() as sess:
    .....
    #sess.run(init)
    saver.restore(sess, 'models/my_model_2.ckpt')

我使用此代码恢复

with tf.Session() as sess:
    #sess.run(init)
    saver.restore(sess, 'models/my_model_2.ckpt')
    ......

错误

2020-10-15 01:10:35.195112: W tensorflow/core/framework/op_kernel.cc:1502] OP_REQUIRES failed at 
save_restore_v2_ops.cc:184 : Not found: Key Variable/Adam not found in checkpoint

如果您不知道如何解决此问题,请告诉我是否有其他方法可以恢复变量。另外,我的程序是最后带有神经网络的 CNN。我对所有事情都使用张量流。

标签: pythontensorflowtensorflow2.0

解决方案


将您的优化器从 Adam 更改为其他?我不知道为什么,但我通过这种方式解决了这个问题。


推荐阅读