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

Method __init__

tensorflow/contrib/eager/python/metrics_impl.py:98–132  ·  view source on GitHub ↗
(self, name=None, use_global_variables=False)

Source from the content-addressed store, hash-verified

96 """
97
98 def __init__(self, name=None, use_global_variables=False):
99 self._built = False
100 self._vars = []
101 self._initial_values = {}
102 self._updates = []
103 self._use_global_variables = use_global_variables
104 name = name or self.__class__.__name__
105 # Replace things like spaces in name to create a valid scope name.
106 scope_name = _to_replace.sub("_", name)
107 # We create the variable scope now to get the unique name that will
108 # be used as a variable prefix when build() calls add_variable().
109 with variable_scope.variable_scope(
110 scope_name, use_resource=True, reuse=False) as scope:
111 pos = scope.name.rfind(scope_name)
112 self._name = name + scope.name[pos + len(scope_name):]
113 self._scope = scope
114
115 # Ensures that if the user calls build directly we still set self._built to
116 # True to prevent variables from being recreated.
117 self._build = self.build
118
119 def actual_build(*args, **kwargs):
120 self._build(*args, **kwargs)
121 self._built = True
122 self.build = actual_build
123 self.build.__doc__ = self._build.__doc__
124
125 # Captures construction scope for proper initialization.
126 if context.executing_eagerly():
127 self._construction_scope = context.eager_mode
128 else:
129 # We make self.call() into a graph callable here, so that we can
130 # return a single op that performs all of the variable updates.
131 self._construction_scope = ops.get_default_graph().as_default
132 self.call = function.defun(self.call)
133
134 # ---- API for users ----
135 def __call__(self, *args, **kwargs):

Callers

nothing calls this directly

Calls 4

variable_scopeMethod · 0.80
executing_eagerlyMethod · 0.80
subMethod · 0.45
defunMethod · 0.45

Tested by

no test coverage detected