我正在使用 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 的每个代码中都收到此错误。 有谁知道如何解决这个问题?
系统配置:
最佳答案
Tensorflow 在导入过程中构建单例作为副作用。导入两次会导致再次创建单例,这是不受支持的。请不要导入两次。
关于python - 导入 tensorflow "AlreadyExistsError: Another metric with the same name already exists."时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58012741/