(self, name=None)
| 37 | """Computes the rate of change since the last rate call.""" |
| 38 | |
| 39 | def __init__(self, name=None): |
| 40 | self._built = False |
| 41 | self._vars = [] |
| 42 | self._initial_values = {} |
| 43 | name = name or self.__class__.__name__ |
| 44 | # Replace things like spaces in name to create a valid scope name. |
| 45 | scope_name = _to_replace.sub("_", name) |
| 46 | # We create the variable scope now to get the unique name that will |
| 47 | # be used as a variable prefix when build() calls _add_variable(). |
| 48 | with variable_scope.variable_scope( |
| 49 | scope_name, use_resource=True, reuse=False) as scope: |
| 50 | pos = scope.name.rfind(scope_name) |
| 51 | self._name = name + scope.name[pos + len(scope_name):] |
| 52 | self._scope = scope |
| 53 | |
| 54 | # Ensures that if the user calls build directly we still set self._built to |
| 55 | # True to prevent variables from being recreated. |
| 56 | self._build = self.build |
| 57 | if context.executing_eagerly(): |
| 58 | self._construction_scope = context.eager_mode |
| 59 | else: |
| 60 | # We make self.call() into a graph callable here, so that we can |
| 61 | # return a single op that performs all of the variable updates. |
| 62 | self._construction_scope = ops.get_default_graph().as_default |
| 63 | self.call = function.defun(self.call) |
| 64 | |
| 65 | def build(self, values, denominator): |
| 66 | """Method to create variables. |
nothing calls this directly
no test coverage detected