tensorflow - tensorflow 中的局部变量是什么?

标签 tensorflow

Tensorflow定义了以下API:

tf.local_variables()
返回使用collection=[LOCAL_VARIABLES]创建的所有变量。
返回值:
局部变量对象的列表。

TensorFlow中的局部变量到底是什么?有人可以给我一个例子吗?

最佳答案

它与常规变量相同,但与默认变量(GraphKeys.VARIABLES)位于不同的集合中。保护程序使用该集合来初始化要保存的变量的默认列表,因此具有local名称具有默认情况下不保存该变量的效果。

我在代码库中只看到一个使用它的地方,即limit_epochs

  with ops.name_scope(name, "limit_epochs", [tensor]) as name:
    zero64 = constant_op.constant(0, dtype=dtypes.int64)
    epochs = variables.Variable(
        zero64, name="epochs", trainable=False,
        collections=[ops.GraphKeys.LOCAL_VARIABLES])

关于tensorflow - tensorflow 中的局部变量是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38910198/

相关文章:

python - axis=[1,2,3]在keras后端的K.sum中是什么意思?

python - 属性错误 : module 'pandas' has no attribute 'core'

python - Tensorflow Keras实现多实例学习问题

tensorflow - 为什么 Keras API 需要第一层的输入形状,因为它实际上在没有它的情况下也能正常工作?

python - 无法导入 Keras 库

node.js - Tensorflow.js inputShape 与模型输入不匹配

opencv - 如何将 Cloud Vision API 导出模型与 Open CV 程序结合使用?

python - Numpy 数组 : Function affects original input object as well

python - Keras( tensorflow 后端)获取 "TypeError: unhashable type: ' Dimension'"

python - Tensorflow 中的分类和连续交叉特征列