MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / cached_name_scope

Function cached_name_scope

tensorpack/tfutils/scope_utils.py:152–167  ·  view source on GitHub ↗

Return a context which either opens and caches a new name scope, or reenter an existing one. Args: top_level(bool): if True, the name scope will always be top-level. It will not be nested under any existing name scope of the caller.

(name, top_level=True)

Source from the content-addressed store, hash-verified

150
151@contextmanager
152def cached_name_scope(name, top_level=True):
153 """
154 Return a context which either opens and caches a new name scope,
155 or reenter an existing one.
156
157 Args:
158 top_level(bool): if True, the name scope will always be top-level.
159 It will not be nested under any existing name scope of the caller.
160 """
161 if not top_level:
162 current_ns = tf.get_default_graph().get_name_scope()
163 if current_ns:
164 name = current_ns + '/' + name
165 ns = _get_cached_ns(name)
166 with tf.name_scope(ns):
167 yield ns

Callers 6

get_costFunction · 0.85
packMethod · 0.85
unpackMethod · 0.85
add_activation_summaryFunction · 0.85
add_param_summaryFunction · 0.85
wrapperFunction · 0.85

Calls 1

_get_cached_nsFunction · 0.85

Tested by

no test coverage detected