①如果遇到ModuleNotFoundError: No module named 'tensorflow.contrib错误
需要将原来的#import tensorflow.contrib.slim as slim注释使用import tf_slim as slim代码
#import tensorflow.contrib.slim as slim
import tf_slim as slim
安装tf_slim
pip install --upgrade tf_slim
或者
pip install tf_slim
②出现AttributeError: module ‘tensorflow’ has no attribute ‘Session’错误
只需加上sess=tf.compat.v1.Session()
sess=tf.compat.v1.Session()
③出现AttributeError: module ‘tensorflow’ has no attribute ‘placeholder’错误
只需将import tensorflow as tf 替换成 import tensorflow.compat.v1 as tf 和添加tf.disable_v2_behavior()代码
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()