close

[Solved] AttributeError: ‘module’ object has no attribute ‘placeholder’

Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to use tensorflow’s placeholder but I am facing following error AttributeError: ‘module’ object has no attribute ‘placeholder’ in Python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How AttributeError: ‘module’ object has no attribute ‘placeholder’ Error Occurs ?

I am trying to use tensorflow’s placeholder but I am facing following error.

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

How To Solve AttributeError: ‘module’ object has no attribute ‘placeholder’ Error ?

  1. How To Solve AttributeError: ‘module’ object has no attribute ‘placeholder’ Error ?

    To Solve AttributeError: ‘module’ object has no attribute ‘placeholder’ Error If you just updated tensorflow 2.0 and you are facing this error then you should use this: import tensorflow.compat.v1 as tf Second solution is If you are using tensorflow-gpu then just remove this all by this command: conda remove tensorflow-gpu tensorflow tensorflow-base Then just, re-installed tensorflow. Using conda install tensorflow Now your error must be solved.

  2. AttributeError: ‘module’ object has no attribute ‘placeholder’

    To Solve AttributeError: ‘module’ object has no attribute ‘placeholder’ Error If you just updated tensorflow 2.0 and you are facing this error then you should use this: import tensorflow.compat.v1 as tf Second solution is If you are using tensorflow-gpu then just remove this all by this command: conda remove tensorflow-gpu tensorflow tensorflow-base Then just, re-installed tensorflow. Using conda install tensorflow Now your error must be solved.

Solution 1: Use tensorflow this way

If you just updated tensorflow 2.0 and you are facing this error then you should use this.

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

Solution 2: remove tensorflow-gpu

If you are using tensorflow-gpu then just remove this all by this command.

conda remove tensorflow-gpu tensorflow tensorflow-base

Then just, re-installed tensorflow. Using

conda install tensorflow

Now your error must be solved.

Summary

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

Leave a Comment