【发布时间】:2020-06-28 15:19:12
【问题描述】:
我是新来的,最近我在用tensorflow和keras学习CNN,我正在尝试运行cnn模型来训练mnist数据集,但是在我用tnesorflow 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 之前,我可以运行模型,但现在我需要那个代码......) 有人可以帮我弄清楚吗?谢谢..
【问题讨论】:
-
Eager Execution 的重点是摆脱预建图,即占位符。
标签: keras tensorflow2.0