MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / get_collection

Method get_collection

tensorflow/python/framework/ops.py:3951–3985  ·  view source on GitHub ↗

Returns a list of values in the collection with the given `name`. This is different from `get_collection_ref()` which always returns the actual collection list if it exists in that it returns a new list each time it is called. Args: name: The key for the collection. For examp

(self, name, scope=None)

Source from the content-addressed store, hash-verified

3949 return coll_list
3950
3951 def get_collection(self, name, scope=None):
3952 """Returns a list of values in the collection with the given `name`.
3953
3954 This is different from `get_collection_ref()` which always returns the
3955 actual collection list if it exists in that it returns a new list each time
3956 it is called.
3957
3958 Args:
3959 name: The key for the collection. For example, the `GraphKeys` class
3960 contains many standard names for collections.
3961 scope: (Optional.) A string. If supplied, the resulting list is filtered
3962 to include only items whose `name` attribute matches `scope` using
3963 `re.match`. Items without a `name` attribute are never returned if a
3964 scope is supplied. The choice of `re.match` means that a `scope` without
3965 special tokens filters by prefix.
3966
3967 Returns:
3968 The list of values in the collection with the given `name`, or
3969 an empty list if no value has been added to that collection. The
3970 list contains the values in the order under which they were
3971 collected.
3972 """ # pylint: disable=g-doc-exception
3973 with self._lock:
3974 collection = self._collections.get(name, None)
3975 if collection is None:
3976 return []
3977 if scope is None:
3978 return list(collection)
3979 else:
3980 c = []
3981 regex = re.compile(scope)
3982 for item in collection:
3983 if hasattr(item, "name") and regex.match(item.name):
3984 c.append(item)
3985 return c
3986
3987 def get_all_collection_keys(self):
3988 """Returns a list of collections used in this graph."""

Calls 4

getMethod · 0.45
compileMethod · 0.45
matchMethod · 0.45
appendMethod · 0.45