我使用 numpy.savez_compressed()保存了一些数组。其中一个阵列是巨大的,它的形状(120000,7680),类型 float32 。
尝试加载数组给了我下面的错误(使用 Ipython 捕获的消息)
似乎这是 Numpy 限制:
Numpy: apparent memory error
有什么其他方法可以保存如此庞大的阵列? (我也遇到了 cPickle 的问题)
In [5]: t=numpy.load('humongous.npz')
In [6]: humg = (t['arr_0.npy'])
/usr/lib/python2.7/dist-packages/numpy/lib/npyio.pyc in __getitem__(self, key)
229 if bytes.startswith(format.MAGIC_PREFIX):
230 value = BytesIO(bytes)
--> 231 return format.read_array(value)
232 else:
233 return bytes
/usr/lib/python2.7/dist-packages/numpy/lib/format.pyc in read_array(fp)
456 # way.
457 # XXX: we can probably chunk this to avoid the memory hit.
--> 458 data = fp.read(int(count * dtype.itemsize))
459 array = numpy.fromstring(data, dtype=dtype, count=count)
460
SystemError: error return without exception set
系统:Ubuntu 12.04 64位,Python 2.7,numpy 1.6.1