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
- Wrap the graph building steps in tf.Graph().as_default(), see:
https://blog.abivin.vn/2019/11/operationfunction-in-tensorflow-2.html - Use tf.compat.v1.placeholder instead of tf.placeholder
- Use tf.compat.v1.Session instead of tf.Session
More about TF1-to-TF2 migration:
No comments:
Post a Comment