错误:
AttributeError: module 'tensorflow' has no attribute 'truncated_normal'
解决:
tf.truncated_normal()改为tf.random.truncated_normal()
错误:
报错显示plotting中不包含newfig和savefig
解决:
在开头引入
import matplotlib.pyplot as plt
然后将代码正文中的所有newfig和savefig全部改为plt.newfig和plt.savefig
错误:
AttributeError: module 'tensorflow' has no attribute 'ConfigProto'
解决:
将tf.ConfigProto()改为tf.compat.v1.ConfigProto()
错误:
RuntimeError: tf.compat.v1.placeholder() is not compatible with eager execution.
解决:
在有tf.placeholder()的这行代码前面加上一行tf.compat.v1..disable_eager_execution()
所有基于TensorFlow1的代码往TensorFlow2上迁移产生的错误,最省事的解决方法是安装TensorFlow1的虚拟环境,直接在1的环境下跑,改起来真的太烦了