我试图第一次运行keras . 我安装了以下模块:
pip install keras --user
pip install tensorflow --user
然后尝试运行https://github.com/fchollet/keras/blob/master/examples/mnist_cnn.py .
但它给了我:
AttributeError: 'module' object has no attribute 'control_flow_ops'
这些是我正在使用的版本 .
print tensorflow.__version__
0.11.0rc0
print keras.__version__
1.1.0
如何让keras与tensorflow一起运行?
2 回答
Keras和TF之间存在问题,可能tf.python.control_flow_ops不存在或不再可见 . 使用下面的import语句可以解决此问题
详情请查看:https://github.com/fchollet/keras/issues/3857
当事实证明
keras
正在使用Theano
后端时,我遇到了这个问题 . 要修复它,请执行以下操作之一:在
~/.keras/keras.json
设置"backend": "tensorflow"
.将环境变量
KERAS_BACKEND
设置为tensorflow
.有关更多信息,请参见Keras backend文档 .