Open nobutoba opened 4 years ago
Thanks for the report. The notebook does need to be fixed. Slim will probably never work in tensorflow 2.0 eager mode, only in graph mode. Thus command line examples won't work as is. We should restore that header in the README.MD with some caveats.
What is the best way to fix this? Should we mention that [TensorFlow 2 might not be supported] in the README or change all instances of from tensorflow.contrib import slim
to import tf_slim as slim
. Or maybe both?
Slim will probably never work in tensorflow 2.0 eager mode, only in graph mode
Is this being deprecated or is there any other reason it doesn't work?
We will update the readme.md and notebook shortly. Skim is mostly in maintenance mode but full on tf2 support basically requires a very thorough rewrite and not all concepts of slim map nicely in tf2.
On Wed, Jun 3, 2020, 5:13 PM Kilaru Yasaswi Sri Chandra Gandhi < notifications@github.com> wrote:
What is the best way to fix this? Should we mention that [TensorFlow 2 might not be supported] in the README or change all instances of from tensorflow.contrib import slim to import tf_slim as slim. Or maybe both?
Slim will probably never work in tensorflow 2.0 eager mode, only in graph mode
Is this being deprecated or is there any other reason it doesn't work?
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/8594#issuecomment-638525440, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVIDWDFJ2EWIR5WIANE4Q3RU3RLFANCNFSM4NOQITFQ .
Prerequisites
1. The entire URL of the file you are using
https://github.com/tensorflow/models/blob/master/research/slim/README.md https://github.com/tensorflow/models/blob/master/research/slim/slim_walkthrough.ipynb
2. Describe the bug
from tensorflow.contrib import slim
andimport tf_slim as slim
appear in the same notebook, resulting in name conflict.3. Steps to reproduce
The following sample commands in README.md throw exceptions with TensorFlow 2.2.0.
The reason is that both train_image_classifier.py and eval_image_classifier.py contain the sentence
from tensorflow.contrib import quantize as contrib_quantize
, which raisesModuleNotFoundError: No module named 'tensorflow.contrib'
.If I run slim_walkthrough.ipynb with TensorFlow 1.15.3, it throws within the 6th cell (starting from
# The following snippet trains the regression model
) aUserWarning: Attempting to use a closed FileWriter. The operation will be a noop unless the FileWriter is explicitly reopened.
and then in the 9th cell right after the sentence "Finally, we print the final value of each metric":On the other hand, since slim_walkthrough.ipynb contains the statement
from tensorflow.contrib import slim
, it is clear that the notebook is not compatible with TensorFlow 2 as it stands. However, if I run the notebook, it actually throws an error within the 6th cell starting from "# The following snippet trains the regression model
", before this import statement:4. Expected behavior
Apparently, the commit a couple of days ago aims to make the TensorFlow-Slim Image Classification Model Library compatible with TensorFlow 2. For example, it deleted the
![TensorFlow 2 Not Supported]
tag from READMEs and replaced as manytf.contrib.slim
withtf-slim
as possible. Since the sample code in README.md works with TensorFlow 1.15.3 anyway, this might not count as a bug, but it is at least confusing for a non-experienced TensorFlow user like me 😭I hope the sample notebook slim_walkthrough.ipynb works with either TensorFlow 1 or 2. Also, for TensorFlow 1, the two conflicting statements
from tensorflow.contrib import slim
andimport tf_slim as slim
are better avoided.5. Additional context
Full log for the 6th cell in the notebook, run with TensorFlow 1.15.3
```python WARNING:tensorflow:From /home/username/tensorflow-slim/.venv/lib/python3.7/site-packages/tensorflow_core/python/ops/losses/losses_impl.py:121: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version. Instructions for updating: Use tf.where in 2.0, which has the same broadcast rule as np.where WARNING:tensorflow:FromFull log for the 9th cell in the notebook, run with TensorFlow 1.15.3
```python WARNING:tensorflow:FromFull log for the 6th cell in the notebook, run with TensorFlow 2.2.0
```python WARNING:tensorflow:From6. System information