Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Tensorflow, what is the difference between a tensor that has a type ending in _ref and a tensor that does not?

Tags:

tensorflow

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?

like image 293
dannygoldstein Avatar asked Jun 22 '16 04:06

dannygoldstein


People also ask

How are TensorFlow tensors different from TensorFlow variables?

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.

What is the difference between Eagertensor and tensor?

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.

What is TensorFlow how many types of tensors are there?

Each operation you will do with TensorFlow involves the manipulation of a tensor. There are four main tensor type you can create: tf.

What does tensor mean in TensorFlow?

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.


1 Answers

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.)

like image 124
mrry Avatar answered Sep 20 '22 07:09

mrry