1

Whenever using tensorflow variables's name, I have had a question why they ended by blabla:0. So I should use split function like v.name.split(':')[0].

Despite there is same name's variables, the tail's name wouldn't be changed, like my expectation aaa:0, aaa:1.

Does anybody know why tensorflow does this?

I couldn't find this reason on tensorflow.org or via googling.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
semenbari
  • 725
  • 1
  • 8
  • 22

1 Answers1

3

The offending integer is added in the Tensor class, and is the "value index":

value_index: An int. Index of the operation's endpoint that produces this tensor.

It's not always zero! For example:

>>> import tensorflow as tf
>>> tf.unique([1,2,3])

Prints:

Unique(y=<tf.Tensor 'Unique:0' shape=(?,) dtype=int32>, idx=<tf.Tensor 'Unique:1' shape=(3,) dtype=int32>)

So the first output has the ":0" suffix, but the second has a ":1" suffix since it's the second output of the op.

Allen Lavoie
  • 5,778
  • 1
  • 17
  • 26