导入 tensorflow 时出错“AlreadyExistsError: 另一个同名指标已经存在." [英] Error importing tensorflow "AlreadyExistsError: Another metric with the same name already exists."

查看:343
本文介绍了导入 tensorflow 时出错“AlreadyExistsError: 另一个同名指标已经存在."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am running this simple code on Spyder 3.3 with Python 3.7 and Tensorlow 2.0:

import tensorflow as tf
print(tf.__version__)

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

When I try to run it again in the same IPython console, I get the following error:

文件/home/rodrigo/.local/lib/python3.7/site-packages/tensorflow_core/python/eager/monitoring.py",第 121 行,initself._metric = self._metric_methods[self._label_length].create(*args)

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:已存在另一个同名指标.

AlreadyExistsError: Another metric with the same name already exists.

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

If I close the IPython console, and then open it again, it works fine. I am getting this error in every code that imports Tensorflow. Does anyone know how to solve this?

系统配置:

  • Ubuntu 19.04
  • Spyder 3.3.2
  • Python 3.7.3
  • IPython 5.8.0
  • TensorFlow 2.0.0-rc2

推荐答案

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

Tensorflow constructs singletons as side effects during import. Importing twice results in the singletons being created again, which is not supported. Please never import twice.

这篇关于导入 tensorflow 时出错“AlreadyExistsError: 另一个同名指标已经存在."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆