首页 > 解决方案 > 带有字符串变量名的 Sess.run

问题描述

我一直在研究《Tensor flow for Dummies》这本书,有一段代码可以恢复之前存储的变量

使用 tf.Session() 作为 sess:

# Load stored graph into current graph
saver = tf.train.import_meta_graph('output.meta')

# Restore variables into graph
saver.restore(sess, os.getcwd() + '/output')

# Display value of variable
print('Variable value: ', sess.run('x_result:0'))

在这里,变量被定义为文本名称为“x_result”,但是在最后一行中,我们通过“x_result:0”调用变量,“:0”是什么意思。此外,当我删除“:0”时,我没有得到所需的结果。请帮助我了解 ':0' 的所有用途

标签: sess.run

解决方案


推荐阅读