我一直在尝试使用tensorflow两天,现在在python2.7和3.4中反复安装和重新安装它.无论我做什么,我在尝试使用tensorflow.placeholder()时都会收到此错误消息
这是非常的样板代码:
tf_in = tf.placeholder("float", [None, A]) # Features
Run Code Online (Sandbox Code Playgroud)
无论我做什么,我总会得到回溯:
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'
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?
我正在尝试在v2.0中运行一个tensorflow代码,并且遇到以下错误
AttributeError: module 'tensorflow' has no attribute 'logging'
Run Code Online (Sandbox Code Playgroud)
我不想简单地将其从代码中删除。
我已经安装了tensorflow版本r0.11。
在我的文件名中,cartpole.py我已经导入tensorflow:
import tensorflow as tf
Run Code Online (Sandbox Code Playgroud)
并使用它:
tf.reset_default_graph()
Run Code Online (Sandbox Code Playgroud)
尝试在PyCharm中运行我的项目时出现以下错误:
in <module>
tf.reset_default_graph()
AttributeError: module 'tensorflow' has no attribute 'reset_default_graph'
Run Code Online (Sandbox Code Playgroud)
如何解决此错误?
我正在尝试运行这行代码:
var_init_1 = tf.get_variable("var_init_1", [1, 2], dtype=tf.int32, initializer=tf.zeros_initializer)
print(var_init_1.shape)
Run Code Online (Sandbox Code Playgroud)
它应该给出一个输出为零张量的形状。
AttributeError Traceback (most recent call last)
<ipython-input-37-3cc73aa1818e> in <module>
----> 1 var_init_1 = tf.get_variable("var_init_1", [1, 2], dtype=tf.int32, initializer=tf.zeros_initializer)
2 print(var_init_1.shape)
AttributeError: module 'tensorflow' has no attribute 'get_variable'
Run Code Online (Sandbox Code Playgroud) 我尝试使用 TensorFlow Probability 运行模型。
但是当我运行它时,我收到以下错误:
**ImportError: This version of TensorFlow Probability requires TensorFlow version >= 2.3; Detected an installation of version 2.0.0-beta1. Please upgrade TensorFlow to proceed.**<br>
Run Code Online (Sandbox Code Playgroud)
我无法安装 TensorFlow 2.3,因为它说没有匹配项。
我已经安装了这些库。
张量流(2.0.0b1)
张量流估计器(1.14.0)
张量流张量板(1.5.1)
tfp-nightly(0.12.0.dev20200817)
有什么建议如何修复它吗?
提前致谢
我导入了 tensorflow 模块,但无法使用 tf.contrib。我不知道是什么问题。我尝试在不同版本中运行它,但我一直得到相同的输出。
模块导入:
import tensorflow.compat.v1 as tf1
tf1.disable_v2_behavior()
import tensorflow as tf2
Run Code Online (Sandbox Code Playgroud)
代码:
tf2.contrib.rnn.LSTMCell(num_units=num_nodes[li],
state_is_tuple=True,
initializer= tf.contrib.layers.xavier_initializer()
)
Run Code Online (Sandbox Code Playgroud)
输出:
AttributeError: module 'tensorflow' has no attribute 'contrib'
Run Code Online (Sandbox Code Playgroud)