0
我一直在尝试使用 Tensorflow : Memory leak even while closing Session? 上提供的答案来迭代张量流模型。我有与在其中一个注释中提到的相同的错误,即“会话图是空的,将操作添加到图之前调用run()“。我无法弄清楚如何解决它。会话图为空
我一直在尝试使用 Tensorflow : Memory leak even while closing Session? 上提供的答案来迭代张量流模型。我有与在其中一个注释中提到的相同的错误,即“会话图是空的,将操作添加到图之前调用run()“。我无法弄清楚如何解决它。会话图为空
我的建议是确保你的会话知道它在哪个图上运行。 出头,你可以尝试是:
构建图形第一,并通过在图形中的会话。
myGraph = tf.Graph()
with myGraph.as_default():
# build your graph here
mySession = tf.Session(graph=myGraph)
mySession.run(...)
# Or
with tf.Session(graph=myGraph) as mySession:
mySession.run(...)
如果你想使用多个with
声明,以嵌套的方式来使用它。
with tf.Graph().as_default():
# build your graph here
with tf.Session() as mySession:
mySession.run(...)
什么是你想要运行的代码? –