I've been trying to use tensorflow for two days now installing and reinstalling it over and over again in python2.7 and 3.4. No matter what I do, I get this error message when trying to use tensorflow.placeholder()
It's very boilerplate code:
tf_in = tf.placeholder("float", [None, A]) # Features
No matter what I do I always get the trace back:
Traceback (most recent call last):
File "/home/willim/PycharmProjects/tensorflow/tensorflow.py", line 2, in <module>
import tensorflow as tf
File "/home/willim/PycharmProjects/tensorflow/tensorflow.py", line 53, in <module>
tf_in = tf.placeholder("float", [None, A]) # Features
AttributeError: 'module' object has no attribute 'placeholder'
Anyone know how I can fix this?
If you are using TensorFlow 2.0, then some code developed for tf 1.x may code work. Either you can follow the link : https://www.tensorflow.org/guide/migrate
or you can install a previous version of tf by pip3 install tensorflow==version
It happened to me too. I had tensorflow and it was working pretty well, but when I install tensorflow-gpu along side the previous tensorflow this error arose then I did these 3 steps and it started working with no problem:
conda remove tensorflow-gpu tensorflow tensorflow-base
conda install tensorflow
Recent version 2.0 does not support placeholder. I uninstalled 2.0 using command:
conda remove tensorflow
. then I installed 1.15.0 using command:conda install -c conda-forge tensorflow=1.15.0
. 1.15 is latest in version 1 series. You can change as per you wish and requirement. For seeing all version, use command:conda search tensorflow
. It worked for Anaconda3 in Windows.