how to solve the no 'estimator' in tensorflow? - tensorflow

I am trying to implement a code from tensorflow:
https://colab.research.google.com/github/tensorflow/hub/blob/master/examples/colab/semantic_similarity_with_tf_hub_universal_encoder.ipynb
However, I had the error of tensorflow lib as follows, I have tried uninstall and reinstall the tensorflow but no working, is anyone facing this error before?
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'

I also face similar error but it was in Darkflow
After doing much google nothing worked for me and did many attempt to resolve it
But I came out with solution just by doing
for Anaconda
->conda install matplotlib
->conda install pandas
(It should be updated Version of Both)
After doing this ReStart Your NoteBook
For Normal IDLE
->pip install pandas
->pip install matplotlib

I changed the tensorflow-estimator to 1.10.12 by doing pip install tensorflow-estimator==1.10.12 and it resolved the issue.

Estimator was moved from tf.contrib.learn.Estimator to tf.estimator.Estimator with the TF 1.1.0 release. Make sure that your Tensorflow version is higher using:
pip show tensorflow
or
pip show tensorflow-gpu
if you are using the GPU version.
If it is lower, you can update Tensorflow with:
pip install --upgrade tensorflow
or
pip isntall --upgrade tensorflow-gpu
or use tf.contrib.learn.Estimator instead.

Related

Tensorflow installation error (ERROR: Could not find a version that satisfies the requirement tensorflow)

pip3 install --upgrade tensorflowI tried installing tensorflow in my virtual environment and kept on running into this error. I have the necessary prerequisites for pip3(pip 21.0.1) and python3(Python 3.7.9) version and cannot understand why this error is occurring. Any inputs to solve this error would be very much appreciated.
pip3 install --upgrade tensorflow
ERROR: Could not find a version that satisfies the requirement tensorflow
ERROR: No matching distribution found for tensorflow
Error message
pip3 install https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.8.0-py3-none-any.whl
This line worked for me but then this error popped up while checking for the tensorflow version
python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/nvidia/projects/hand_gesture/venv/lib/python3.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/nvidia/projects/hand_gesture/venv/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/nvidia/projects/hand_gesture/venv/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/nvidia/projects/hand_gesture/venv/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 114
def TFE_ContextOptionsSetAsync(arg1, async):
^
SyntaxError: invalid syntax
error terminal description

No module named 'tensorflow_datasets.image.cityscapes'

I installed TensorFlow Datasets using conda, as:
conda install -c anaconda tensorflow-datasets
I've tried importing Cityscapes:
from tensorflow_datasets.image.cityscapes import Cityscapes
but this raises the following error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'tensorflow_datasets.image.cityscapes'
How can I fix it?
PS: I can import the following without errors:
import tensorflow_datasets as tfds
Edit:
I've already downloaded Cityscapes data, as recommended in the official guide.

"ImportError: DLL load failed: The specified module could not be found" when trying to import gensim

While trying to import gensim, I run into the following error
Traceback (most recent call last):
File "c:\Users\usr\Documents\hello\test.py", line 3, in <module>
import gensim
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\gensim\__init__.py", line 5, in <module>
from gensim import parsing, corpora, matutils, interfaces, models, similarities, summarization, utils # noqa:F401
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\gensim\corpora\__init__.py", line 6, in <module>
from .indexedcorpus import IndexedCorpus # noqa:F401 must appear before the other classes
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\gensim\corpora\indexedcorpus.py", line 15, in <module>
from gensim import interfaces, utils
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\gensim\interfaces.py", line 21, in <module>
from gensim import utils, matutils
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\gensim\matutils.py", line 21, in <module>
from scipy.stats import entropy
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\stats\__init__.py", line 384, in <module>
from .stats import *
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\stats\stats.py", line 179, in <module>
from scipy.spatial.distance import cdist
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\spatial\__init__.py", line 99, in <module>
from .qhull import *
ImportError: DLL load failed: The specified module could not be found.
I have tried uninstalling numpy, scipy and gensim using pip in the command prompt and installing them again, but this does not resolve the issue.
I have also looked at the suggestions to a similar problem here, and tried installing numpy‑1.19.0+mkl‑cp37‑cp37m‑win_amd64.whl, but it resulted in a separate error Importing the numpy c-extensions failed. Thus, I have stuck to using numpy, scipy and gensim installed via pip.
Additionally, I installed scipy version 1.4.1 as the latest 1.5.0 version will give the following error as described in this link:
Error when loading scipy: OSError: [WinError 126] The specified module could not be found
Any help is greatly appreciated!
For additional information, I am using Python 3.7 and Windows 10.
I had the same problem and tried various things, but the only thing that worked for me was to install an older version of Gensim.
pip install gensim==3.7.0

ModuleNotFoundError: No module named 'nets'

Hi guys I'm having an error when I'm trying to run the training using this command:
> `python train.py --logtostderr --train_dir=training/
> --pipeline_config_path=training/ssd_mobilenet_v1_coco.config`
Traceback (most recent call last): File "train.py", line 51, in
<module> from object_detection.builders import model_builder File
"C:\tensorflow1\models\research\object_detection\builders\model_builder.py",
line 35, in <module> from object_detection.models import
faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res
File
"C:\tensorflow1\models\research\object_detection\models \faster_rcnn_inception_resnet_v2_feature_extractor.py",
line 28, in <module> from nets import inception_resnet_v2
ModuleNotFoundError: No module named 'nets
The nets module is in slim folder, you need to add the slim library to PYTHONPATH:
# From tensorflow/models/research/
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
Try Installing pip install nets and also check the site package and environment package for installed folders (It worked for me)

Cannot start tensorboard from console due to numpy issue

I'd like to make use of TensorBoard.I already saved training and validation data in the same directory as the rest of the project data using the tensorflow.keras.callbacks library.
I already pip reinstalled numpy, didn't work out. Then I deleted tb-nightly and tensorboard as I had them both for some reason and just pip reinstalled tb-nightly.
(Tensorflow) C:\Users\alias>python -c "print(__import__('numpy').__version__)"
1.16.2
(Tensorflow) C:\Users\alias>python -c "print(__import__('tensorflow').__version__)"
2.0.0-alpha0
(Tensorflow) C:\Users\alias>python -c "print(__import__('tensorboard.version').version.VERSION)"
1.14.0a20190301
When calling it via Anaconda prompt on a Win10-OS , the following happens:
(Tensorflow) C:\Users\alias>tensorboard --logdir=logs\
TensorBoard 1.14.0a20190301 at http://LAPTOP-4E1BJCAV:6006 (Press CTRL+C to quit)
Traceback (most recent call last):
File "c:\users\alias\anaconda3\envs\tensorflow\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\alias\anaconda3\envs\tensorflow\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\alias\Anaconda3\envs\Tensorflow\Scripts\tensorboard.exe\__main__.py", line 9, in <module>
File "c:\users\alias\anaconda3\envs\tensorflow\lib\site-packages\tensorboard\main.py", line 58, in run_main
app.run(tensorboard.main, flags_parser=tensorboard.configure)
File "c:\users\alias\anaconda3\envs\tensorflow\lib\site-packages\absl\app.py", line 300, in run
_run_main(main, args)
File "c:\users\alias\anaconda3\envs\tensorflow\lib\site-packages\absl\app.py", line 251, in _run_main
sys.exit(main(argv))
File "c:\users\alias\anaconda3\envs\tensorflow\lib\site-packages\tensorboard\program.py", line 228, in main
self._register_info(server)
File "c:\users\alias\anaconda3\envs\tensorflow\lib\site-packages\tensorboard\program.py", line 274, in _register_info
manager.write_info_file(info)
File "c:\users\alias\anaconda3\envs\tensorflow\lib\site-packages\tensorboard\manager.py", line 269, in write_info_file
payload = "%s\n" % _info_to_string(tensorboard_info)
File "c:\users\alias\anaconda3\envs\tensorflow\lib\site-packages\tensorboard\manager.py", line 129, in _info_to_string
for k in _TENSORBOARD_INFO_FIELDS
File "c:\users\alias\anaconda3\envs\tensorflow\lib\site-packages\tensorboard\manager.py", line 129, in <dictcomp>
for k in _TENSORBOARD_INFO_FIELDS
File "c:\users\alias\anaconda3\envs\tensorflow\lib\site-packages\tensorboard\manager.py", line 51, in <lambda>
(dt - datetime.datetime.fromtimestamp(0)).total_seconds()),
OSError: [Errno 22] Invalid argument
Would be glad about some help.
Thanks in advance!
Did you do a fresh install and or update recently?
Not sure if this applies to your case or not? Yesterday I installed the latest conda, for python 2.7, from scratch and updated to the latest packages after installation. Running python from pycharm or windows powershell and importing numpy would throw a multiarray import error. The fix for me was to downgrade numpy from ?1.16.12? to ?1.5.14?. Sorry, but I am away from my PC's were I encountered the error but I think those versions are correct.
I experienced the same error in my local Jupyter notebook. Upgrading Numpy package worked for me.
Try upgrading Numpy as below
pip install numpy==1.16
If the above doesn't work, upgrade tensorflow with below command and try again
pip install tensorflow --upgrade
The issue was solved # Github https://github.com/tensorflow/tensorboard/issues/2092
Thanks for the support