arrays - Python Memorry error -
i new python , below code,
import numpy np val = 4**10 q = [] j in range(60): = [] in range(val): tmp = (i+j)**2 a.append(tmp) q.append(a) t= zip(*q) g = [] t in t: tmps2 = np.average(t) g.append(tmps2) below code error:
memoryerror traceback (most recent phone call last) c:\python27\lib\site-packages\ipython\utils\py3compat.pyc in execfile(fname, glo b, loc) 169 else: 170 filename = fname --> 171 exec compile(scripttext, filename, 'exec') in glob, loc 172 else: 173 def execfile(fname, *where): c:\users\user\desktop\simpl.py in <module>() 13 14 ---> 15 t= zip(*q) 16 17 g = [] memoryerror: so, can expert explain me, computer still have 1.5gb memory.
you can accomplish much more efficiently with:
i,j= np.indices((60, 4**10)) q = (i+j)**2 g = np.average(q, axis=0) the biggest advantages are:
avoid loops more efficient memory usage.in illustration transpose of q not used, not memory error.
python arrays memory numpy
No comments:
Post a Comment