Please answer the following questions for yourself before submitting an issue.
https://github.com/tensorflow/models/tree/master/official/...
2020-07-25 10:07:11.122491: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
WARNING:tensorflow:From C:\Users\dw\Anaconda3\envs\TF2.2\libsite-packages\tensorflow_core\python\compat\v2_compat.py:88: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
Traceback (most recent call last):
File "model_main_tf2.py", line 31, in
from object_detection import model_lib_v2
File "D:\tf_train\models\research\object_detection\model_lib_v2.py", line 27, in
from object_detection import eval_util
File "D:\tf_train\models\research\object_detection\eval_util.py", line 36, in
slim = tf.contrib.slim
AttributeError: module 'tensorflow_core.compat.v1' has no attribute 'contrib'
python model_main_tf2.py --model_dir=training --pipeline_config_path=training/center_net_hourglass104_1024x1024_coco17_tpu-32.config --alsologtostderr
Start training the model
(TF2.1) D:\tf_train\workspaces\my_training_demo1>python model_main_tf2.py --model_dir=training --pipeline_config_path=training/center_net_hourglass104_1024x1024_coco17_tpu-32.config --alsologtostderr
2020-07-25 10:13:58.091313: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
WARNING:tensorflow:From C:\Users\dw\Anaconda3\envs\TF2.2\libsite-packages\tensorflow_core\python\compat\v2_compat.py:88: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
Traceback (most recent call last):
File "model_main_tf2.py", line 31, in
from object_detection import model_lib_v2
File "D:\tf_train\models\research\object_detection\model_lib_v2.py", line 27, in
from object_detection import eval_util
File "D:\tf_train\models\research\object_detection\eval_util.py", line 36, in
slim = tf.contrib.slim
AttributeError: module 'tensorflow_core.compat.v1' has no attribute 'contrib'
unknown 2.1.0
@dreamitpossible1
contrib module is no longer available in TensorFlow 2.0, but you can use with this;
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
or uninstall TensorFlow and install oldest version with this;
pip install tensorflow==1.14
Detailed information; https://www.tensorflow.org/guide/migrate
Tensorflow Core released a utility to convert your TF 1.x scripts to TF2.0 which can be found here:
https://www.tensorflow.org/guide/upgrade
Thanks!
Automatically closing due to lack of recent activity. Please update the issue when new information becomes available, and we will reopen the issue. Thanks!
@ravikyram import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
I used this code but I am facing same error
AttributeError: module 'tensorflow' has no attribute 'compat'
Same issue as NitinSaini18. I get the same error in spite of using :
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
I got the same problem as @NitinSaini18 and @richarnaik
Were you able to solve it?
Same issue still even after import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
@Gaurav37 What I did at the end was switching from Python 3.8 to Python3.7 (since Tensorflow 1.x is not working with Python 3.8) and the use Tensorflow 1.x (in my case 1.14.0) instead of 2.x
@richarnaik @Kuehlhausvogel I have the same problem. I can solved using it.
https://stackoverflow.com/questions/61066142/unable-to-use-tf-contrib
Most helpful comment
Same issue as NitinSaini18. I get the same error in spite of using :
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()