Reputation: 61
I am writing an application using TensorFlow and I'm using the tf.transpose() function. The API states that the function returns a transposed tensor, which is what you'd expect. However, I noticed the following phenomenon:
>>> tf.transpose([3, 5])
<tf.Tensor 'transpose:0' shape=(2,) dtype=int32>
>>> a = tf.transpose([3, 5])
>>> a
<tf.Tensor 'transpose_1:0' shape=(2,) dtype=int32>
>>> a == tf.transpose([3, 5])
Does anyone know why this happens or how it should be used?
Upvotes: 1
Views: 58
Reputation: 61
Oops, I answered my question as soon as I posted it... I think they are just not equivalent because they are two different tensor objects, even though they have the same value. I was thrown off by the naming convention. We can see this here:
>>> a = tf.transpose([3, 5], name='a')
>>> tf.transpose([3, 5], name='b')
<tf.Tensor 'b:0' shape=(2,) dtype=int32>
>>> a
<tf.Tensor 'a:0' shape=(2,) dtype=int32>
Upvotes: 1