% save .mat file in the matlab
train_set_x=1:50*1*51*61*23;
train_set_x=reshape(train_set_x,[50,1,51,61,23]);
save(['pythonTest.mat'],'train_set_x','-v7.3');
The data obtained in the matlab is in the size of (50,1,51,61,23).
I load the .mat file in Python with the instruction of this link.
The code is as follows:
import numpy as np, h5py
f = h5py.File('pythonTest.mat', 'r')
train_set_x = f.get('train_set_x')
train_set_x = np.array(train_set_x)
The output of train_set_x.shape is (23L, 61L, 51L, 1L, 50L)
. It is expected to be (50L, 1L, 51L, 61L, 23L)
. So I changed the shape by
train_set_x=np.transpose(train_set_x, (4,3,2,1,0))
I am curious about the change in data shape between Python and matlab. Is there some errors in my code?