|View source on GitHub|
Gets an existing variable with these parameters or create a new one.
tf.compat.v1.get_variable( name, shape=None, dtype=None, initializer=None, regularizer=None, trainable=None, collections=None, caching_device=None, partitioner=None, validate_shape=True, use_resource=None, custom_getter=None, constraint=None, synchronization=tf.VariableSynchronization.AUTO, aggregation=tf.compat.v1.VariableAggregation.NONE )
Used in the notebooks
|Used in the guide|
This function prefixes the name with the current variable scope and performs reuse checks. See the Variable Scope How To for an extensive description of how reusing works. Here is a basic example:
def foo(): with tf.variable_scope("foo", reuse=tf.AUTO_REUSE): v = tf.get_variable("v", ) return v v1 = foo() # Creates v. v2 = foo() # Gets the same, existing v. assert v1 == v2
If initializer is
None (the default), the default initializer passed in
the variable scope will be used. If that one is
None too, a
glorot_uniform_initializer will be used. The initializer can also be
a Tensor, in which case the variable is initialized to this value and shape.
Similarly, if the regularizer is
None (the default), the default regularizer
passed in the variable scope will be used (if that is
then by default no regularization is performed).
If a partitioner is provided, a
PartitionedVariable is returned.
Accessing this object as a
Tensor returns the shards concatenated along
the partition axis.
Some useful partitioners are available. See, e.g.,
||The name of the new or existing variable.|
||Shape of the new or existing variable.|
Type of the new or existing variable (defaults to
||Initializer for the variable if one is created. Can either be an initializer object or a Tensor. If it's a Tensor, its shape must be known unless validate_shape is False.|