Class VariableScope
Defined in tensorflow/python/ops/variable_scope.py
.
Variable scope object to carry defaults to provide to get_variable
.
Many of the arguments we need for get_variable
in a variable store are most
easily handled with a context. This object is used for the defaults.
Attributes:
name
: name of the current scope, used as prefix in get_variable.initializer
: default initializer passed to get_variable.regularizer
: default regularizer passed to get_variable.reuse
: Boolean, None, or tf.AUTO_REUSE, setting the reuse in get_variable. When eager execution is enabled this argument is always forced to be False.caching_device
: string, callable, or None: the caching device passed to get_variable.partitioner
: callable orNone
: the partitioner passed toget_variable
.custom_getter
: default custom getter passed to get_variable.name_scope
: The name passed totf.name_scope
.dtype
: default type passed to get_variable (defaults to DT_FLOAT).use_resource
: if False, create a normal Variable; if True create an experimental ResourceVariable with well-defined semantics. Defaults to False (will later change to True). When eager execution is enabled this argument is always forced to be True.constraint
: An optional projection function to be applied to the variable after being updated by anOptimizer
(e.g. used to implement norm constraints or value constraints for layer weights). The function must take as input the unprojected Tensor representing the value of the variable and return the Tensor for the projected value (which must have the same shape). Constraints are not safe to use when doing asynchronous distributed training.
__init__
__init__(
reuse,
name='',
initializer=None,
regularizer=None,
caching_device=None,
partitioner=None,
custom_getter=None,
name_scope='',
dtype=tf.dtypes.float32,
use_resource=None,
constraint=None
)
Creates a new VariableScope with the given properties.
Properties
caching_device
constraint
custom_getter
dtype
initializer
name
original_name_scope
partitioner
regularizer
reuse
use_resource
Methods
tf.VariableScope.get_collection
get_collection(name)
Get this scope's variables.
tf.VariableScope.get_variable
get_variable(
var_store,
name,
shape=None,
dtype=None,
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=tf.VariableSynchronization.AUTO,
aggregation=tf.VariableAggregation.NONE
)
Gets an existing variable with this name or create a new one.
tf.VariableScope.global_variables
global_variables()
Get this scope's global variables.
tf.VariableScope.local_variables
local_variables()
Get this scope's local variables.
tf.VariableScope.reuse_variables
reuse_variables()
Reuse variables in this scope.
tf.VariableScope.set_caching_device
set_caching_device(caching_device)
Set caching_device for this scope.
tf.VariableScope.set_custom_getter
set_custom_getter(custom_getter)
Set custom getter for this scope.
tf.VariableScope.set_dtype
set_dtype(dtype)
Set data type for this scope.
tf.VariableScope.set_initializer
set_initializer(initializer)
Set initializer for this scope.
tf.VariableScope.set_partitioner
set_partitioner(partitioner)
Set partitioner for this scope.
tf.VariableScope.set_regularizer
set_regularizer(regularizer)
Set regularizer for this scope.
tf.VariableScope.set_use_resource
set_use_resource(use_resource)
Sets whether to use ResourceVariables for this scope.
tf.VariableScope.trainable_variables
trainable_variables()
Get this scope's trainable variables.