python - 导入 tensorflow "AlreadyExistsError: Another metric with the same name already exists."时出错

标签 python tensorflow

我正在使用 Python 3.7 和 Tensorlow 2.0 在 Spyder 3.3 上运行这个简单的代码:

import tensorflow as tf
print(tf.__version__)

当我尝试在同一个 IPython 控制台中再次运行它时,出现以下错误:

File "/home/rodrigo/.local/lib/python3.7/site-packages/tensorflow_core/python/eager/monitoring.py", line 121, in init self._metric = self._metric_methods[self._label_length].create(*args)

AlreadyExistsError: Another metric with the same name already exists.



如果我关闭 IPython 控制台,然后再次打开它,它工作正常。我在导入 Tensorflow 的每个代码中都收到此错误。 有谁知道如何解决这个问题?

系统配置:
  • Ubuntu 19.04
  • Spyder 3.3.2
  • Python 3.7.3
  • IPython 5.8.0
  • TensorFlow 2.0.0-rc2
  • 最佳答案

    Tensorflow 在导入过程中构建单例作为副作用。导入两次会导致再次创建单例,这是不受支持的。请不要导入两次。

    关于python - 导入 tensorflow "AlreadyExistsError: Another metric with the same name already exists."时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58012741/

    相关文章:

    python - selenium.common.exceptions.ElementNotVisibleException : Message: element not visible while invoking send_keys in ubuntu headless browser through python

    python - 通过属性比较对象实例是否相等

    python - 我试图向代理发送 python 请求,但失败了

    python - tf.image.decode_jpeg() 返回零矩阵

    python - 应用资源时访问多个变量的梯度 [Tensorflow]

    java - 在java中加载DNNClassifier

    python - 合并从 contigs.fa 生成的两行

    python - Selenium 使用 Python - Geckodriver 可执行文件需要在 PATH 中

    python - tf.group 和 tensorflow 集合有什么不同?

    python - 如何将字符串数据保存到 TFRecord?