尝试在jupyter笔记本上使用tensforflow集线器,我安装了最新的tensorflow。但是,当我试图导入tensorflow_hub import tensorflow_hub as hub时,会出现一个错误:ImportError:无法从'tensorflow.python.tpu.tpu_embedding‘tensorflow.python.tpu.tpu_embedding导入名称'MomentumParameters’
我试过使用conda install -c anaconda tensorflow-hub在anaconda上安装tensorflow集线器,在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)发布于 2021-11-14 16:10:17
我将我的TensorFlow集线器降级为2.3版(与我的tf相同)及其工作
https://stackoverflow.com/questions/66719924
复制相似问题