Migrate from TensorFlow 1.x to TensorFlow 2

Learn how to migrate your TensorFlow code from TensorFlow 1.x to TensorFlow 2. It may take a little work to convert your code, but every change results in access to new features and models, increased clarity and simplicity, and easier debugging. Before starting to migrate, read the behaviors guide. Briefly, the migration process is:

  1. Run the automated script to convert your TF1.x API usage to tf.compat.v1.
  2. Remove old tf.contrib.layers and replace them with TF Slim symbols. Also check TF Addons for other tf.contrib symbols.
  3. Rewrite your TF1.x model forward passes to run in TF2 with eager execution enabled.
  4. Validate the accuracy and numerical correctness of your migrated code.
  5. Upgrade your training, evaluation and model saving code to TF2 equivalents.
  6. (Optional) Migrate your TF2-compatible tf.compat.v1 APIs including TF Slim usage to idiomatic TF2 APIs.
Learn how the TF2 API and behaviors differ fundamentally from TF1.x.
Begin using TF1.x models in TF2 right away using modeling shims.
Programmatically upgrade some parts of your TF1.x code to TF2.
Verify the correctness of your migrated TF2 code.
Migrate from your Estimator training pipelines to TF2.
Learn how to migrate to Keras preprocessing layers from tf.feature_columns.
Learn how to migrate multi-worker distributed Estimator to TF2.
Learn how to migrate the TPUEstimator API to TF2.
Learn how to migrate TF Lite code created with TF1.x to TF2.