tf.contrib.framework.variable(
name,
shape=None,
dtype=None,
initializer=None,
regularizer=None,
trainable=True,
collections=None,
caching_device=None,
device=None,
partitioner=None,
custom_getter=None,
use_resource=None,
synchronization=tf.VariableSynchronization.AUTO,
aggregation=tf.VariableAggregation.NONE
)
Defined in tensorflow/contrib/framework/python/ops/variables.py.
Gets an existing variable with these parameters or creates a new one.
Args:
name: the name of the new or existing variable.shape: shape of the new or existing variable.dtype: type of the new or existing variable (defaults toDT_FLOAT).initializer: initializer for the variable if one is created.regularizer: a (Tensor -> Tensor or None) function; the result of applying it on a newly created variable will be added to the collection GraphKeys.REGULARIZATION_LOSSES and can be used for regularization.trainable: IfTruealso add the variable to the graph collectionGraphKeys.TRAINABLE_VARIABLES(seetf.Variable).collections: A list of collection names to which the Variable will be added. If None it would default totf.GraphKeys.GLOBAL_VARIABLES.caching_device: Optional device string or function describing where the Variable should be cached for reading. Defaults to the Variable's device.device: Optional device to place the variable. It can be an string or a function that is called to get the device for the variable.partitioner: Optional callable that accepts a fully definedTensorShapeand dtype of theVariableto be created, and returns a list of partitions for each axis (currently only one axis can be partitioned).custom_getter: Callable that allows overwriting the internal get_variable method and has to have the same signature.use_resource: IfTrueuse a ResourceVariable instead of a Variable.synchronization: Indicates when a distributed a variable will be aggregated. Accepted values are constants defined in the classtf.VariableSynchronization. By default the synchronization is set toAUTOand the currentDistributionStrategychooses when to synchronize. Ifsynchronizationis set toON_READ,trainablemust not be set toTrue.aggregation: Indicates how a distributed variable will be aggregated. Accepted values are constants defined in the classtf.VariableAggregation.
Returns:
The created or existing variable.