from keras import models File "/usr/local/python3/lib/python3.7/site-packages/keras/mo_tensorfl">
赞
踩
File "/usr/local/python3/lib/python3.7/site-packages/keras/__init__.py", line 25, in <module> from keras import models File "/usr/local/python3/lib/python3.7/site-packages/keras/models.py", line 20, in <module> from keras import metrics as metrics_module File "/usr/local/python3/lib/python3.7/site-packages/keras/metrics.py", line 26, in <module> from keras import activations File "/usr/local/python3/lib/python3.7/site-packages/keras/activations.py", line 20, in <module> from keras.layers import advanced_activations File "/usr/local/python3/lib/python3.7/site-packages/keras/layers/__init__.py", line 23, in <module> from keras.engine.input_layer import Input File "/usr/local/python3/lib/python3.7/site-packages/keras/engine/input_layer.py", line 21, in <module> from keras.engine import base_layer File "/usr/local/python3/lib/python3.7/site-packages/keras/engine/base_layer.py", line 43, in <module> from keras.mixed_precision import loss_scale_optimizer File "/usr/local/python3/lib/python3.7/site-packages/keras/mixed_precision/loss_scale_optimizer.py", line 18, in <module> from keras import optimizers File "/usr/local/python3/lib/python3.7/site-packages/keras/optimizers.py", line 26, in <module> from keras.optimizer_v2 import adadelta as adadelta_v2 File "/usr/local/python3/lib/python3.7/site-packages/keras/optimizer_v2/adadelta.py", line 22, in <module> from keras.optimizer_v2 import optimizer_v2 File "/usr/local/python3/lib/python3.7/site-packages/keras/optimizer_v2/optimizer_v2.py", line 37, in <module> "/tensorflow/api/keras/optimizers", "keras optimizer usage", "method") File "/usr/local/python3/lib/python3.7/site-packages/tensorflow/python/eager/monitoring.py", line 361, in __init__ len(labels), name, description, *labels) File "/usr/local/python3/lib/python3.7/site-packages/tensorflow/python/eager/monitoring.py", line 135, in __init__ self._metric = self._metric_methods[self._label_length].create(*args) tensorflow.python.framework.errors_impl.AlreadyExistsError: Another metric with the same name already exists.
Tensorflow版本是2.6.1,keras版本是2.7
Tensorflow2.6 的发行说明中,Keras 被拆分为单独的 PIP 包(keras),其代码已移至 GitHub 存储库 keras-team/keras。tf.keras 的 API 端点保持不变,但现在由 keras PIP 包支持。tensorflow/python/keras 中的现有代码是一个陈旧的副本,将在未来版本 (2.7) 中删除。请删除对 tensorflow.python.keras 的任何导入,并将它们替换为公共 tf.keras API。
解决方案:pip install keras==2.6.0
参考:https://stackoverflow.com/questions/58012741/error-importing-tensorflow-alreadyexistserror-another-metric-with-the-same-nam
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。