python - Tensorflow 集线器错误“无法从 'tensorflow.python.tpu.tpu_embedding' 导入名称 'MomentumParameters'”
问题描述
尝试在 jupyter notebook 上使用 tensforflow hub,我安装了最新的 tensorflow。但是,当我尝试导入 tensorflow_hub 时import tensorflow_hub as hub
,出现错误:ImportError: cannot import name 'MomentumParameters' from 'tensorflow.python.tpu.tpu_embedding' (C:\Users\vedan\anaconda3\lib\site-packages\tensorflow\python \tpu\tpu_embedding.py)
我尝试在 anaconda cmd 上安装 tensorflow hubconda install -c anaconda tensorflow-hub
并在 jupyter 上使用!pip install --upgrade tensorflow-hub
这是整个错误
ImportError Traceback (most recent call last)
<ipython-input-14-5c017171c13e> in <module>
----> 1 import tensorflow_hub as hub
~\anaconda3\lib\site-packages\tensorflow_hub\__init__.py in <module>
86
87
---> 88 from tensorflow_hub.estimator import LatestModuleExporter
89 from tensorflow_hub.estimator import register_module_for_export
90 from tensorflow_hub.feature_column import image_embedding_column
~\anaconda3\lib\site-packages\tensorflow_hub\estimator.py in <module>
60
61
---> 62 class LatestModuleExporter(tf.compat.v1.estimator.Exporter):
63 """Regularly exports registered modules into timestamped directories.
64
~\anaconda3\lib\site-packages\tensorflow\python\util\lazy_loader.py in __getattr__(self, item)
60
61 def __getattr__(self, item):
---> 62 module = self._load()
63 return getattr(module, item)
64
~\anaconda3\lib\site-packages\tensorflow\python\util\lazy_loader.py in _load(self)
43 """Load the module and insert it into the parent's globals."""
44 # Import the target module and insert it into the parent's namespace
---> 45 module = importlib.import_module(self.__name__)
46 self._parent_module_globals[self._local_name] = module
47
~\anaconda3\lib\importlib\__init__.py in import_module(name, package)
125 break
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
128
129
~\anaconda3\lib\site-packages\tensorflow_estimator\python\estimator\api\_v1\estimator\__init__.py in <module>
8 import sys as _sys
9
---> 10 from tensorflow_estimator.python.estimator.api._v1.estimator import experimental
11 from tensorflow_estimator.python.estimator.api._v1.estimator import export
12 from tensorflow_estimator.python.estimator.api._v1.estimator import inputs
~\anaconda3\lib\site-packages\tensorflow_estimator\__init__.py in <module>
8 import sys as _sys
9
---> 10 from tensorflow_estimator._api.v1 import estimator
11
12 del _print_function
~\anaconda3\lib\site-packages\tensorflow_estimator\_api\v1\estimator\__init__.py in <module>
11 from tensorflow_estimator._api.v1.estimator import export
12 from tensorflow_estimator._api.v1.estimator import inputs
---> 13 from tensorflow_estimator._api.v1.estimator import tpu
14 from tensorflow_estimator.python.estimator.canned.baseline import BaselineClassifier
15 from tensorflow_estimator.python.estimator.canned.baseline import BaselineEstimator
~\anaconda3\lib\site-packages\tensorflow_estimator\_api\v1\estimator\tpu\__init__.py in <module>
8 import sys as _sys
9
---> 10 from tensorflow_estimator._api.v1.estimator.tpu import experimental
11 from tensorflow_estimator.python.estimator.tpu.tpu_config import InputPipelineConfig
12 from tensorflow_estimator.python.estimator.tpu.tpu_config import RunConfig
~\anaconda3\lib\site-packages\tensorflow_estimator\_api\v1\estimator\tpu\experimental\__init__.py in <module>
8 import sys as _sys
9
---> 10 from tensorflow_estimator.python.estimator.tpu._tpu_estimator_embedding import EmbeddingConfigSpec
11
12 del _print_function
~\anaconda3\lib\site-packages\tensorflow_estimator\python\estimator\tpu\_tpu_estimator_embedding.py in <module>
33 from tensorflow.python.tpu.tpu_embedding import AdamParameters
34 from tensorflow.python.tpu.tpu_embedding import FtrlParameters
---> 35 from tensorflow.python.tpu.tpu_embedding import MomentumParameters
36 from tensorflow.python.tpu.tpu_embedding import RMSPropParameters
37 from tensorflow.python.tpu.tpu_embedding import StochasticGradientDescentParameters
ImportError: cannot import name 'MomentumParameters' from 'tensorflow.python.tpu.tpu_embedding' (C:\Users\vedan\anaconda3\lib\site-packages\tensorflow\python\tpu\tpu_embedding.py)
解决方案
我将 TensorFlow 集线器降级到 2.3 版(与我的 tf GPU 相同)及其工作
推荐阅读
- php - PHP preg_match_all 问题
- javascript - 如何使用nodejs检查mongodb中是否存在登录凭据?
- android - Android Studio 无法让模拟器运行
- android - Android Toast 消息回调或任何触摸事件
- java - 将 java (JAR) 应用程序转换为 windows exe
- c# - 未注册类型“Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityUser]”的服务
- ios - 符号化后如何从 App Store 崩溃日志中找到根本原因?
- xcode9 - 使用 Xcode 构建数据库时遇到问题
- excel - 如何在 Excel 中的下拉列表中添加自定义值
- android - 将 GL 像素传输到相机像素以进行广播