tensorflow :AttributeError: module 'tensorflow' has no attribute 'placeholder'

图片说明

I tensorflow/stream_executor/platform/default/dso_loader.cc:44]
Successfully opened dynamic library cudart64_100.dll

Traceback (most recent call last):
File "G:/pycharm/mycode-ZZQ/TensorflowDemo/demo1.py", line 7, in
a_ph = tf.placeholder(tf.float32, name='variable_a')
AttributeError: module 'tensorflow' has no attribute 'placeholder'

大佬有知道怎么回事嘛,我卸载又安装还是不管用

2个回答

尝试前面加compat.v1

tf.compat.v1.disable_eager_execution()
xl = tf.compat.v1.placeholder(tf.float32, [batch_size, None, None, 1], name='xl')

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问