I'm trying to get a list of all existing collections in a Tensorflow model. Regarding collections automatically created by Tensorflow I can iterate over all keys in GraphKeys
and can query each key e.g.
tf.get_collection(tf.GraphKeys.TRAIN_OP)
Is there a way to get a complete list of all collections, including user created collections.
If you want to get all the trainable variables, you can get all of them inside of a list using tf. trainable_variables method.
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.
Tensorflow stores the collections as a private dictionary _collections
in class Graph
. This class also exposes a function to retrieve all collection keys/names:
tf.get_default_graph().get_all_collection_keys()
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