python - 属性错误 : module 'tensorflow' has no attribute 'float32'

标签 python windows tensorflow

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

最佳答案

tensorflow 有 float32。

In [1]: import tensorflow as tf

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

以上是我确认的输出。这是windows安装时的一个已知问题,可以看看Here .

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

pip install --upgrade --force-reinstall tensorflow

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

关于python - 属性错误 : module 'tensorflow' has no attribute 'float32' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51654346/

相关文章:

c# - 如何保证我的 WPF 应用程序的永久管理员权限

python - tensorflow in_top_k 的输入应该是 1 级还是 2 级?

machine-learning - Tensorflow 中的 Dropconnect

python - 如何确保脚本始终使用cron运行?

windows - 试图更换;使用 cmd 文件在 txt 文件中使用 ASCII 控制字符

python - 用我自己的数据进行tensorflow对象检测,你能帮我吗?

windows - 有没有办法检查 MS 安全中心的病毒防护状态?

python - 如何在 TensorFlow import_graph_def 期间更改输入维度

Python正则表达式困惑

python - 在pytorch的神经网络中将参数限制为-1、0或1