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.Vari
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?