Monday, 4 November 2019

Keep TensorFlow 1 Code Running in TensorFlow 2

TensorFlow 2 is rather different from TensorFlow 1 and TF2 runs in Eager mode by default in which all operations are considered as functions. The following shows how to keep TensorFlow 1 code running in TensorFlow 2.

Method 1: Use compatibility module

%tensorflow_version 2.x
import tensorflow.compat.v1 as tf;
tf.disable_v2_behavior();

Method 2: Change the code to fit TF2
More about TF1-to-TF2 migration:

No comments:

Post a Comment