[关闭]
@songying 2018-05-18T21:41:56.000000Z 字数 1130 阅读 1222

tf中的collections

TensorFlow


tensorflowcollection提供一个全局的存储机制,不会受到变量名生存空间的影响。一处保存,到处可取。

  • tf.GraphKeys.GLOBAL_VARIABLES --- variables that can be shared across multiple devices,
  • tf.GraphKeys.TRAINABLE_VARIABLES --- variables for which TensorFlow will calculate gradients.
  • tf.GraphKeys.LOCAL_VARIABLES : If you don't want a variable to be trainable, add it to this

tf.add_to_collection

细节可参见:tf.Graph.add_to_collection

  1. tf.add_to_collection(
  2. name,
  3. value
  4. )
  • **name: **The key for the collection. For example, the GraphKeys class contains many standard names for collections.
  • value: The value to add to the collection.

tf.get_collection

See tf.Graph.get_collection for more details.

  • 返回值: The list of values in the collection with the given name, or an empty list if no value has been added to that collection. The list contains the values in the order under which they were collected.
  1. tf.get_collection(
  2. key,
  3. scope=None
  4. )
  • key: The key for the collection. For example, the GraphKeys class contains many standard names for collections.
  • scope: 可选参数, If supplied, the resulting list is filtered to include only items whose name attribute matches using re.match. Items without a name attribute are never returned if a scope is supplied and the choice or re.match means that a scope without special tokens filters by prefix.
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注