Keras: How could I know which version of tensorflow has been used for current keras?

Created on 27 Sep 2016  路  10Comments  路  Source: keras-team/keras

I have download the recent tensorflow from github, but it is not work for current keras, what should do? How could I know which version of tensorflow has been used for current keras?

it report something like that:
Traceback (most recent call last):
File "mnist_mlp.py", line 42, in
model.add(Dropout(0.2))
File "/home2/jyh705/anaconda2/lib/python2.7/site-packages/Keras-1.0.8-py2.7.egg/keras/models.py", line 308, in add
output_tensor = layer(self.outputs[0])
File "/home2/jyh705/anaconda2/lib/python2.7/site-packages/Keras-1.0.8-py2.7.egg/keras/engine/topology.py", line 514, in call
self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
File "/home2/jyh705/anaconda2/lib/python2.7/site-packages/Keras-1.0.8-py2.7.egg/keras/engine/topology.py", line 572, in add_inbound_node
Node.create_node(self, inbound_layers, node_indices, tensor_indices)
File "/home2/jyh705/anaconda2/lib/python2.7/site-packages/Keras-1.0.8-py2.7.egg/keras/engine/topology.py", line 149, in create_node
output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
File "/home2/jyh705/anaconda2/lib/python2.7/site-packages/Keras-1.0.8-py2.7.egg/keras/layers/core.py", line 90, in call
x = K.in_train_phase(K.dropout(x, self.p, noise_shape), x)
File "/home2/jyh705/anaconda2/lib/python2.7/site-packages/Keras-1.0.8-py2.7.egg/keras/backend/tensorflow_backend.py", line 1299, in in_train_phase
x = tf.python.control_flow_ops.cond(tf.cast(_LEARNING_PHASE, 'bool'),
AttributeError: 'module' object has no attribute 'control_flow_ops'

stale

All 10 comments

python -c 'import tensorflow as tf; print(tf.version)'

I have same problem.
I checked tensorflow version, the following error appeared.

print(tf.version)
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'module' object has no attribute 'version'

I guess you are on r0.11.0. If you go back to 0.10.0, you will be fine. The following link is the instruction:
https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html#using-pip

I have the same problem with current Keras master and Tensorflow 0.11 or 0.10. Both give me the same error:

Using TensorFlow backend.
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so locally
Traceback (most recent call last):
  File "./train_test_model_multi.py", line 98, in <module>
    model = baseline_model(pixels_count, classes_count)
  File "./train_test_model_multi.py", line 53, in baseline_model
    model.add(Dropout(0.2, input_shape=(pixels_count,)))
  File "/home/marcin/.local/lib/python2.7/site-packages/Keras-1.1.0-py2.7.egg/keras/models.py", line 276, in add
    layer.create_input_layer(batch_input_shape, input_dtype)
  File "/home/marcin/.local/lib/python2.7/site-packages/Keras-1.1.0-py2.7.egg/keras/engine/topology.py", line 370, in create_input_layer
    self(x)
  File "/home/marcin/.local/lib/python2.7/site-packages/Keras-1.1.0-py2.7.egg/keras/engine/topology.py", line 514, in __call__
    self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
  File "/home/marcin/.local/lib/python2.7/site-packages/Keras-1.1.0-py2.7.egg/keras/engine/topology.py", line 572, in add_inbound_node
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)
  File "/home/marcin/.local/lib/python2.7/site-packages/Keras-1.1.0-py2.7.egg/keras/engine/topology.py", line 149, in create_node
    output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
  File "/home/marcin/.local/lib/python2.7/site-packages/Keras-1.1.0-py2.7.egg/keras/layers/core.py", line 90, in call
    x = K.in_train_phase(K.dropout(x, self.p, noise_shape), x)
  File "/home/marcin/.local/lib/python2.7/site-packages/Keras-1.1.0-py2.7.egg/keras/backend/tensorflow_backend.py", line 1304, in in_train_phase
    x = tf.python.control_flow_ops.cond(tf.cast(_LEARNING_PHASE, 'bool'),
AttributeError: 'module' object has no attribute 'control_flow_ops'

@emjotde This has been addressed in #3857. Instead of v0.11.0 or v0.10.0, switch to v0.10.0rc0 or v0.9.0. If it still gives the same error, you might have some of the old install files lying around in your pythonpath.

Had a similar issue. Switched to v0.10.0rc0 to resolve it. Thanks!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.

I think the issue still persists since I have not found a way to determine, which versions of Tensorflow does keras support. For example, Tensorflow 1.4 does not have axis argument in tf.normalize_l2; however, on Tensorflow 1.5 tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value.

I have no way of determining whether the error is due to Tensorflow version mismatch or some other GPU problem.

Guys, not tf.version but tf.__version__
So:
python -c 'import tensorflow as tf; print(tf.__version__)'

Same Problem

$python -c 'import tensorflow as tf; print(tf.__version__)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'tensorflow' has no attribute '__version__'

My conda

$conda list |grep tensor
tensorflow-gpu            1.4.0            py36h6bf4e57_0    cjj3779
tensorflow-tensorboard    0.4.0            py36hf484d3e_0  
Was this page helpful?
0 / 5 - 0 ratings