看了很多博客太麻烦,有的虽然改了但是不是适用最新版本。经过验证之后,直接在程序头部加上如下几句程序,禁用TF2避免重新安装TF1:
import tensorflow._api.v2.compat.v1 as tf
tf.disable_v2_behavior()
import warnings
warnings.filterwarnings('ignore')
graph = tf.get_default_graph() # 分配内存
大功告成!
看了很多博客太麻烦,有的虽然改了但是不是适用最新版本。经过验证之后,直接在程序头部加上如下几句程序,禁用TF2避免重新安装TF1:
import tensorflow._api.v2.compat.v1 as tf
tf.disable_v2_behavior()
import warnings
warnings.filterwarnings('ignore')
graph = tf.get_default_graph() # 分配内存
大功告成!