使用雲平臺或者別的服務器時,如果安裝的是高版本的tf(tf2.x),跑比較舊的代碼容易出現這種報錯。解決方案:註釋tf的引用,換爲兼容模式。
# import tensorflow as tf
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
使用雲平臺或者別的服務器時,如果安裝的是高版本的tf(tf2.x),跑比較舊的代碼容易出現這種報錯。解決方案:註釋tf的引用,換爲兼容模式。
# import tensorflow as tf
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()