@songying
2018-05-18T21:41:56.000000Z
字数 1130
阅读 1222
TensorFlow
tensorflow
的collection
提供一个全局的存储机制,不会受到变量名
生存空间的影响。一处保存,到处可取。
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
tf.add_to_collection(
name,
value
)
- **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.
tf.get_collection(
key,
scope=None
)
- 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 usingre.match
. Items without aname
attribute are never returned if a scope is supplied and the choice orre.match
means that ascope
without special tokens filters by prefix.