首页 文章

AttributeError:module 'tensorflow'没有属性'float32'

提问于
浏览
0

在为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

    tensorflow有float32 .

    In [1]: import tensorflow as tf
    
    In [2]: tf.float32
    Out[2]: tf.float32
    

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

    要解决此问题,您只需使用以下commang重新安装 tensorflow

    pip install --upgrade --force-reinstall tensorflow
    

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

  • 1

    我用命令修复了问题:pip install --upgrade --force-reinstall tensorflow

相关问题