I am trying to understand how numpy.transpose command works.
a=np.arange(24).reshape(2,3,4)
According to my understanding numpy stores data like this
[[0 1 2 3], [4,5,6,7], [8,9,10,11]]
[[12,13,14,15],[16,17,18,19],[20,21,22,23]]
so there are two samples and 4 channels. In simple math language transpose means convert rows into columns and columns into rows. But how following command works
b= np.transpose(a,(1,0,2))
I have go through the documentation and also questions posted to this website related to this command. But still its not clear to me. can someone please explain this permutation of axes according to the storage pattern that I mentioned above.
print(a.shape)(before and aftertranspose()) might help illustrate what it does.numpyactually stores the data in a flat array, and maps the multidimensional indices onto that using theshapeandstridesattributes.transposejust changes those attributes, and hence the mapping. It doesn't change the storage.