Lin-Chen-Hao_Jeremy
Lin-Chen-Hao_Jeremy

Reputation: 55

After upgraded tensorflow2.1,I got "RuntimeError: tf.placeholder() is not compatible with eager execution."

I'm new here,recently I am learning CNN with tensorflow and keras,and I am trying to run cnn model to train mnist dataset,but After I upgraded with tnesorflow 2.0 to 2.1, I got this error message:

 raise RuntimeError("tf.placeholder() is not compatible with "

 RuntimeError: tf.placeholder() is not compatible with eager execution.

I try this code

tf.compat.v1.disable_eager_execution()

and next,

##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])

and below is CNN model, so I can run the model successfully,but I still want to understand why.... (before I upgraded to 2.1,I can run the model,but now I need that code...) could someone help me figure out?? Thanks..

Upvotes: 4

Views: 6291

Answers (1)

Moein
Moein

Reputation: 71

use this line in your code: tf.compat.v1.disable_eager_execution()

Upvotes: 4

Related Questions