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:
- Run the automated script to convert your TF1.x API usage to
tf.compat.v1
. - Remove old
tf.contrib.layers
and replace them with TF Slim symbols. Also check TF Addons for othertf.contrib
symbols. - Rewrite your TF1.x model forward passes to run in TF2 with eager execution enabled.
- Validate the accuracy and numerical correctness of your migrated code.
- Upgrade your training, evaluation and model saving code to TF2 equivalents.
- (Optional) Migrate your TF2-compatible
tf.compat.v1
APIs including TF Slim usage to idiomatic TF2 APIs.
Featured migration guides
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 fromtf.feature_column
s.
Multi-worker CPU/GPU training workflows
Learn how to migrate multi-worker distributedEstimator
to TF2.
TPU workflows
Learn how to migrate theTPUEstimator
API to TF2.