我第一次尝试运行 Keras。我使用以下命令安装了模块:
pip install keras --userpip 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.0rc0print keras.__version__1.1.0
我该怎么做才能让 Keras 和 TensorFlow 一起运行?
回答:
Keras 和 TensorFlow 之间存在问题,可能是因为 tf.python.control_flow_ops 不存在或不再可见。使用下面的导入语句可以解决这个问题
import tensorflow as tftf.python.control_flow_ops = tf