I have a 4-D array a where a.shape = (300, 300, 40, 193)
I want to reshape it to shape (40, 300*300*193).
So, after the reshape, new_a[0,:] should be equivalent to a[:,:,0,:].ravel()
What is proper way to use numpy.reshape to do this?
I have a 4-D array a where a.shape = (300, 300, 40, 193)
I want to reshape it to shape (40, 300*300*193).
So, after the reshape, new_a[0,:] should be equivalent to a[:,:,0,:].ravel()
What is proper way to use numpy.reshape to do this?
One way to do this is to use
np.rollaxis. Roll axis number 2 to be in front of axis number 0, then reshape.Here's a smaller version for demonstration: