The docs say:
In addition, variants of these types with the _ref suffix are defined for reference-typed tensors.
What exactly does this mean? What are reference-typed tensors and how do they differ from standard ones?
Tensors v.s. Variables A variable in Tensorflow is also a wrapper around a tensor, but has a different meaning. A variable contains a tensor that is persistent and changeable across different Session.
EagreTensor represents a tensor who's value has been calculated in eager mode whereas Tensor represents a tensor node in a graph that may not yet have been calculated.
Each operation you will do with TensorFlow involves the manipulation of a tensor. There are four main tensor type you can create: tf.
A tensor is a generalization of vectors and matrices to potentially higher dimensions. Internally, TensorFlow represents tensors as n-dimensional arrays of base datatypes. Each element in the Tensor has the same data type, and the data type is always known.
A reference-typed tensor is mutable. The most common way to create a reference-typed tensor is to define a tf.Variable
: defining a tf.Variable
whose initial value has dtype tf.float32
will create a reference-typed tensor with dtype tf.float32_ref
. You can mutate a reference-typed tensor by passing it as the first argument to tf.assign()
.
(Note that reference-typed tensors are something of an implementation detail in the present version of TensorFlow. We'd encourage you to use higher-level wrappers like tf.Variable
, which may migrate to alternative representations for mutable state in the future.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With