【问题标题】:Error instantiating the InteractiveSession using TensorFlow and Jupyter使用 TensorFlow 和 Jupyter 实例化 InteractiveSession 时出错
【发布时间】:2016-06-09 18:07:46
【问题描述】:

最近,我在 Jupyter / IPython 笔记本中使用 TensorFlow 中的 InteractiveSession 时遇到了错误。这个问题很容易重新创建,我的整个代码是:

import tensorflow as tf

sess = tf.InteractiveSession()

sess.graph

输出是:

Exception ignored in: <bound method BaseSession.__del__ of <tensorflow.python.client.session.InteractiveSession object at 0x11a4e89b0>>
Traceback (most recent call last):
  File "/Users/.../anaconda/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 140, in __del__
    self.close()
  File "/Users/.../anaconda/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 905, in close
    self._default_session.__exit__(None, None, None)
  File "/Users/brad/anaconda/lib/python3.5/contextlib.py", line 66, in __exit__
    next(self.gen)
  File "/Users/.../anaconda/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3215, in get_controller
    assert self.stack[-1] is default
AssertionError: 
Out[3]:
<tensorflow.python.framework.ops.Graph at 0x10685dc50>

所以图形调用有效,但我无法解释或消除此错误。

【问题讨论】:

  • 您使用的是哪个版本的 TensorFlow?最近对交互式会话析构函数代码进行了调整,我无法使用最新版本重新创建它。
  • 我使用的是 v0.8.0 版本

标签: python ipython tensorflow jupyter


【解决方案1】:

此错误消息是由 TensorFlow 0.8 及更早版本中的错误引起的。当 Python 垃圾收集器删除旧的 tf.InteractiveSession 之前创建新的 tf.InteractiveSession 时会触发该错误。在 TensorFlow 0.9 版中是 fixed,因此升级到最新版本应该可以解决问题。

【讨论】:

    猜你喜欢
    • 2017-11-01
    • 2019-03-20
    • 1970-01-01
    • 2019-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-02
    • 2011-03-21
    相关资源
    最近更新 更多