bluenote10
bluenote10

Reputation: 26560

How to get all collections in Tensorflow?

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.

Upvotes: 6

Views: 3539

Answers (1)

bluenote10
bluenote10

Reputation: 26560

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()

Upvotes: 11

Related Questions