使用TensorFlow和Jupyter实例化InteractiveSession时出错

时间:2016-06-09 18:07:46

标签: python ipython tensorflow jupyter

最近我在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>

因此图形调用有效,但我无法解释此错误或将其删除。

1 个答案:

答案 0 :(得分:1)

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