Migrate to TensorFlow 2 (original) (raw)

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.

TensorFlow 1.x vs TensorFlow 2

Learn how the TF2 API and behaviors differ fundamentally from TF1.x.

Map TF1.x models to TF2

Begin using TF1.x models in TF2 right away using modeling shims.

Rewrite TF1.x API symbols

Programmatically upgrade some parts of your TF1.x code to TF2.

Validate migrated TF2 code

Verify the correctness of your migrated TF2 code.

Moving off Estimators

Migrate from your Estimator training pipelines to TF2.

Moving off feature columns

Learn how to migrate to Keras preprocessing layers from tf.feature_columns.

Multi-worker CPU/GPU training workflows

Learn how to migrate multi-worker distributed Estimator to TF2.

TPU workflows

Learn how to migrate the TPUEstimator API to TF2.

TensorFlow Lite

Learn how to migrate TF Lite code created with TF1.x to TF2.