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__‘
最新推荐文章于 2024-01-27 23:55:44 发布