Keras + tensorflow给出错误"无属性'control_flow_ops'"

ele*_*ora 11 python ubuntu machine-learning keras tensorflow

我想第一次运行keras.我安装了以下模块:

pip install keras --user
pip install tensorflow --user
Run Code Online (Sandbox Code Playgroud)

然后尝试运行https://github.com/fchollet/keras/blob/master/examples/mnist_cnn.py.

但它给了我:

AttributeError: 'module' object has no attribute 'control_flow_ops'
Run Code Online (Sandbox Code Playgroud)

这些是我正在使用的版本.

print tensorflow.__version__
0.11.0rc0
print keras.__version__
1.1.0
Run Code Online (Sandbox Code Playgroud)

我能做些什么才能让keras与tensorflow一起运行?

Dee*_*rma 23

Keras和TF之间存在问题,可能tf.python.control_flow_ops不存在或不再可见.使用下面的import语句可以解决此问题

import tensorflow as tf
tf.python.control_flow_ops = tf
Run Code Online (Sandbox Code Playgroud)

有关详细信息,请访问:https: //github.com/fchollet/keras/issues/3857

  • tf 在过去 1 或 2 年中发生了很大变化。我认为这个解决方案不再重要。 (3认同)
  • 我也有同样的问题。尝试您的解决方案时,我得到: AttributeError: module 'tensorflow' has no attribute 'python' (2认同)