TensorFlow的“模块"对象没有属性“占位符" [英] TensorFlow, "'module' object has no attribute 'placeholder'"

查看:493
本文介绍了TensorFlow的“模块"对象没有属性“占位符"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用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:

  1. 我从Anaconda移除了tensorflow-gpu,tensorflow,tensorflow-base软件包.使用.

conda remove tensorflow-gpu tensorflow tensorflow-base

  1. 重新安装了张量流.使用

conda install tensorflow

这篇关于TensorFlow的“模块"对象没有属性“占位符"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆