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

Function variable_creator_scope

tensorflow/python/ops/variable_scope.py:3529–3592  ·  view source on GitHub ↗

Scope which defines a variable creation function to be used by variable(). variable_creator is expected to be a function with the following signature: ``` def variable_creator(next_creator, **kwargs) ``` The creator is supposed to eventually call the next_creator to create a variabl

(variable_creator)

Source from the content-addressed store, hash-verified

3527@tf_export("variable_creator_scope", v1=[])
3528@tf_contextlib.contextmanager
3529def variable_creator_scope(variable_creator):
3530 """Scope which defines a variable creation function to be used by variable().
3531
3532 variable_creator is expected to be a function with the following signature:
3533
3534 ```
3535 def variable_creator(next_creator, **kwargs)
3536 ```
3537
3538 The creator is supposed to eventually call the next_creator to create a
3539 variable if it does want to create a variable and not call Variable or
3540 ResourceVariable directly. This helps make creators composable. A creator may
3541 choose to create multiple variables, return already existing variables, or
3542 simply register that a variable was created and defer to the next creators in
3543 line. Creators can also modify the keyword arguments seen by the next
3544 creators.
3545
3546 Custom getters in the variable scope will eventually resolve down to these
3547 custom creators when they do create variables.
3548
3549 The valid keyword arguments in kwds are:
3550 initial_value: A `Tensor`, or Python object convertible to a `Tensor`,
3551 which is the initial value for the Variable. The initial value must have
3552 a shape specified unless `validate_shape` is set to False. Can also be a
3553 callable with no argument that returns the initial value when called. In
3554 that case, `dtype` must be specified. (Note that initializer functions
3555 from init_ops.py must first be bound to a shape before being used here.)
3556 trainable: If `True`, the default, GradientTapes automatically watch
3557 uses of this Variable.
3558 validate_shape: If `False`, allows the variable to be initialized with a
3559 value of unknown shape. If `True`, the default, the shape of
3560 `initial_value` must be known.
3561 caching_device: Optional device string describing where the Variable
3562 should be cached for reading. Defaults to the Variable's device.
3563 If not `None`, caches on another device. Typical use is to cache
3564 on the device where the Ops using the Variable reside, to deduplicate
3565 copying through `Switch` and other conditional statements.
3566 name: Optional name for the variable. Defaults to `'Variable'` and gets
3567 uniquified automatically.
3568 dtype: If set, initial_value will be converted to the given type.
3569 If `None`, either the datatype will be kept (if `initial_value` is
3570 a Tensor), or `convert_to_tensor` will decide.
3571 constraint: A constraint function to be applied to the variable after
3572 updates by some algorithms.
3573 synchronization: Indicates when a distributed a variable will be
3574 aggregated. Accepted values are constants defined in the class
3575 `tf.VariableSynchronization`. By default the synchronization is set to
3576 `AUTO` and the current `DistributionStrategy` chooses
3577 when to synchronize.
3578 aggregation: Indicates how a distributed variable will be aggregated.
3579 Accepted values are constants defined in the class
3580 `tf.VariableAggregation`.
3581
3582 This set may grow over time, so it's important the signature of creators is as
3583 mentioned above.
3584
3585 Args:
3586 variable_creator: the passed creator

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected