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)
| 3452 | @tf_export(v1=["variable_creator_scope"]) |
| 3453 | @tf_contextlib.contextmanager |
| 3454 | def variable_creator_scope_v1(variable_creator): |
| 3455 | """Scope which defines a variable creation function to be used by variable(). |
| 3456 | |
| 3457 | variable_creator is expected to be a function with the following signature: |
| 3458 | |
| 3459 | ``` |
| 3460 | def variable_creator(next_creator, **kwargs) |
| 3461 | ``` |
| 3462 | |
| 3463 | The creator is supposed to eventually call the next_creator to create a |
| 3464 | variable if it does want to create a variable and not call Variable or |
| 3465 | ResourceVariable directly. This helps make creators composable. A creator may |
| 3466 | choose to create multiple variables, return already existing variables, or |
| 3467 | simply register that a variable was created and defer to the next creators in |
| 3468 | line. Creators can also modify the keyword arguments seen by the next |
| 3469 | creators. |
| 3470 | |
| 3471 | Custom getters in the variable scope will eventually resolve down to these |
| 3472 | custom creators when they do create variables. |
| 3473 | |
| 3474 | The valid keyword arguments in kwds are: |
| 3475 | initial_value: A `Tensor`, or Python object convertible to a `Tensor`, |
| 3476 | which is the initial value for the Variable. The initial value must have |
| 3477 | a shape specified unless `validate_shape` is set to False. Can also be a |
| 3478 | callable with no argument that returns the initial value when called. In |
| 3479 | that case, `dtype` must be specified. (Note that initializer functions |
| 3480 | from init_ops.py must first be bound to a shape before being used here.) |
| 3481 | trainable: If `True`, the default, also adds the variable to the graph |
| 3482 | collection `GraphKeys.TRAINABLE_VARIABLES`. This collection is used as |
| 3483 | the default list of variables to use by the `Optimizer` classes. |
| 3484 | `trainable` defaults to `True`, unless `synchronization` is |
| 3485 | set to `ON_READ`, in which case it defaults to `False`. |
| 3486 | collections: List of graph collections keys. The new variable is added to |
| 3487 | these collections. Defaults to `[GraphKeys.GLOBAL_VARIABLES]`. |
| 3488 | validate_shape: If `False`, allows the variable to be initialized with a |
| 3489 | value of unknown shape. If `True`, the default, the shape of |
| 3490 | `initial_value` must be known. |
| 3491 | caching_device: Optional device string describing where the Variable |
| 3492 | should be cached for reading. Defaults to the Variable's device. |
| 3493 | If not `None`, caches on another device. Typical use is to cache |
| 3494 | on the device where the Ops using the Variable reside, to deduplicate |
| 3495 | copying through `Switch` and other conditional statements. |
| 3496 | name: Optional name for the variable. Defaults to `'Variable'` and gets |
| 3497 | uniquified automatically. |
| 3498 | dtype: If set, initial_value will be converted to the given type. |
| 3499 | If `None`, either the datatype will be kept (if `initial_value` is |
| 3500 | a Tensor), or `convert_to_tensor` will decide. |
| 3501 | constraint: A constraint function to be applied to the variable after |
| 3502 | updates by some algorithms. |
| 3503 | use_resource: if True, a ResourceVariable is always created. |
| 3504 | synchronization: Indicates when a distributed a variable will be |
| 3505 | aggregated. Accepted values are constants defined in the class |
| 3506 | `tf.VariableSynchronization`. By default the synchronization is set to |
| 3507 | `AUTO` and the current `DistributionStrategy` chooses |
| 3508 | when to synchronize. |
| 3509 | aggregation: Indicates how a distributed variable will be aggregated. |
| 3510 | Accepted values are constants defined in the class |
| 3511 | `tf.VariableAggregation`. |
nothing calls this directly
no test coverage detected