Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert tf.contrib to Tensorflow 2.0

So I'm trying to implement object detection using Tensorflow and a part of my code uses tf.contrib. The problem is tf.contrib is not supported in Tensorflow 2.0.

I've tried using the tf_upgrade_v2 script but I get the following message:

ERROR: Using member tf.contrib.slim in deprecated module tf.contrib. tf.contrib.slim cannot be converted automatically. tf.contrib will not be distributed with TensorFlow 2.0, please consider an alternative in non-contrib TensorFlow, a community-maintained repository such as tensorflow/addons, or fork the required code.

import functools
import tensorflow as tf
from object_detection.core import box_predictor
from object_detection.utils import shape_utils
from object_detection.utils import static_shape

slim = tf.contrib.slim
like image 995
Ethan Nguyen Avatar asked Nov 12 '19 16:11

Ethan Nguyen


1 Answers

Since all the projects in tf.contrib were not officially supported by Tensorflow and it had designated owners for maintaining it.
All the contributions and features were meant to merge into core Tensorflow.

From the Tensorflow 2.0 version all the contrib projects had one of three options for its future: move to core; move to a separate repository; or delete, most of which have been reviewed with the respective project owners.

This link provides the details and status for all the projects under tf.contrib.

If the library you are using is moved to the core or separate repository, the TensorFlow's automatic code migration from 1.x to 2.x will not work for tf.contrib projects. You need to change your code manually for these parts, which is suggested going forward.

I can see in the table that tf.contrib.slim is moved to tensorflow/models , you can follow this link for the usage in detail.

like image 58
Tensorflow Warrior Avatar answered Sep 23 '22 00:09

Tensorflow Warrior