I am confused by tf.get_collection()
form the docs, it says that
Returns a list of values in the collection with the given name.
And an example from the Internet is here
from_vars = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, from_scope)
Is it means that it collects variables from tf.GraphKeys.TRAINABLE_VARIABLES
to from_scope
?
However, how can I use this function if I want to get variables from another scope? Thank you!
TensorFlow uses graphs as the format for saved models when it exports them from Python. Graphs are also easily optimized, allowing the compiler to do transformations like: Statically infer the value of tensors by folding constant nodes in your computation ("constant folding").
The TensorFlow Python library has a default graph to which ops constructors add nodes. The default graph is sufficient for many applications. See the Graph class documentation for how to explicitly manage multiple graphs.
You can use tf. function to make graphs out of your programs. It is a transformation tool that creates Python-independent dataflow graphs out of your Python code. This will help you create performant and portable models, and it is required to use SavedModel .
Remember that under the hood, Tensorflow is a system for specifying and then executing computational data flow graphs. The graph collections are used as part of keeping track of the constructed graphs and how they must be executed. For example, when you create certain kinds of ops, such as tf. train.
A collection is nothing but a named set of values.
Every value is a node of the computational graph.
Every node has its name and the name is composed by the concatenation of scopes, /
and values, like: preceding/scopes/in/that/way/value
get_collection
, without scope
allow fetching every value in the collection without applying any filter operation.
When the scope
parameter is present, every element of the collection is filtered and its returned only if the name of the node starts with the specified scope
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With