AttributeError:模块“ tensorflow”没有属性“ float32”

时间:2018-08-02 13:00:36

标签: python windows tensorflow

在为张量流模型设置环境时,当我在最后一步运行python model_builder_test.py时,导致AttributeError: module 'tensorflow' has no attribute 'float32'的发生,有人知道如何解决吗?谢谢。

https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md

PS C:\Users\User\models\research\object_detection\builders> python model_builder_test.py
Traceback (most recent call last):
  File "model_builder_test.py", line 21, in <module>
    from object_detection.builders import model_builder
  File "C:\Users\User\models\research\object_detection\builders\model_builder.py", line 17, in <module>
    from object_detection.builders import anchor_generator_builder
  File "C:\Users\User\models\research\object_detection\builders\anchor_generator_builder.py", line 18, in <module>
    from object_detection.anchor_generators import grid_anchor_generator
  File "C:\Users\User\models\research\object_detection\anchor_generators\grid_anchor_generator.py", line 27, in <module>
    from object_detection.utils import ops
  File "C:\Users\User\models\research\object_detection\utils\ops.py", line 282, in <module>
    dtype=tf.float32):
AttributeError: module 'tensorflow' has no attribute 'float32'

2 个答案:

答案 0 :(得分:2)

tensorflow具有float32。

576

以上是我的输出确认这一点。在Windows中安装时,这是一个已知问题。您可以查看Here

要修复此问题,只需使用以下命令重新安装ABCDEFGHIJKLMNOP

In [1]: import tensorflow as tf

In [2]: tf.float32
Out[2]: tf.float32

注意:一个更常见的错误是将模块命名为tensorflow。这可能会使它导入您创建的空模块

答案 1 :(得分:0)

我使用以下命令解决了该问题: pip install --upgrade --force-reinstall张量流