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() 
posted @ 2022-11-13 22:35  dlhl  阅读(104)  评论(0)    收藏  举报