【问题标题】:Bazel & Tensorflow: Inception v3 retraining: AttributeError: 'int' object attribute '__doc__' is read-onlyBazel & Tensorflow:Inception v3 再训练:AttributeError:'int'对象属性'__doc__'是只读的
【发布时间】:2018-01-29 11:21:51
【问题描述】:

我目前正在按照本教程重新训练 Inception v3 神经网络的顶层: https://www.youtube.com/watch?v=m2D02eZTB4s https://www.tensorflow.org/tutorials/image_retraining

我已经设置了一个运行 Ubuntu 14.04.5 LTS 64bit 的 VirtualBox

python 2.7.6

张量流 1.3.0

bazel 构建标签:0.5.3

但是,当我使用命令时

bazel-bin/tensorflow/examples/image_retraining/retrain --image_dir /media/myImageDir

然后我的过程与教程不同。出现两个导入错误,通过安装包很容易解决。

File "/home/tensorflow/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/framework/ops.py", line 28, in <module>
    from autograd import core as ag_core
ImportError: No module named autograd

File "/home/tensorflow/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/ops/variable_scope.py", line 24, in <module>
    import enum  # pylint: disable=g-bad-import-order
ImportError: No module named enum

安装autograd和enum后,再次尝试执行retrain命令时,出现如下错误:

Traceback (most recent call last):
File "/home/tensorflow/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/examples/image_retraining/retrain.py", line 108, in <module>
import tensorflow as tf
File "/home/tensorflow/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/tensorflow/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 63, in <module>
from tensorflow.python.framework.framework_lib import *
File "/home/tensorflow/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/framework/framework_lib.py", line 102, in <module>
from tensorflow.python.framework.importer import import_graph_def
File "/home/tensorflow/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/framework/importer.py", line 30, in <module>
from tensorflow.python.framework import function
File "/home/tensorflow/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/framework/function.py", line 34, in <module>
from tensorflow.python.ops import variable_scope as vs
File "/home/tensorflow/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/ops/variable_scope.py", line 191, in <module>
"""
AttributeError: 'int' object attribute '__doc__' is read-only

文件“/home/tensorflow/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/ops/variable_scope.py”第191行如下:

AUTO_REUSE.__doc__ = """
When passed in as the value for the `reuse` flag, AUTO_REUSE indicates that
get_variable() should create the requested variable if it doesn't exist or, if
it does exist, simply return it.
"""

现在我真的不想干预这段代码,因为它不是我编写的自定义代码。我怀疑还有另一个问题,但我完全不知道它可能是什么。我希望这里有人遇到过类似的问题和/或可以给我任何建议。

【问题讨论】:

  • 看来你没有正确安装tensorflow,当你尝试导入tensorflow时出现错误。尝试重新安装 tensorflow
  • 如果我在 python 解释器中导入 tensorflow,它可以工作

标签: python tensorflow neural-network bazel pre-trained-model


【解决方案1】:

我通过粗暴的修改源代码解决了这个问题!!!

【讨论】:

    【解决方案2】:

    我也刚遇到这个,我注意到最近在 tensorflow 中有一个 issue 与此有关。解决方法如下:

    • 卸载枚举,如果你已经安装了它:sudo pip remove enum
    • 安装此兼容版本的枚举:sudo apt-get install python-enum34
    • 再试一次。

    【讨论】:

      猜你喜欢
      • 2016-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-31
      • 2021-11-30
      • 2020-03-26
      • 2013-04-15
      相关资源
      最近更新 更多