用下面代码就可以轻松解决
import tensorflow.compat.v1 as tf tf.disable_v2_behavior()
tensorflow兼容处理--2.0版本中用到1.x版本中被deprecated的代码
原文:https://www.cnblogs.com/hercules-chung/p/12417004.html