The simplest way to make TF 1.x code compatible with TF 2.0 code is to run the update script that's installed on your system, along with the TF 2.0 installation. The update script makes use of the tf.compat.v1 module.
As a way to provide backward compatibility for code written for TF 1.x, the tf.compat.v1 module was introduced in TF 2.0. The tf.compat.v1 module replaces all TF 1.x symbols, such as tf.foo and tf.compat.v1.foo. This module allows most of the code that's been written for TF 1.x to be converted so that it can be run in TF 2.0.
As a way to streamline this process, TensorFlow provides a tf_upgrade_v2 utility, which helps streamline the transition as much as possible. This utility is preinstalled with the TF 2.0 installation, along with any TF 1.x installation from r1.13 and onwards. To run this script, simply specify an infile and...