我有一个编码为 2048 位向量的 2215 个分子的列表。我想做的是从中创建二维数组。我正在使用rdkit
库转换为 numpy 数组。几周前代码运行没有问题,现在出现内存错误,但我不知道为什么。任何人都可以提供解决方案吗?
我试图使列表更小,并将其减少到两个向量。我认为这会有所帮助,但经过一段时间的处理后仍然会出现错误。这使我相信我实际上确实有足够的记忆力。
# red_fp is the list of bit vectors
def rdkit_numpy_convert(red_fp):
output = []
for f in fp:
arr = np.zeros((1,))
DataStructs.ConvertToNumpyArray(f, arr)
output.append(arr)
return np.asarray(output)
# this one line causes the problem
x = rdkit_numpy_convert(red_fp)
这是错误:
MemoryError Traceback (most recent call last)
MemoryError: cannot allocate memory for array
The above exception was the direct cause of the following exception:
SystemError Traceback (most recent call last)
<ipython-input-14-91594513666c> in <module>
----> 1 x = rdkit_numpy_convert(red_fp)
<ipython-input-13-78d1c9fdd07e> in rdkit_numpy_convert(red_fp)
4 for f in fp:
5 arr = np.zeros((1,))
----> 6 DataStructs.ConvertToNumpyArray(f, arr)
7 output.append(arr)
8 return np.asarray(output)
SystemError: <Boost.Python.function object at 0x55a2a5743520> returned a result with an error set