首页 > 解决方案 > 导入 Tensorflow Hub 时出现问题“模块‘tensorflow.tools.docs.doc_controls’没有属性‘inheritable_header’”

问题描述

我面临一个关于 TensorFlow hub 导入的问题。以下是在终端中发布的错误。我用的tensorflow的版本是2.6,tensorflow-hub的版本是0.12.0。我使用 pip install 安装了它们。我有点急于完成我的项目,非常感谢您的帮助。

File "/home/bannigo/catkin_ws/src/motorAI_assign/scripts/task1_1.py", line 21, in
import tensorflow_hub as hub
File "/home/bannigo/.local/lib/python3.6/site-packages/tensorflow_hub/init.py", line 
88, in
from tensorflow_hub.estimator import LatestModuleExporter
File "/home/bannigo/.local/lib/python3.6/site-packages/tensorflow_hub/estimator.py",         
line 62, in
class LatestModuleExporter(tf.compat.v1.estimator.Exporter):
File "/home/bannigo/.local/lib/python3.6/site-    
packages/tensorflow/python/util/lazy_loader.py", line 62, in getattr
module = self._load()
File "/home/bannigo/.local/lib/python3.6/site- 
packages/tensorflow/python/util/lazy_loader.py", line 45, in _load
module = importlib.import_module(self.name)
File "/usr/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/bannigo/.local/lib/python3.6/site-packages/tensorflow_estimator/init.py", 
line 10, in
from tensorflow_estimator._api.v1 import estimator
File "/home/bannigo/.local/lib/python3.6/site- 
packages/tensorflow_estimator/_api/v1/estimator/init.py", line 10, in
from tensorflow_estimator._api.v1.estimator import experimental
File "/home/bannigo/.local/lib/python3.6/site- 
packages/tensorflow_estimator/_api/v1/estimator/experimental/init.py", line 10, in
from tensorflow_estimator.python.estimator.canned.dnn import dnn_logit_fn_builder
File "/home/bannigo/.local/lib/python3.6/site- 
packages/tensorflow_estimator/python/estimator/canned/dnn.py", line 27, in
from tensorflow_estimator.python.estimator import estimator
File "/home/bannigo/.local/lib/python3.6/site- 
packages/tensorflow_estimator/python/estimator/estimator.py", line 70, in
@doc_controls.inheritable_header
AttributeError: module 'tensorflow.tools.docs.doc_controls' has no attribute 
'inheritable_header'

标签: tensorflowpython-3.6tensorflow-hub

解决方案


这是一个已知问题:https ://github.com/tensorflow/hub/issues/819 。一种临时解决方法是降级tensorflow-estimator

pip install -U tensorflow-estimator==2.6.0


推荐阅读