天天看點

tf.get_collection()

此函數有兩個參數,key和scope。

Args:

1.key: The key for the collection. For example, the GraphKeys class contains many standard names for collections. 2.scope: (Optional.) 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.

舉個例子:

tf.get_collection會列出key裡所有的值。

tf.GraphKeys的點後可以跟很多類,

比如VARIABLES類(包含所有variables),

比如REGULARIZATION_LOSSES。

具體tf.get_collection(tf.GraphKeys.REGULARIZATION_LOSSES)的使用:

據:

這段代碼的輸出可知,

在圖上的所有regularization都會集中儲存到tf.GraphKeys.REGULARIZATION_LOSSES去。

關于collection的詳情請參見:

http://blog.csdn.net/shenxiaolu1984/article/details/52815641

關于tf.GraphKeys.REGULARIZATION_LOSSES的詳情參見:

https://gxnotes.com/article/178205.html