module ‘tensorflow‘ has no attribute ‘placeholder‘

Tensorflow2.0 prompt error:

module 'tensorflow' has no attribute 'placeholder'

Solution:
do not use:

import tensorflow as tf

Replace with:

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

The new changes of tensorflow, follow-up to find specific documents, and then add.


Read More: