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

前端 未结 4 1629
暖寄归人
暖寄归人 2021-02-02 07:14

I have upgraded with tf_upgrade_v2 TF1 code to TF2. I\'m a noob with both. I got the next error:

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


        
4条回答
  •  爱一瞬间的悲伤
    2021-02-02 08:17

    In TensorFlow 1.X, placeholders are created and meant to be fed with actual values when a tf.Session is instantiated. However, from TensorFlow2.0 onwards, Eager Execution has been enabled by default, so the notion of a "placeholder" does not make sense as operations are computed immediately (rather than being differed with the old paradigm).

    Also see Functions, not Sessions,

    # TensorFlow 1.X
    outputs = session.run(f(placeholder), feed_dict={placeholder: input})
    # TensorFlow 2.0
    outputs = f(input)
    

提交回复
热议问题