1、tf版本要与keras版本对应,不然导入会出现错误import keras cannot import name ‘context’ from ‘tensorflow.python.eager’ (unknown location)
具体对应版本看这
tf与keras对应版本查询以及下载对应版本地址
2、就算版本对应了,import keras 还是报错
module ‘tensorflow.compat.v2‘ has no attribute ‘internal‘
搜索了一下,用 from tensorflow.compat.v1 import keras 完美解决
记录下导入keras时的问题:tensorflow.python.eager和module ‘tensorflow.compat.v2‘ has no attribute ‘__internal__‘
最新推荐文章于 2023-02-14 23:16:16 发布
本文介绍了如何处理TensorFlow与Keras版本不兼容导致的导入错误,提供了解决方案:查询并安装对应版本的库,以及在遇到'tensorflow.compat.v2'无'internal'属性的错误时,使用'from tensorflow.compat.v1 import keras'来解决。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
TensorFlow-v2.15
TensorFlow
TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型

7446

被折叠的 条评论
为什么被折叠?



