Despite tensorflow.compat.v1, still receiving deprecation and versioning errors

1.Disable Eager Execution (for full TF1 behavior)

 

import tensorflow.compat.v1 as tf

tf.disable_eager_execution()

2. Stick to One API Style

 

Don’t mix tf.compat.v1 and TF2 in the same script:

  • Use only compat.v1 ops if keeping TF1-style

OR

  • Convert fully to TF2 (tf.keras, tf.function, etc.)
  •  

3. Replace Removed APIs

 

TF1 (Deprecated)

  TF2 Alternative

tf.contrib

  TensorFlow Addons, Keras layers

tf.summary.*

  tf.summary.create_file_writer

tf.Session()

  Use @tf.function and eager execution

 

4. Downgrade TensorFlow (if needed)

 

If you’re stuck with legacy code, try using:

pip install tensorflow==2.3

 

5. Suppress Warnings (not recommended unless safe)

import warnings

warnings.filterwarnings(“ignore”, category=DeprecationWarning)