If you don't use the scope argument in tf.get_collection, those two methods return the same collection in the computational graph.
get_collection, without scope fetches every value in the collection without applying any filter operation.
When the scope parameter is specified, every element of the collection is filtered by the scope.
Consider the following sample code, which returns the same as your sample code (here I used tf.GraphKeys.TRAINABLE_VARIABLES instead for the demo purposes).
with tf.variable_scope("foo1"):
v1 = tf.get_variable("v1", [1])
with tf.variable_scope("foo2"):
v2 = tf.get_variable("v2", [1])
aaa = tf.get_collection_ref(tf.GraphKeys.TRAINABLE_VARIABLES)
aaaa = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES)
print(aaa == aaaa) #True
print(aaa is aaaa) #False
Since there is no scope specified, aaa and aaaa objects referred to by the variables are equal.
However, If you run the following sample code with the scope specified,
with tf.variable_scope("foo1"):
v1 = tf.get_variable("v1", [1])
with tf.variable_scope("foo2"):
v2 = tf.get_variable("v2", [1])
aaa = tf.get_collection_ref(tf.GraphKeys.TRAINABLE_VARIABLES)
aaaa = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES,'foo1')
print(aaa == aaaa) # False
print(aaa is aaaa) # False
since the scope is specified, aaa and aaaa objects referred to by the variables are not equal.
Moreover, in both cases, aaa and aaaa are not pointing to the same object. Therefore, aaa is aaaa is False in both cases (Is there a difference between `==` and `is` in Python?).
Hope this helps.