遵循这个doc:,在安装tensorflow 1.8.0版本和python版本2.7.13之后,我尝试运行这些代码行。
*import tensorflow as tf
tf.enable_eager_execution()*
我转到安装tensorflow的顶层目录中的jupyter notebook,创建一个新的jupyter notebook,然后运行上面的代码行,得到以下错误:
*---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-1-1ff77c8b7a69> in <module>()
1 import tensorflow as tf
2 from __future__ import absolute_import, division, print_function
----> 3 tf.enable_eager_execution()
AttributeError: 'module' object has no attribute 'enable_eager_execution'*
但是当我从终端访问python,或者使用ipython时,我可以成功地运行这两行代码。有人知道这是为什么吗?我该如何解决笔记本中的这个问题?
发布于 2019-05-13 12:55:56
我在colab上工作时遇到了这个错误,我通过选择Runtime菜单中的“Reset all Runtime”选项来重置环境,从而消除了这个错误。
另一种消除此错误的方法是在代码单元格中执行以下代码:
import tensorflow as tf
tf.enable_eager_execution()
https://stackoverflow.com/questions/50214104
复制相似问题