AttributeError:模块“ tensorboard”没有属性“ lazy”

时间:2019-08-23 03:06:56

标签: python tensorflow keras tensorboard attributeerror

我有一个使用Keras和tensorflow后端的生成对抗网络。我正在运行Tensorflow 1.14.0,Python 3.7.4和Keras 2.2.4。完整的错误是:

Using TensorFlow backend.
Traceback (most recent call last):
  File "C:/Users/Riley/PycharmProjects/shoeGAN/shoeWGAN.py", line 7, in <module>
    from keras.layers import *
  File "C:\Users\Riley\AppData\Local\Programs\Python\Python35\lib\site-packages\keras\__init__.py", line 3, in <module>
    from . import utils
  File "C:\Users\Riley\AppData\Local\Programs\Python\Python35\lib\site-packages\keras\utils\__init__.py", line 6, in <module>
    from . import conv_utils
  File "C:\Users\Riley\AppData\Local\Programs\Python\Python35\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module>
    from .. import backend as K
  File "C:\Users\Riley\AppData\Local\Programs\Python\Python35\lib\site-packages\keras\backend\__init__.py", line 89, in <module>
    from .tensorflow_backend import *
  File "C:\Users\Riley\AppData\Local\Programs\Python\Python35\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in <module>
    import tensorflow as tf
  File "C:\Users\Riley\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\__init__.py", line 35, in <module>
    from tensorflow._api.v1 import compat
  File "C:\Users\Riley\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\_api\v1\compat\__init__.py", line 22, in <module>
    from tensorflow._api.v1.compat import v2
  File "C:\Users\Riley\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\_api\v1\compat\v2\__init__.py", line 303, in <module>
    from tensorboard.summary._tf import summary
  File "C:\Users\Riley\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorboard\summary\__init__.py", line 32, in <module>
    from tensorboard.summary import v2
  File "C:\Users\Riley\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorboard\summary\v2.py", line 24, in <module>
    from tensorboard.plugins.audio.summary_v2 import audio
  File "C:\Users\Riley\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorboard\plugins\audio\summary_v2.py", line 30, in <module>
    from tensorboard.compat import tf2 as tf
  File "C:\Users\Riley\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorboard\compat\__init__.py", line 28, in <module>
    import tensorboard.lazy as _lazy
AttributeError: module 'tensorboard' has no attribute 'lazy'

我没有提供完整的代码,因为在导入期间会出现错误,如下所示:

import os

import matplotlib.pyplot as plt

import numpy as np

from keras.layers import *
from keras.models import *
from keras.optimizers import *
from keras.initializers import *
from keras.callbacks import *
from keras.utils.generic_utils import Progbar
from keras.preprocessing.image import save_img

我尝试过的事情:

  • 重新启动计算机。
  • 使用pip卸载并重新安装所有tensorflow和tensorboard库,然后重新启动计算机。
  • 最高答案here

有什么想法吗?谢谢!

3 个答案:

答案 0 :(得分:1)

Here是说明您在Github上的错误的问题。

起初,有人指出,只有TensorBoard(tb-nightly)的夜间版本才与TF 2.0预览版兼容,而1.12.2则无法正常工作。

最后的评论之一表明tensorflow-tensorboardtensorboard的顺序很重要,因此您应该拳头

pip install tensorflow-tensorboard==1.5.1

然后

pip install tensorboard==1.14.0

希望这会有所帮助!

答案 1 :(得分:0)

tensorflow-tensorboard 已被弃用,因此您应该卸载它并使用最新版本的 tensorboard(在撰写此回复时为 2.4.0)。

pip install tensorboard

答案 2 :(得分:0)

您应该使用以下命令卸载 tensorflow-tensorboard。

pip uninstall tensorflow-tensorboard