如何解决张量流中的无“估计量”?

时间:2018-10-15 17:00:31

标签: tensorflow tensorflow-hub

我正在尝试从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'

3 个答案:

答案 0 :(得分:1)

我也遇到类似的错误,但它在Darkflow中 在做了很多谷歌之后,对我没有任何帮助,并做了很多尝试来解决它 但是我只是通过

提出了解决方案

对于Anaconda ->康达安装matplotlib ->康达安装熊猫 (应该更新两者的版本) 完成此操作后,重新启动笔记本电脑

对于普通IDLE -> pip安装熊猫 -> pip安装matplotlib

答案 1 :(得分: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。

答案 2 :(得分:0)

我通过执行pip install tensorflow-estimator==1.10.12将tensorflow-estimator更改为1.10.12,并解决了该问题。