tensorflow解决keras报错 “AlreadyExistsError: Another metric with the same name already exists.“

tensorflow解决keras报错 "AlreadyExistsError: Another metric with the same name already exists."


最近要用到keras的一些API,用conda install keras之后不起作用,然后uninstall之后用pip重新安装后报了这个错。

我的tensorflow是2.6,装的keras是2.7。

从字面意思看是已经安装了两个keras的冲突,这里搬运一下*上的帖子原帖

在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.*

解决。

上一篇:TensorFlow2.1中计算平方函数的tf.square()的用法


下一篇:django多条件筛选搜索(项目实例)