Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can I not import Tensorflow.contrib I get an error of No module named 'tensorflow.python.saved

Hi I just installed Tensorflow on my Mac and I want to use tf.contrib.slim but when I use it I get this

import tensorflow as tf

slim = tf.contrib.slim

Error:

File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/export/export_lib.py", line 25, in from tensorflow.python.saved_model.model_utils import build_all_signature_defs ModuleNotFoundError: No module named 'tensorflow.python.saved_model.model_utils'

I don't know what to do, please help me

I use Tensorflow.13.1 and python 3.7

like image 661
Daromogo Avatar asked Mar 09 '19 22:03

Daromogo


People also ask

How do I fix No module named TensorFlow error?

The Python "ModuleNotFoundError: No module named 'tensorflow'" occurs when we forget to install the tensorflow module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install tensorflow command.

When was TensorFlow contrib removed?

contrib was removed in version 1.14 or 1.15.

What is TensorFlow contrib?

In general, tf. contrib contains contributed code. It is meant to contain features and contributions that eventually should get merged into core TensorFlow, but whose interfaces may still change, or which require some testing to see whether they can find broader acceptance.


2 Answers

For anyone who is trying some old codes from github with Tensorflow 1.x.x versions while having Tensorflow 2.0.x please note that tf.contrib no longer exist in Tensorflow 2.0.x and it's modules were moved.
Please google the name of the module without the tf.contrib part to know it's new location and thus migrating your code accordingly by correcting the import statement.

Hope this helped!

like image 58
Yehdhih ANNA Avatar answered Oct 14 '22 18:10

Yehdhih ANNA


first unistall tensorflow

pip uninstall tensorflow

then install 1.13.2 version

pip install tensorflow==1.13.2

it works.. had the same issue.. but installing tensorflow 1.13.2 solved it!
the newer version of tensorflow doesn't have

like image 47
PemaGrg Avatar answered Oct 14 '22 18:10

PemaGrg