Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keras + tensorflow gives the error "no attribute 'control_flow_ops'"

I am trying to run keras for the first time. I installed the modules with:

pip install keras --user
pip install tensorflow --user

and then tried to run https://github.com/fchollet/keras/blob/master/examples/mnist_cnn.py.

However it gives me:

AttributeError: 'module' object has no attribute 'control_flow_ops'

These are the versions I am using.

print tensorflow.__version__
0.11.0rc0
print keras.__version__
1.1.0

What can I do to get keras to run with tensorflow?

like image 713
graffe Avatar asked Oct 14 '16 15:10

graffe


2 Answers

There is an issue between Keras and TF, Probably tf.python.control_flow_ops does not exist or not visible anymore. using below import statements you can resolve this issue

import tensorflow as tf
tf.python.control_flow_ops = tf

For Details check: https://github.com/fchollet/keras/issues/3857

like image 127
Deepak Sharma Avatar answered Oct 12 '22 15:10

Deepak Sharma


If not Using TensorFlow 1.0.0; use tf.python_io in later versions

import tensorflow as tf 

tf.python_io.control_flow_ops = tf
like image 23
jayson ruzario Avatar answered Oct 12 '22 13:10

jayson ruzario