Solve the problem of using in tensoft 2. X tf.contrib.slim No module named appears in the package: tensorflow.contrib problem


tensorflow2.x has been greatly changed over 1.x to make TensorFlow users more efficient. Where Tf.contrib was abandoned altogether is a major change of 2.x version, but import tensorflow.contrib.slim as Slim as a superior package, has been widely used in many previous versions. Most of the source code is still written based on the TensorFlow1.x version, which makes some modules that have been removed from the 2.x version unusable.

main problem

when running a import tensorflow. Contrib. Slim as slim

: ModuleNotFoundError: No module named 'tensorflow. Contrib false


query existing solutions, most of the use of the reduced version of the method, if you want to use this method can go to the query.
because I don't want to use the method of reducing the version to solve, after searching on github to find out the information
link: tf.contrib.slim is not worked in tensorflow 2.0 what is the alternative for that?.

Tf - slim has a independent of tensorflow mirror to pat. V1 compatible mode is used, install the package can be

tf-slim is a lightweight library for defining, training, and evaluating complex models in TensorFlow. Tf-slim's components can be freely blended with the native TensorFlow and other frameworks.
here you can find information about Slim: link.


use PIP to download tf-slim

in CMD

pip install --upgrade tf_slim


note when using Slim library:

#import tensorflow.contrib.slim as slim
import tf_slim as slim

where the commented out part is the source code, modified no longer report an error.
(ps: the ability is limited, if there is an error, please point out.

Read More: