一、scio库
import scipy.io as scio
dataFile = 'G:/radar data/data(20,20).mat'
data = scio.loadmat(dataFile)
X_train = data['X_train']
Y_train = data['Y_train']
X_val = data['X_val']
Y_val = data['Y_val']
X_test = data['X_test']
Y_test = data['Y_test']
结果:
如果mat文件太大,存储时采用了下图第一个选项,采用scio读取就会报错
报错如下,此时就要采用第二种方法了
NotImplementedError: Please use HDF reader for matlab v7.3 files
二、h5py库
import h5py
data = h5py.File('G:/radar data/data(40, 40).mat','r')
X_train = data['X_train'][:]
Y_train = data['Y_train'][:]
X_val = data['X_val'][:]
Y_val = data['Y_val'][:]
X_test = data['X_test'][:]
Y_test = data['Y_test'][:]
结果:
注意:两种方法读取之后array的通道表示不一样,需要自行调整