Creates a context for the variable_scope, see `variable_scope` for docs. Note: this does not create a name scope. Args: name_or_scope: `string` or `VariableScope`: the scope to open. reuse: `True` or None, or tf.compat.v1.AUTO_REUSE; if `None`, we inherit the parent sco
(self,
name_or_scope,
reuse=None,
initializer=None,
regularizer=None,
caching_device=None,
partitioner=None,
custom_getter=None,
old_name_scope=None,
dtype=dtypes.float32,
use_resource=None,
constraint=None)
| 2535 | """A context for the variable_scope, see `variable_scope` for docs.""" |
| 2536 | |
| 2537 | def __init__(self, |
| 2538 | name_or_scope, |
| 2539 | reuse=None, |
| 2540 | initializer=None, |
| 2541 | regularizer=None, |
| 2542 | caching_device=None, |
| 2543 | partitioner=None, |
| 2544 | custom_getter=None, |
| 2545 | old_name_scope=None, |
| 2546 | dtype=dtypes.float32, |
| 2547 | use_resource=None, |
| 2548 | constraint=None): |
| 2549 | """Creates a context for the variable_scope, see `variable_scope` for docs. |
| 2550 | |
| 2551 | Note: this does not create a name scope. |
| 2552 | |
| 2553 | Args: |
| 2554 | name_or_scope: `string` or `VariableScope`: the scope to open. |
| 2555 | reuse: `True` or None, or tf.compat.v1.AUTO_REUSE; if `None`, we inherit |
| 2556 | the parent scope's reuse flag. |
| 2557 | initializer: default initializer for variables within this scope. |
| 2558 | regularizer: default regularizer for variables within this scope. |
| 2559 | caching_device: default caching device for variables within this scope. |
| 2560 | partitioner: default partitioner for variables within this scope. |
| 2561 | custom_getter: default custom getter for variables within this scope. |
| 2562 | old_name_scope: the original name scope when re-entering a variable scope. |
| 2563 | dtype: type of the variables within this scope (defaults to `DT_FLOAT`). |
| 2564 | use_resource: If False, variables in this scope will be regular Variables. |
| 2565 | If True, experimental ResourceVariables will be creates instead, with |
| 2566 | well-defined semantics. Defaults to False (will later change to True). |
| 2567 | constraint: An optional projection function to be applied to the variable |
| 2568 | after being updated by an `Optimizer` (e.g. used to implement norm |
| 2569 | constraints or value constraints for layer weights). The function must |
| 2570 | take as input the unprojected Tensor representing the value of the |
| 2571 | variable and return the Tensor for the projected value (which must have |
| 2572 | the same shape). Constraints are not safe to use when doing asynchronous |
| 2573 | distributed training. |
| 2574 | """ |
| 2575 | self._name_or_scope = name_or_scope |
| 2576 | self._reuse = reuse |
| 2577 | self._initializer = initializer |
| 2578 | self._regularizer = regularizer |
| 2579 | self._caching_device = caching_device |
| 2580 | self._partitioner = partitioner |
| 2581 | self._custom_getter = custom_getter |
| 2582 | self._old_name_scope = old_name_scope |
| 2583 | self._dtype = dtype |
| 2584 | self._use_resource = use_resource |
| 2585 | self._constraint = constraint |
| 2586 | self._var_store = _get_default_variable_store() |
| 2587 | self._var_scope_store = get_variable_scope_store() |
| 2588 | self._last_variable_scope_object = None |
| 2589 | if isinstance(self._name_or_scope, VariableScope): |
| 2590 | self._new_name = self._name_or_scope.name |
| 2591 | name_scope = self._name_or_scope._name_scope # pylint: disable=protected-access |
| 2592 | # Handler for the case when we jump to a shared scope. We create a new |
| 2593 | # VariableScope (self._var_scope_object) that contains a copy of the |
| 2594 | # provided shared scope, possibly with changed reuse and initializer, if |
nothing calls this directly
no test coverage detected