Answers for "what is permutate argument(perm) in tf.transpose?"

0

what is permutate argument(perm) in tf.transpose?

x = tf.constant([[[ 1, 2, 3], 
                    [ 4, 5, 6]], 
                   [[ 7, 8, 9], 
                    [ 10, 11, 12]], 
                   [[ 13, 14, 15], 
                    [ 16, 17, 18]], 
                   [[ 19, 20, 21], 
                    [ 22, 23, 24]]]) 
transposed_tensor = tf.transpose(x, perm = [2,1,0]) 
# if you run x.shape
x.shape
>>>TensorShape([4, 2, 3])
# if you run transpose.shape
transpose.shape
>>>TensorShape([3,2,4])
# now change the perm argument of tf.transpose to perm = [0,1,2]
transpose.shape
>>>TensorShape([4,2,3])
## now change the perm argument of tf.transpose to perm = [1,2,0]
transpose.shape
>>>TensorShape([2,3,4])
# that means if we consider the output of tensor as a list then we thought
# list of perm argument as a index-list of shape of input array.so,if we change
# the value of list in perm we see the corresponding change of input array shape
# as output of transpose shape
Posted by: Guest on February-02-2021

Code answers related to "what is permutate argument(perm) in tf.transpose?"

Python Answers by Framework

Browse Popular Code Answers by Language