0

我正在尝试从 tensorflow 实现代码:

https://colab.research.google.com/github/tensorflow/hub/blob/master/examples/colab/semantic_similarity_with_tf_hub_universal_encoder.ipynb

但是,我遇到了 tensorflow lib 的错误如下,我尝试卸载并重新安装 tensorflow 但没有工作,以前有人遇到过这个错误吗?

  import tensorflow as tf
  File "/data/d14127800/py3_170/lib/python3.5/site-packages/tensorflow/__init__.py", line 22, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/data/d14127800/py3_170/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 52, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "/data/d14127800/py3_170/lib/python3.5/site-packages/tensorflow/core/framework/graph_pb2.py", line 6, in <module>
    from google.protobuf import descriptor as _descriptor
  File "/data/d14127800/py3_170/lib/python3.5/site-packages/google/protobuf/__init__.py", line 37, in <module>
    __import__('pkg_resources').declare_namespace(__name__)
  File "/data/d14127800/py3_170/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3112, in <module>
    @_call_aside
  File "/data/d14127800/py3_170/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3096, in _call_aside
    f(*args, **kwargs)
  File "/data/d14127800/py3_170/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3140, in _initialize_master_working_set
    for dist in working_set
  File "/data/d14127800/py3_170/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3140, in <genexpr>
    for dist in working_set
  File "/data/d14127800/py3_170/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2647, in activate
    declare_namespace(pkg)
  File "/data/d14127800/py3_170/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2184, in declare_namespace
    _handle_ns(packageName, path_item)
  File "/data/d14127800/py3_170/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2117, in _handle_ns
    loader.load_module(packageName)
  File "/data/d14127800/dataset10/google.py", line 4, in <module>
    import tensorflow_hub as hub
  File "/data/d14127800/py3_170/lib/python3.5/site-packages/tensorflow_hub/__init__.py", line 23, in <module>
    from tensorflow_hub.estimator import LatestModuleExporter
  File "/data/d14127800/py3_170/lib/python3.5/site-packages/tensorflow_hub/estimator.py", line 61, in <module>
    class LatestModuleExporter(tf.estimator.Exporter):
AttributeError: module 'tensorflow' has no attribute 'estimator'
4

3 回答 3

1

我也面临类似的错误,但它在 Darkflow 在做了很多谷歌之后对我没有任何工作并且做了很多尝试来解决它但是我只是通过做就得出了解决方案

对于 Anaconda ->conda install matplotlib ->conda install pandas (应该更新两者的版本)这样做之后重新启动你的笔记本

对于 Normal IDLE ->pip install pandas ->pip install matplotlib

于 2019-01-20T13:53:19.000 回答
1

我通过做将 tensorflow-estimator 更改为 1.10.12 pip install tensorflow-estimator==1.10.12,它解决了这个问题。

于 2019-05-14T05:40:42.770 回答
0

Estimator 在 TF 1.1.0 版本中从 tf.contrib.learn.Estimator 移至 tf.estimator.Estimator。使用以下命令确保您的 TensorFlow 版本更高:

pip show tensorflow

或者

pip show tensorflow-gpu 

如果您使用的是 GPU 版本。

如果它较低,您可以使用以下命令更新 Tensorflow:

pip install --upgrade tensorflow

或者

pip isntall --upgrade tensorflow-gpu

或使用 tf.contrib.learn.Estimator 代替。

于 2018-10-16T11:43:42.797 回答