I have a 4d numpy array which represents a dataset with 3d instances. Lets say that the shape of the array is (32, 32, 3, 73257).
(32, 32, 3, 73257)
How can i change the
It looks like np.rollaxis(arr, axis=-1) will do what you want. Example:
np.rollaxis(arr, axis=-1)
>>> arr = np.empty(32, 32, 3, 73257) >>> arr2 = np.rollaxis(arr, axis=-1) >>> arr2.shape (73257, 32, 32, 3)
This will make arr[i,j,k,l] == arr2[l,i,j,k] for all ijkl
arr[i,j,k,l] == arr2[l,i,j,k]
ijkl