|TensorFlow 1 version||View source on GitHub|
See the variable guide.
tf.Variable( initial_value=None, trainable=None, validate_shape=True, caching_device=None, name=None, variable_def=None, dtype=None, import_scope=None, constraint=None, synchronization=tf.VariableSynchronization.AUTO, aggregation=tf.compat.v1.VariableAggregation.NONE, shape=None )
Used in the notebooks
|Used in the guide||Used in the tutorials|
A variable maintains shared, persistent state manipulated by a program.
Variable() constructor requires an initial value for the variable, which
can be a
Tensor of any type and shape. This initial value defines the type
and shape of the variable. After construction, the type and shape of the
variable are fixed. The value can be changed using one of the assign methods.
v = tf.Variable(1.)
<tf.Variable ... shape=() dtype=float32, numpy=2.0>
<tf.Variable ... shape=() dtype=float32, numpy=2.5>
shape argument to
Variable's constructor allows you to construct a
variable with a less defined shape than its
v = tf.Variable(1., shape=tf.TensorShape(None))
<tf.Variable ... shape=<unknown> dtype=float32, numpy=array([[1.]], ...)>
Just like any
Tensor, variables created with
Variable() can be used as
inputs to operations. Additionally, all the operators overloaded for the