AttributeError: 模块“tensorflow"没有属性“float32" [英] AttributeError: module 'tensorflow' has no attribute 'float32'

查看:116
本文介绍了AttributeError: 模块“tensorflow"没有属性“float32"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在为 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回溯(最近一次调用最后一次):文件model_builder_test.py",第 21 行,在 <module> 中.从 object_detection.builders 导入 model_builder文件C:\Users\User\models\research\object_detection\builders\model_builder.py",第 17 行,在 <module> 中.从 object_detection.builders 导入 anchor_generator_builder文件C:\Users\User\models\research\object_detection\builders\anchor_generator_builder.py",第 18 行,在 <module> 中.从 object_detection.anchor_generators 导入 grid_anchor_generator文件C:\Users\User\models\research\object_detection\anchor_generators\grid_anchor_generator.py",第 27 行,在 <module> 中.从 object_detection.utils 导入操作文件C:\Users\User\models\research\object_detection\utils\ops.py",第 282 行,在 <module> 中.dtype=tf.float32):AttributeError: 模块tensorflow"没有属性float32"

解决方案

tensorflow 有 float32.

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

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

要修复它,您只需要使用以下命令重新安装 tensorflow

pip install --upgrade --force-reinstall tensorflow

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

While setting an environment for tensorflow models, when I run python model_builder_test.py at last step, causes AttributeError: module 'tensorflow' has no attribute 'float32', does someone know how to fix it? Thanks.

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'

解决方案

tensorflow has float32.

In [1]: import tensorflow as tf

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

Above is my output confirming that. This is a known problem while installing in windows.You can take a look Here.

To fix it, you just need to reinstall tensorflow using the following commang

pip install --upgrade --force-reinstall tensorflow

Note:One More common mistake is naming a module as tensorflow. this might make it to import this module you created which is empty

这篇关于AttributeError: 模块“tensorflow"没有属性“float32"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆