【问题标题】:Module 'tensorflow.tools.docs.doc_controls' has no attribute 'inheritable_header'模块“tensorflow.tools.docs.doc_controls”没有属性“inheritable_header”
【发布时间】:2021-12-16 00:57:00
【问题描述】:

今天从 tensorflow 运行 estimator,出现了这个错误,知道如何解决吗?

File "C:\Users\ASUS Laptop\anaconda3\envs\tf_gpu\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 70, in <module>
    @doc_controls.inheritable_header("""\
AttributeError: module 'tensorflow.tools.docs.doc_controls' has no attribute 'inheritable_header'

这是在我的 estimator.py 文件中: @doc_controls.inheritable_header("""
警告:不建议将估算器用于新代码。估算器运行 v1.Session 风格的代码更难正确编写,以及 可能会出现意外行为,尤其是与 TF 2 代码结合使用时。估算器 确实属于我们的 compatibility guarantees,但会 除了安全漏洞之外,没有收到任何修复。见 migration guide 了解详情。 """)

【问题讨论】:

    标签: python tensorflow machine-learning tensorflow2.0 tensorflow-estimator


    【解决方案1】:

    检查您的tensorflow-estimator 版本,10 月 30 日的 2.7 版本似乎与某些库不兼容。

    尝试 2.6 版:

    pip install --upgrade tensorflow-estimator==2.6.0
    

    编辑:- 还将 keras 降级到 2.6.0 版本:

    pip install --upgrade keras==2.6.0
    

    【讨论】:

    • 这给了我一个AlreadyExistsError: Another metric with the same name already exists.
    • 这里更具体一点,tensorflow-estimator==2.7.0 使用来自tensorflow 的装饰器,直到tensorflow==2.7.0 才引入。 tensorflow==2.6.0(可能是所有 2.6.x 版本),不幸的是,只有引脚 tensorflow-estimator~=2.6,这使得 tfe==2.7.0 被拉入。而 tfe 没有 tensorflow 作为它自己的显式依赖,导致我们在这里看到的语义版本控制的细分。
    • Pranav 对上述AlreadyExistsError 的编辑帐户。
    • 顺便说一句,tensorflow 2.6.2 已经发布,它正确地设置了 tensorflow-estimator 版本的上限,从而解决了这些问题。
    【解决方案2】:

    升级或降级 tensorflow-estimator 包以匹配 tensorflow 版本。

    【讨论】:

    • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 2021-12-15
    • 1970-01-01
    • 2020-06-04
    • 2021-12-24
    • 2015-05-08
    • 2020-10-17
    • 2020-10-03
    • 2018-08-11
    • 2020-01-01
    相关资源
    最近更新 更多