我有非常大的.mat文件(~1.3 GB),我试图在我的Python代码(IPython笔记本)中加载.我试过了:
import scipy.io as sio
very_large = sio.loadmat('very_large.mat')
Run Code Online (Sandbox Code Playgroud)
我的笔记本电脑有8 GB RAM挂起.我保持系统监视器打开,看到内存消耗稳定增加到7 GB,然后系统冻结.
我究竟做错了什么?有什么建议/解决方法吗?
编辑:
有关数据的更多详细信息:以下是数据的链接:http://ufldl.stanford.edu/housenumbers/
我感兴趣的特定文件是extra_32x32.mat.从描述:加载.mat文件创建2个变量:X是包含图像的4-D矩阵,y是类标签的向量.为了访问图像,X(:,:,:,i)给出第i个32×32 RGB图像,其类标签为y(i).
因此,例如,当以下列方式加载时,来自同一页面(test_32x32.mat)的较小的.mat文件:
SVHN_full_test_data = sio.loadmat('test_32x32.mat')
print("\nData set = SVHN_full_test_data")
for key, value in SVHN_full_test_data.iteritems():
print("Type of", key, ":", type(SVHN_full_test_data[key]))
if str(type(SVHN_full_test_data[key])) == "<type 'numpy.ndarray'>":
print("Shape of", key, ":", SVHN_full_test_data[key].shape)
else:
print("Content:", SVHN_full_test_data[key])
Run Code Online (Sandbox Code Playgroud)
生产:
Data set = SVHN_full_test_data
Type of y : <type 'numpy.ndarray'>
Shape of y : (26032, 1)
Type of X : <type 'numpy.ndarray'>
Shape of …Run Code Online (Sandbox Code Playgroud)