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

Function wrapper

tensorpack/tfutils/scope_utils.py:38–53  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

36
37 @functools.wraps(func)
38 def wrapper(*args, **kwargs):
39 scope = tf.get_variable_scope()
40 h = hash((tf.get_default_graph(), scope.name))
41 # print("Entering " + scope.name + " reuse: " + str(h in used_scope))
42 if h in used_scope:
43 if get_tf_version_tuple() >= (1, 5):
44 with tf.variable_scope(scope, reuse=True, auxiliary_name_scope=False):
45 return func(*args, **kwargs)
46 else:
47 ns = tf.get_default_graph().get_name_scope()
48 with tf.variable_scope(scope, reuse=True), \
49 tf.name_scope(ns + '/' if ns else ''):
50 return func(*args, **kwargs)
51 else:
52 used_scope.add(h)
53 return func(*args, **kwargs)
54
55 return wrapper
56

Callers

nothing calls this directly

Calls 4

get_tf_version_tupleFunction · 0.85
cached_name_scopeFunction · 0.85
formatMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected