TensorFlow,“‘模块’对象没有属性‘占位符’"; [英] TensorFlow, "'module' object has no attribute 'placeholder'"
问题描述
我已经尝试使用 tensorflow 两天了,现在在 python2.7 和 3.4 中一遍又一遍地安装和重新安装它.无论我做什么,尝试使用 tensorflow.placeholder() 时都会收到此错误消息
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()
这是非常样板代码:
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?
推荐答案
这也发生在我身上.我有 tensorflow 并且它工作得很好,但是当我在之前的 tensorflow 旁边安装 tensorflow-gpu 时出现了这个错误,然后我做了这 3 个步骤,它开始正常工作:
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:
- 我从 Anaconda 中删除了 tensorflow-gpu、tensorflow、tensorflow-base 包.使用.
conda 删除 tensorflow-gpu tensorflow tensorflow-base
- 重新安装了 tensorflow.使用
conda 安装 tensorflow
这篇关于TensorFlow,“‘模块’对象没有属性‘占位符’";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!