【问题标题】:AttributeError: module 'tensorflow' has no attribute 'random' for tensorflow version 1.3AttributeError:模块 'tensorflow' 没有 tensorflow 1.3 版的属性 'random'
【发布时间】:2021-01-04 12:44:30
【问题描述】:

我使用的是 tensorflow 版本 1.3.0 库达版本 8 和 cuDNN 版本 6

当我运行python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))" 时,我看到以下错误:-

Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'tensorflow' has no attribute 'random'

请帮助我,因为我被困了很长时间。

【问题讨论】:

    标签: python python-3.x tensorflow


    【解决方案1】:

    Tensorflow 1.3 使用 tf.random_normal 而不是 tf.random.normal

    你会发现 TensorFlow 1.3 documentation on github


    注意:除非明确要求,否则我建议您不要使用 tf 1.3:tf1 不再接收任何更新。

    【讨论】:

      【解决方案2】:

      升级你的 tensorflow 版本

      pip install --upgrade tensorflow
      

      另外,请检查this StackOverflow question

      【讨论】:

        猜你喜欢
        • 2019-10-05
        • 2019-08-04
        • 1970-01-01
        • 2020-12-06
        • 2017-04-08
        • 2020-02-04
        • 2020-02-12
        • 2019-01-10
        • 2019-10-01
        相关资源
        最近更新 更多