google-research/tf-slim

in tf2.1,after pip install tf-slim,No module named 'tensorflow.contrib'

GreenTeaHua opened this issue · 14 comments

in tf2.1,
after pip install tf-slim,
and, import tf_slim as slim
the error:
No module named 'tensorflow.contrib'

It looks like tf-slim 1.1 has not released into PyPi, yet. If you run "pip install tf-slim" it will install version 1.0, which does not support TF 2.x. However, you can install the current version (1.1) from github using the following command:

pip install git+https://github.com/google-research/tf-slim.git

Don't forget that after the official tf-slim version 1.1 is released to PyPi, you will have to force a reinstall to pick it up (pip install --force-reinstall tf-slim).

even this doesn't resolve the problem,
after running this,
pip install git+https://github.com/google-research/tf-

while importing from tf_slim import slim, it throws me an error saying,

ImportError: cannot import name 'slim' from 'tf_slim' (/Users/uthayan.manavalan/anaconda3/envs/cnn/lib/python3.7/site-packages/tf_slim/init.py)

even this doesn't resolve the problem,
after running this,
pip install git+https://github.com/google-research/tf-

while importing from tf_slim import slim, it throws me an error saying,

ImportError: cannot import name 'slim' from 'tf_slim' (/Users/uthayan.manavalan/anaconda3/envs/cnn/lib/python3.7/site-packages/tf_slim/init.py)

Hello, package tf_slim do not contains 'slim' module. Be carefull, may be you want to do 'import tf_slim as slim'?

I'm bigginer, but based on documentation, 'tensorflow.contrib' is deprecated and has been removed from tf. However we may use some deprecated functions from 'contrib' module via slim. For example, tf.contib.layers.fully_connected() may be replaced with slim.layers.fully_connected(). I'm not sure, but it might work.

yes those are exactly equivalent functions.

emnab commented

It looks like tf-slim 1.1 has not released into PyPi, yet. If you run "pip install tf-slim" it will install version 1.0, which does not support TF 2.x. However, you can install the current version (1.1) from github using the following command:

pip install git+https://github.com/google-research/tf-slim.git

Don't forget that after the official tf-slim version 1.1 is released to PyPi, you will have to force a reinstall to pick it up (pip install --force-reinstall tf-slim).

think you It work for me

come back to tf 1.13.1, everything is OK. crying.

come back to tf 1.13.1, everything is OK. crying.

hello,i had the same problem with tf_slim,but i must use tensorflow2.0,so How should I modify it?

@HouGall I started the release today. I might finish today or early tomorrow and will update this issue when finished.

@HouGall @emnab @GreenTeaHua @GamerX-Ar @uthayanmanavalan @xavigibert

I just pushed TF-Slim 1.1.0 after testing it on TF 1.15.2 py2, TF 2.0.1, TF 2.1 and TF 2.2. The tests were the unit tests, if you see errors using it in some situation please let us know. I am closing this issue but I can reopen. Just ping the thread. I am keeping myself assigned. The README.md is being updated now. I am getting +1s.

pip install --upgrade tf-slim

https://pypi.org/project/tf-slim/1.1.0/

It looks like tf-slim 1.1 has not released into PyPi, yet. If you run "pip install tf-slim" it will install version 1.0, which does not support TF 2.x. However, you can install the current version (1.1) from github using the following command:

pip install git+https://github.com/google-research/tf-slim.git

Don't forget that after the official tf-slim version 1.1 is released to PyPi, you will have to force a reinstall to pick it up (pip install --force-reinstall tf-slim).

What if you have installed every fie for the project with conda does it mean I have to write conda install git+https://github.com/google-research/tf-slim.git

@Ndohjapan I do not know conda enough to know if your command is correct (sorry), but if that installs tf-slim from github it should be fine. It will not be 1.1 but there are not very many commits and you actually end up with a slightly new version that what I released back in May. I have seen some "tricks" where people install pypi packages via conda but I don't know the syntax and a quick google search did not make me confident enough to give you advice.

Sorry for not really answering your question. I did not want you to think your question was not seen.

@Ndohjapan or anyone that runs into this. I did not test this but this is a solution I have seen another team use. Consider this more pseudo code than code snippet. I thought this might give someone a nudge in the right direction at some later date.

https://berkeley-stat159-f17.github.io/stat159-f17/lectures/06-conda-pip-environments..html

$ conda env create -f conda.yml".
If we put in the conda.yml file. 
- pip:
  - tf-slim