调用np.vstack()时获取MemoryError

时间:2015-10-22 06:31:24

标签: python numpy memory out-of-memory ram

我正在UCF运动数据集中进行动作识别。我已经提取了所有功能。但我需要将所有这些功能保存在一个numpy数组中。

test = []
train = []
test.append(allhogs[i])
test.append(allhogs[i+1])
vid_descs = []
print allhogs[i]
for el in allhogs[0:i]:
    train.append(el)
for el in allhogs[i+2:]:
   train.append(el)
   feat = s.genfromtxt('/media/prithviraj/Seagate Backup Plus Drive/ucf_sports_feat/' + el)
   # print feat
   k = len(feat)/96
   feat = np.asarray(feat)      
   feat= feat.reshape((k,96))  
   vid_descs.append(feat)
vid_descs = np.asarray(vid_descs)

all_desc = np.vstack(vid_descs)
print all_desc.shape

我收到此错误:

Traceback (most recent call last):
File "t.py", line 39, in <module>
all_desc = np.vstack(vid_descs)
File "/usr/lib/python2.7/dist-packages/numpy/core/shape_base.py", line 228, in vstack
return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
MemoryError

vid_descs数组的形状是(298,723456,96)。我还保存了vid_descs数组,发现它的大小为6 GB。我的系统内存也是6GB。那么我应该迁移到具有更高RAM的系统吗?还有其他解决方案吗?

0 个答案:

没有答案