Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 使用python在磁盘上存储数字(1';s和0';s)的大列表(10000x42x400)_List_Numpy_Pickle_H5py_Storing Data - Fatal编程技术网

List 使用python在磁盘上存储数字(1';s和0';s)的大列表(10000x42x400)

List 使用python在磁盘上存储数字(1';s和0';s)的大列表(10000x42x400),list,numpy,pickle,h5py,storing-data,List,Numpy,Pickle,H5py,Storing Data,列表-100000个案例,每个案例有42行和400列 我尝试使用numpy.save保存它,但它给了我一个内存错误。 我试了一下泡菜,它挂上了我的电脑。花了很长时间,我不得不重新启动它。 H5py不适用于64位python 3.3.5 我想将整个列表保存在磁盘上,然后将其完全加载到列表中以供进一步处理。我不打算从内存中访问特定的索引 是否有一种有效的方法来存储列表 还是从一行中提取索引并将其存储在内存中更好。(一行400位中大约有8个1)。如果我只存储一个的索引,那么稍后我将不得不再次将这些索引

列表-100000个案例,每个案例有42行和400列

我尝试使用numpy.save保存它,但它给了我一个内存错误。 我试了一下泡菜,它挂上了我的电脑。花了很长时间,我不得不重新启动它。 H5py不适用于64位python 3.3.5

我想将整个列表保存在磁盘上,然后将其完全加载到列表中以供进一步处理。我不打算从内存中访问特定的索引

是否有一种有效的方法来存储列表


还是从一行中提取索引并将其存储在内存中更好。(一行400位中大约有8个1)。如果我只存储一个的索引,那么稍后我将不得不再次将这些索引转换为400位数组。

numpy.save应该适用于此。也许你说的不对?以下代码适用于我:

a = np.ones((100000, 400))
np.save('output', a)

为了最大限度地减少开销,您可以使用以下方法将原始二进制数据从内存转储到磁盘:

import numpy as np

fname = "/tmp/aa.bin"
shape = (100, 100)
aa = np.random.randn(*shape)  # make an array
dtyp = aa.dtype  # store data type (here: np.float64)

aa.tofile(fname) # dump to file


with open(fname, 'rb') as f:  # read from file
    bb = np.fromfile(file=f, dtype=np.dtyp).reshape(shape)

print(np.all(aa == bb)) # prints True

请注意兼容性主题,如endianess、存储顺序等。有关更多信息,请参阅。

如果存储紧凑,则仅为40 MB或5 MB。不是很大。使用类似“抱歉”的方式,实际列表大小为10000x41x400