AttributeError: module tensorflow has no attribute placeholder

使用云平台或者别的服务器时,如果安装的是高版本的tf(tf2.x),跑比较旧的代码容易出现这种报错。解决方案:注释tf的引用,换为兼容模式。

# import tensorflow as tf
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior() 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章