亲测解决导入Keras报错:AttributeError: module ‘tensorflow.python.keras.backend‘ has no attribute ‘get_graph‘
tensorflow
一个面向所有人的开源机器学习框架
项目地址:https://gitcode.com/gh_mirrors/te/tensorflow

·
初次安装导入Keras时很多人可能都会遇到这样的报错:
AttributeError: module 'tensorflow.python.keras.backend' has no attribute 'get_graph'
原因是你安装的tensorflow版本和keras版本不匹配!
解决办法:
方案一: 网上有的说直接更新tensorflow:pip install --upgrade tensorflow
但考虑到兼容性问题,为了避免不必要麻烦所以我选择推荐第二方案。
方案二: 重新安装tensorflow对应版本的keras。
1.查看自己安装的tensorflow版本;
进入python环境:python
导入tensorflow: import tensorflow as tf
查看版本: tf.__version__
2.打开下面链接查看自己tensorflow版本对应的keras版本:
https://docs.floydhub.com/guides/environments/
例如我的tensorflow是1.11.0,所以我应该安装keras 2.2.4
3.重新安装Keras
pip install keras==2.2.4
OK! 命令执行完重新导入keras,不再报错,哈皮(^ _ ^)
(希望有帮到您,感谢您的浏览点赞,谢谢)




一个面向所有人的开源机器学习框架
最近提交(Master分支:1 个月前 )
4f64a3d5
Instead, check for this case in `ResolveUsers` and `ResolveOperand`, by querying whether the `fused_expression_root` is part of the `HloFusionAdaptor`.
This prevents us from stepping into nested fusions.
PiperOrigin-RevId: 724311958
1 个月前
aa7e952e
Fix a bug in handling negative strides, and add a test case that exposes it.
We can have negative strides that are not just -1, e.g. with a combining
reshape.
PiperOrigin-RevId: 724293790
1 个月前
更多推荐
所有评论(0)