Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In TensorFlow,what's the meaning of ":0" in a Variable's name?

Tags:

import tensorflow as tf with tf.device('/gpu:0'):     foo = tf.Variable(1, name='foo')     assert foo.name == "foo:0" with tf.device('/gpu:1'):     bar = tf.Variable(1, name='bar')     assert bar.name == "bar:0" 

The above code returns true.I use with tf.device here to illustrate that the ":0" doesn't mean the variable lie on the specific device.So what's the meaning of the ":0" in the variable's name(foo and bar in this example)?

like image 479
EncodeTS Avatar asked Dec 02 '16 05:12

EncodeTS


People also ask

What is name in TensorFlow?

The name TensorFlow derives from the operations that such neural networks perform on multidimensional data arrays, which are referred to as tensors. During the Google I/O Conference in June 2016, Jeff Dean stated that 1,500 repositories on GitHub mentioned TensorFlow, of which only 5 were from Google.

What are TensorFlow variables?

A TensorFlow variable is the recommended way to represent shared, persistent state your program manipulates. This guide covers how to create, update, and manage instances of tf. Variable in TensorFlow. Variables are created and tracked via the tf.

How do I assign a value in TensorFlow?

Tensorflow variables represent the tensors whose values can be changed by running operations on them. The assign() is the method available in the Variable class which is used to assign the new tf. Tensor to the variable. The new value must have the same shape and dtype as the old Variable value.


1 Answers

It has to do with representation of tensors in underlying API. A tensor is a value associated with output of some op. In case of variables, there's a Variable op with one output. An op can have more than one output, so those tensors get referenced to as <op>:0, <op>:1 etc. For instance if you use tf.nn.top_k, there are two values created by this op, so you may see TopKV2:0 and TopKV2:1

a,b=tf.nn.top_k([1], 1) print a.name # => 'TopKV2:0' print b.name # => 'TopKV2:1' 

How to understand the term `tensor` in TensorFlow?

like image 173
Yaroslav Bulatov Avatar answered Oct 20 '22 04:10

Yaroslav Bulatov