属性错误:模块"张量流"没有属性"占位符"



我在kaggle内核上进行面部表情识别,一切都很顺利,但突然下面的代码开始出错。

将tensorflow导入为tf

x=tf.占位符(shape=[无,image_pixels],dtype=tf.foat32(y=tf.占位符(shape=[无,labels_count],dtype=tf.foat32(

AttributeError:模块"tensorflow"没有属性"placeholder">

我已经尝试了互联网上的许多替代方案,例如使用

导入tensorflow.compat.v1作为tf

tf.disable_v2_behavior((

这而不是

将tensorflow导入为tf

但一切都白费了。请在这里帮我

更改<tf.placeholder>作为<tf.compat.v1.placeholder>

x = tf.placeholder(shape = [None, image_pixels], dtype = tf.float32)

更改为

x = tf.compat.v1.placeholder(shape = [None, image_pixels], dtype = tf.float32)

但是,对于急于执行的运行时错误,还有另一个问题添加<tf.compat.v1.disable_eager_execution((>进口后部件

import tensorflow as tf
tf.compat.v1.disable_eager_execution()

像这个

最新更新