小编aks*_*ksr的帖子

AttributeError: 模块“tensorflow”没有属性“get_variable”

我正在尝试运行这行代码:

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)

python python-3.x deep-learning tensorflow

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

deep-learning ×1

python ×1

python-3.x ×1

tensorflow ×1