关注微信公共号:小程在线


关注CSDN博客:程志伟的博客
Python 3.7.6 (default, Jan  8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 7.12.0 -- An enhanced Interactive Python.
 

错误提示:

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

增加代码:

tf.compat.v1.disable_eager_execution()

错误代码实例:

reset_graph()

X = tf.placeholder(tf.float32, shape=(None, n_inputs), name="X")
y = tf.placeholder(tf.int32, shape=(None), name="y")
Traceback (most recent call last):

  File "<ipython-input-15-d0b4044c06e0>", line 3, in <module>
    X = tf.placeholder(tf.float32, shape=(None, n_inputs), name="X")

  File "C:\Users\cheng\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\ops\array_ops.py", line 3282, in placeholder
    raise RuntimeError("tf.placeholder() is not compatible with "

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

正确代码:

tf.compat.v1.disable_eager_execution()
reset_graph()

X = tf.placeholder(tf.float32, shape=(None, n_inputs), name="X")
y = tf.placeholder(tf.int32, shape=(None), name="y")

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐