简体   繁体   English

AttributeError:模块'tensorflow'没有属性'float32'

[英]AttributeError: module 'tensorflow' has no attribute 'float32'

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? 在为tensorflow模型设置环境时,当我在最后一步运行python model_builder_test.py时,导致AttributeError: module 'tensorflow' has no attribute 'float32' ,有人知道如何修复它吗? Thanks. 谢谢。

https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md 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. tensorflow有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 . 这是在windows中安装时的一个已知问题。你可以看看这里

To fix it, you just need to reinstall tensorflow using the following commang 为了解决这个问题,你只需要重新安装tensorflow使用以下commang

pip install --upgrade --force-reinstall tensorflow

Note:One More common mistake is naming a module as tensorflow . 注意:一个更常见的错误是将模块命名为tensorflow this might make it to import this module you created which is empty 这可能会导致您导入您创建的此模块为空

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Tensorflow AttributeError: &#39;numpy.float32&#39; 对象没有属性 &#39;value&#39; - Tensorflow AttributeError: 'numpy.float32' object has no attribute 'value' AttributeError:模块'numpy'没有属性'float' - AttributeError: module 'numpy' has no attribute 'float' 如何在 tensorflow 中将字符串转换为 float32 - How to convert string to float32 in tensorflow AttributeError: 模块“tensorflow”没有属性“GraphDef” - AttributeError: module 'tensorflow' has no attribute 'GraphDef' AttributeError:模块“ tensorflow”没有属性“ keras” - AttributeError: module 'tensorflow' has no attribute 'keras' 属性错误:模块“tensorflow”没有属性“变量”“错误” - AttributeError: module 'tensorflow' has no attribute 'Variable' “ERROR” AttributeError: 模块“tensorflow”没有属性“layers” - AttributeError: module 'tensorflow' has no attribute 'layers' AttributeError:模块“tensorflow”没有属性“assign” - AttributeError: module 'tensorflow' has no attribute 'assign' tensorflow AttributeError: 'module' object 没有属性 'data' - tensorflow AttributeError: 'module' object has no attribute 'data' AttributeError: 模块 'tensorflow' 没有属性 'placeholder' - AttributeError: module 'tensorflow' has no attribute 'placeholder'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM