【问题标题】:AttributeError: module 'tensorflow.contrib' has no attribute 'estimator'AttributeError:模块“tensorflow.contrib”没有属性“估计器”
【发布时间】:2018-09-03 16:01:23
【问题描述】:

我在 Windows 10 的 anaconda 中安装了 Tensorflow,但在导入某些模块时出现错误:

my_optimizer = tf.contrib.estimator.clip_gradients_by_norm(my_optimizer, 5.0)

AttributeError: 模块 'tensorflow.contrib' 没有属性 'estimator'

我该如何解决这个错误?

【问题讨论】:

  • 您能说明您使用了哪些“导入”语句吗?如果您在“import tensorflow.contrib”之后收到此错误,则可能表明存在安装问题。
  • 您使用的是哪个 trensdsorflow 版本。 ???
  • 我有最新版本的 tensorflo,当我运行 'import tensorflow.contrib' 时,我没有收到任何错误,但是当我运行 'my_optimizer = tf.contrib.estimator.clip_gradients_by_norm(my_optimizer, 5.0 )' 我得到了错误,我已经告诉过你了,而且当我运行'from tensorflow.python.data import Dataset' 错误“ModuleNotFoundError: No module named 'tensorflow.python.data'”时我也遇到了错误

标签: python tensorflow


【解决方案1】:

尝试将 tensorflow 导入为tf

【讨论】:

    【解决方案2】:

    我知道这个话题有点老了,但我的解决方案是:

    sudo pip install --upgrade tensorflow==1.12.0
    

    这里是 1.12.0,但使用的是最新的稳定更新。

    换句话说,尝试更新您的 tensorflow 安装,一切都会变得更好。

    【讨论】:

      猜你喜欢
      • 2018-08-30
      • 2018-04-14
      • 2019-02-18
      • 1970-01-01
      • 2021-10-06
      • 1970-01-01
      • 2020-01-01
      • 2019-07-20
      相关资源
      最近更新 更多