(*args, **kwargs)
| 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 |
nothing calls this directly
no test coverage detected