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

Method get_variable

tensorflow/python/ops/variable_scope.py:496–805  ·  view source on GitHub ↗

Gets an existing variable with these parameters or create a new one. If a variable with the given name is already stored, we return the stored variable. Otherwise, we create a new one. Set `reuse` to `True` when you only want to reuse existing Variables. Set `reuse` to `False` when

(self,
                   name,
                   shape=None,
                   embedding_block_num=None,
                   dtype=dtypes.float32,
                   initializer=None,
                   regularizer=None,
                   reuse=None,
                   trainable=None,
                   collections=None,
                   caching_device=None,
                   partitioner=None,
                   validate_shape=True,
                   use_resource=None,
                   custom_getter=None,
                   constraint=None,
                   synchronization=VariableSynchronization.AUTO,
                   aggregation=VariableAggregation.NONE,
                   invalid_key=None,
                   evconfig=variables.EmbeddingVariableConfig(),
                   ht_partition_num=1000)

Source from the content-addressed store, hash-verified

494 return distribute_hashtable_var
495
496 def get_variable(self,
497 name,
498 shape=None,
499 embedding_block_num=None,
500 dtype=dtypes.float32,
501 initializer=None,
502 regularizer=None,
503 reuse=None,
504 trainable=None,
505 collections=None,
506 caching_device=None,
507 partitioner=None,
508 validate_shape=True,
509 use_resource=None,
510 custom_getter=None,
511 constraint=None,
512 synchronization=VariableSynchronization.AUTO,
513 aggregation=VariableAggregation.NONE,
514 invalid_key=None,
515 evconfig=variables.EmbeddingVariableConfig(),
516 ht_partition_num=1000):
517 """Gets an existing variable with these parameters or create a new one.
518
519 If a variable with the given name is already stored, we return the stored
520 variable. Otherwise, we create a new one.
521
522 Set `reuse` to `True` when you only want to reuse existing Variables.
523 Set `reuse` to `False` when you only want to create new Variables.
524 Set `reuse` to None (the default) or tf.compat.v1.AUTO_REUSE when you want
525 variables to be created if they don't exist or returned if they do.
526
527 If initializer is `None` (the default), the default initializer passed in
528 the constructor is used. If that one is `None` too, we use a new
529 `glorot_uniform_initializer`. If initializer is a Tensor, we use
530 it as a value and derive the shape from the initializer.
531
532 If a partitioner is provided, a `PartitionedVariable` is returned.
533 Accessing this object as a `Tensor` returns the shards concatenated along
534 the partition axis.
535
536 Some useful partitioners are available. See, e.g.,
537 `variable_axis_size_partitioner` and `min_max_variable_partitioner`.
538
539 Args:
540 name: The name of the new or existing variable.
541 shape: Shape of the new or existing variable.
542 dtype: Type of the new or existing variable (defaults to `DT_FLOAT`).
543 initializer: Initializer for the variable.
544 regularizer: A (Tensor -> Tensor or None) function; the result of applying
545 it on a newly created variable will be added to the collection
546 GraphKeys.REGULARIZATION_LOSSES and can be used for regularization.
547 reuse: a Boolean, None, or tf.AUTO_REUSE. Controls reuse or creation of
548 variables. When eager execution is enabled this argument is always
549 forced to be False.
550 trainable: If `True` also add the variable to the graph collection
551 `GraphKeys.TRAINABLE_VARIABLES` (see `tf.Variable`). `trainable`
552 defaults to `True`, unless `synchronization` is set to `ON_READ`, in
553 which case it defaults to `False`.

Callers

nothing calls this directly

Calls 2

custom_getterFunction · 0.85
executing_eagerlyMethod · 0.80

Tested by

no test coverage detected