{"id":24704,"library":"tf-slim","title":"TF-Slim","description":"TF-Slim is a lightweight library for defining, training, and evaluating complex models in TensorFlow. The current version is 1.1.0, with no recent updates and likely in maintenance mode.","status":"maintenance","version":"1.1.0","language":"python","source_language":"en","source_url":"https://github.com/google-research/tf-slim","tags":["tensorflow","slim","model-zoo","legacy"],"install":[{"cmd":"pip install tf-slim","lang":"bash","label":"default"}],"dependencies":[{"reason":"Required runtime dependency","package":"tensorflow","optional":false}],"imports":[{"note":"Old contrib path removed in TF 2.x","wrong":"import tensorflow.contrib.slim as slim","symbol":"slim","correct":"import tf_slim as slim"},{"note":"contrib module deprecated and removed","wrong":"from tensorflow.contrib import slim","symbol":"slim","correct":"from tf_slim import slim"}],"quickstart":{"code":"import tensorflow as tf\nimport tf_slim as slim\n\ninputs = tf.random.normal([4, 224, 224, 3])\nnets = tf_slim.nets.resnet_v2\nwith slim.arg_scope(nets.resnet_arg_scope()):\n    logits, _ = nets.resnet_v2_50(inputs, num_classes=1000, is_training=False)\nprint(logits.shape)","lang":"python","description":"Load a pretrained ResNet-50 model using TF-Slim's model zoo."},"warnings":[{"fix":"Install tf-slim with pip and use 'import tf_slim as slim' instead of 'tensorflow.contrib.slim'.","message":"TF-Slim was part of TensorFlow contrib, which was removed in TF 2.0. The standalone tf-slim package must be installed separately.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use tf.compat.v1.disable_eager_execution() at the start of your script or wrap code in a graph context.","message":"TF-Slim's TF 1.x APIs (e.g., slim.layers, slim.losses) are not fully compatible with eager execution. You may need to run inside tf.Graph().as_default() or disable eager execution.","severity":"gotcha","affected_versions":"all"},{"fix":"Consider migrating to tf.keras for model building and tf.train.Checkpoint/tf.function for training.","message":"Many TF-Slim functions (e.g., slim.learning, slim.evaluation) are deprecated in favor of TensorFlow native APIs like tf.keras or tf.estimator.","severity":"deprecated","affected_versions":">=1.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install tf-slim and import as 'import tf_slim as slim' or 'from tf_slim import slim'.","cause":"Using old import path from TensorFlow contrib (removed in TF 2.x).","error":"ModuleNotFoundError: No module named 'tensorflow.contrib.slim'"},{"fix":"Use tf.variable_scope('model', reuse=tf.AUTO_REUSE) or reuse=True when reusing the model.","cause":"Reusing the same variable scope without enclosing in a variable scope or using slim.get_unique_variable_scope() properly.","error":"ValueError: Variable resnet_v2_50/conv1/weights already exists, disallowed."},{"fix":"Install tf-slim and use the correct import path: 'import tf_slim as slim'.","cause":"TensorFlow 2.x removed the contrib module entirely.","error":"AttributeError: module 'tensorflow' has no attribute 'contrib'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}