[Solved] Error: AttributeError: module ‘tensorflow‘ has no attribute ‘placeholder‘

Errors are reported as follows:

Solution:

Reason: use tensorflow1 instead of tensorflow2.

Check the tensorflow version information first:

pip list

Then add the following code at the beginning of the code:

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

Read More: