Keras + tensorflow 给出错误“没有属性 'control_flow_ops'"; [英] Keras + tensorflow gives the error "no attribute 'control_flow_ops'"

查看:23
本文介绍了Keras + tensorflow 给出错误“没有属性 'control_flow_ops'";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次尝试运行 keras.我安装了模块:

pip install keras --userpip 安装 tensorflow --user

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

但是它给了我:

AttributeError: 'module' 对象没有属性 'control_flow_ops'

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

 打印 tensorflow.__version__0.11.0rc0打印 keras.__version__1.1.0

<块引用>

我该怎么做才能让 keras 与 tensorflow 一起运行?

解决方案

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

 将 tensorflow 导入为 tftf.python.control_flow_ops = tf

详情请查看:https://github.com/fchollet/keras/issues/3857

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?

解决方案

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

这篇关于Keras + tensorflow 给出错误“没有属性 'control_flow_ops'";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆