Tensorflow get all variables in scope

I think you want tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope=”my_scope”). This will get all variables in a scope.

To pass to an optimizer you do not want all variables you would just want the trainable variables. Those are also kept in a default collection, which is tf.GraphKeys.TRAINABLE_VARIABLES.

Leave a Comment