我有一个巨大的数组,我想用小数组计算点积。但我越来越'阵列太大'有没有解决办法?巨大数组的点积numpy
import numpy as np
eMatrix = np.random.random_integers(low=0,high=100,size=(20000000,50))
pMatrix = np.random.random_integers(low=0,high=10,size=(50,50))
a = np.dot(eMatrix,pMatrix)
Error:
/Library/Python/2.7/site-packages/numpy/random/mtrand.so in mtrand.RandomState.random_integers (numpy/random/mtrand/mtrand.c:9385)()
/Library/Python/2.7/site-packages/numpy/random/mtrand.so in mtrand.RandomState.randint (numpy/random/mtrand/mtrand.c:7051)()
ValueError: array is too big.
这种情况已经发生在eMatrix =,no?您要求10^9个整数 - 每个整数字节数的1倍。所以至少应该将它们放入dtype int8而不是默认的int64数组中。 – mdurant 2014-09-05 14:33:04
但是我有一台64位的机器,内存为16GB RAM – Lanc 2014-09-05 14:51:56
所以8GB的第一个ePrime,至少也是一样的,也许还有一些看不见的中间产品。 – mdurant 2014-09-05 14:53:59