我是新手,最近在学习使用TensorFlow和Keras来构建卷积神经网络(CNN)。我试图运行CNN模型来训练mnist数据集,但是在将TensorFlow从2.0版本升级到2.1版本后,出现了以下错误信息:
raise RuntimeError("tf.placeholder() is not compatible with "
RuntimeError: tf.placeholder() is not compatible with eager execution.
我尝试了这段代码
tf.compat.v1.disable_eager_execution()
接下来,
##build input layer
with tf.compat.v1.name_scope('Input_Layer'):
x=tf.compat.v1.placeholder("float",shape=[None, 784],name="x")
x_image = tf.compat.v1.reshape(x, [-1,28,28,1])
下面是CNN模型,所以我能够成功地运行该模型,但我仍然想理解为什么......(在我升级到2.1之前,我可以运行该模型,但现在我需要那段代码...)有人可以帮助我吗?谢谢。