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

Function override_to_local_variable

tensorpack/graph_builder/utils.py:51–65  ·  view source on GitHub ↗

Returns: a context where all variables will be created as local.

(enable=True)

Source from the content-addressed store, hash-verified

49
50@contextmanager
51def override_to_local_variable(enable=True):
52 """
53 Returns:
54 a context where all variables will be created as local.
55 """
56 if enable:
57
58 def custom_getter(getter, name, *args, **kwargs):
59 _replace_global_by_local(kwargs)
60 return getter(name, *args, **kwargs)
61
62 with custom_getter_scope(custom_getter):
63 yield
64 else:
65 yield
66
67
68# https://github.com/tensorflow/benchmarks/blob/48cbef14a592e02a14beee8e9aef3ad22cadaed1/scripts/tf_cnn_benchmarks/variable_mgr_util.py#L192-L218

Callers 5

buildMethod · 0.85
call_for_each_towerMethod · 0.85
buildMethod · 0.85
add_moving_summaryFunction · 0.85
_setup_inputMethod · 0.85

Calls 1

custom_getter_scopeFunction · 0.85

Tested by

no test coverage detected