在tensorflow中还原检查点时出错
我使用以下代码保存我的张量流模型:在tensorflow中还原检查点时出错,tensorflow,Tensorflow,我使用以下代码保存我的张量流模型: saver = tf.train.Saver() saver.save(session, 'model.ckpt') 现在,当我想使用以下代码恢复模型时: with tf.Session() as session: ckpt = tf.train.get_checkpoint_state(checkpoint_dir='/Documents/') if ckpt and ckpt.model_checkpoint_path:
saver = tf.train.Saver()
saver.save(session, 'model.ckpt')
现在,当我想使用以下代码恢复模型时:
with tf.Session() as session:
ckpt = tf.train.get_checkpoint_state(checkpoint_dir='/Documents/')
if ckpt and ckpt.model_checkpoint_path:
saver.restore(session, ckpt.model_checkpoint_path)
else:
print("no checkpoint found")
我得到这个错误:
ValueError: Fetch argument u'save/restore_all' of u'save/restore_all' cannot be interpreted as a Tensor. ("The name 'save/restore_all' refers to an Operation not in the graph.")
如何修复此问题并恢复会话?您可以发布更多代码吗?该错误可能是由于您的
tf.Session()
没有正确的图形造成的。您可以使用sess.graph.get_operations()
检查此项,如果为空,则此项不好!您需要在恢复检查点之前重新创建模型图,例如,使用tf.train.import\u meta\u graph
Thank@YaroslavBulatov。它不再产生那个错误了。但是,当我想要使用加载的会话时,我收到以下错误:ValueError:无法使用默认会话来计算张量:张量图与会话图不同。将显式会话传递给eval(session=sess)。谢谢@OlivierMoindrot。我检查了sess.graph.get_操作()。它不是空的。听起来您有多个会话。尝试只创建一个会话以避免此类错误扫描您发布的更多代码?该错误可能是由于您的tf.Session()
没有正确的图形造成的。您可以使用sess.graph.get_operations()
检查此项,如果为空,则此项不好!您需要在恢复检查点之前重新创建模型图,例如,使用tf.train.import\u meta\u graph
Thank@YaroslavBulatov。它不再产生那个错误了。但是,当我想要使用加载的会话时,我收到以下错误:ValueError:无法使用默认会话来计算张量:张量图与会话图不同。将显式会话传递给eval(session=sess)。谢谢@OlivierMoindrot。我检查了sess.graph.get_操作()。它不是空的。听起来您有多个会话。尝试只创建一个会话以避免此类错误