我的tensorflow是2.6,装的keras是2.7。
从字面意思看是已经安装了两个keras的冲突,这里搬运一下stackoverflow上的帖子原帖:
在tensorflow的release note里面写了这个问题: https://github.com/tensorflow/tensorflow/releases/tag/v2.6.0
Keras been split into a separate PIP package (keras), and its code has been moved to the GitHub repositorykeras-team/keras. The API endpoints for tf.keras stay unchanged, but are now backed by the keras PIP package. The existing code in tensorflow/python/keras is a staled copy and will be removed in future release (2.7). Please remove any imports to tensorflow.python.keras and replace them with public tf.keras API instead.
意思就是keras代码移位了,需要用pip单独安装,但之前的keras还没移除。如果装了和tf版本不一致的keras就会somehow触发这个冲突,于是意识到keras版本装错了,用pip重装一下就好:
pip install keras==2.6.*解决。