【发布时间】:2021-08-19 09:20:03
【问题描述】:
我正在尝试使用此代码在 google Collaboratory 中创建变量张量,但由于 TensorFlow 没有关于变量的模块而出错。有什么解决办法?
import tensorflow as tf
var_1 = tf.variable(tf.ones([2,3]))
错误:
AttributeError Traceback (most recent call last)
<ipython-input-2-2666f49bf801> in <module>()
----> 1 var_1 = tf.variable(tf.ones([2,3]))```
AttributeError: module 'tensorflow' has no attribute 'variable'
【问题讨论】:
-
解决办法是正确大写。 tensorflow.org/api_docs/python/tf/Variable
-
它是
Variable而不是variable。 V 大写。
标签: python tensorflow variables google-colaboratory