Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

no module named tensorflow.contrib

I have this problem when I import tensorflow.contrib.slim

import tensorflow.contrib.slim as slim

i get this error message

Traceback (most recent call last):
File "/home/toshiba/PFE/DocFace-master/src/tflib.py", line 28, in <module>
import tensorflow.contrib.slim as slim

ModuleNotFoundError: No module named 'tensorflow.contrib'

tensorflow is correctly installed and i found some solutions that said that the file name is tensorflow so it causes the problem but that is not the case in here

like image 237
Ammari Amira Avatar asked Jan 21 '20 14:01

Ammari Amira


People also ask

What is Tensorflow contrib?

TensorFlow's high-level machine learning API (tf. contrib. learn) makes it easy to configure, train, and evaluate a variety of machine learning models.

When was Tensorflow contrib removed?

tf. contrib was removed in version 1.14 or 1.15.


1 Answers

You probably have TensorFlow version 2.* installed, but tf.contrib.slim is TensorFlow 1.15 code. You can check here how to migrate your existing code to tensorflow 2.*.

If you instead want to keep your code, you can downgrade to TensorFlow by typing pip install tensorflow==1.15 into your command-line to downgrade to TensorFlow 1.15.

like image 159
Wouterr Avatar answered Sep 21 '22 22:09

Wouterr