我想使用np。()生成三个序列,但需要很长时间。以下是我的代码:
mom_grid_number=1000
import codecs, json
import time
import os,sys
import numpy as np
ts=time.time()
i_grid_seq = np.concatenate(\
[np.zeros(mom_grid_number**2,dtype=int)+i for i in range(mom_grid_number)])
j_grid_seq = np.transpose(\
np.concatenate(\
[np.zeros(\
mom_grid_number**2,dtype=int)+i for i in range(mom_grid_number)]).reshape([-1,mom_grid_number])).reshape([1,-1])[0]
k_grid_seq = np.transpose(\
np.concatenate(\
[np.zeros(\
mom_grid_number**2,dtype=int)+i for i in range(mom_grid_number)]).reshape([-1,mom_grid_number**2])).reshape([1,-1])[0]
te=time.time()
print(te - ts)
根据打印时间大约需要166秒,实际上我等了5分钟。任何人都可以帮我解决这个问题,以便它可以非常快地运行吗?
另外,如果有必要,我可以在我的电脑上获得gpu支持。