Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does get_tensor_by_name require appending a port to the tensor name

I know that when getting a tensor by name that I must append an output index

ex)

graph.get_tensor_by_name('example:0')

Where :0 is the output index. But why is this necessary?

here is a link to get_tensor_by_name in tensorflow's docs. However, it does not mention specifying an output index.

like image 457
BadProgrammer Avatar asked Jan 03 '17 22:01

BadProgrammer


1 Answers

In TensorFlow, names are given to tf.Operation objects (which correspond to nodes in the tf.Graph), and a tf.Tensor object is named for the tf.Operation that produces it as an output.

Since a tf.Operation can have more than one output, to name a tf.Tensor uniquely, we include its index in the the outputs as part of its name.

Therefore, we chose the following format for the name of a tf.Tensor object, which is also the value returned by the tf.Tensor.name property:

<name of operation>:<index of output>
like image 137
mrry Avatar answered Oct 07 '22 09:10

mrry