4

I have a tensor of unknown shape, but it is at least 3 dimensional, i.e. shape=[a, b, c, ...]. I would like to switch dimensions a and b, without knowing how long the tensor is (so I can't use tf.transpose, as suggested in this question)

Toke Faurby
  • 5,788
  • 9
  • 41
  • 62

1 Answers1

2

This works, but is ugly:

tf.transpose(x, [1, 0] + [i+2 for i in range(tf.shape(x).shape[0]-2)])
Toke Faurby
  • 5,788
  • 9
  • 41
  • 62