Created
December 6, 2023 16:53
-
-
Save shubhamwagh/c26811ce7be45564c382f3e4f9df6436 to your computer and use it in GitHub Desktop.
tf tranpose alternative
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shape = (3,4,5) | |
a = tf.random.uniform(shape) | |
a_t = tf.transpose(a,(1,0,2)) # permuting first and second axis | |
a_concat = tf.concat([tf.reshape(a[i:i+1,:,:],(shape[1],1,shape[2])) for i in range(shape[0])],axis=1) | |
tf.debugging.assert_equal(a_t,a_concat) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment