我对这门课很感兴趣,对python也很感兴趣。我尝试了第一个NN程序,但它相当慢(主要是在下面的循环中)。
# loop over all test rows
for i in xrange(num_test):
distances = np.sum(np.abs(self.Xtr - X[i,:]), axis = 1)
min_index = np.argmin(distances)
Ypred[i] = self.ytr[min_index]有没有办法加速它?
谢谢。
发布于 2017-02-24 08:42:19
回答我自己:在这个链接(Parallelise python loop with numpy arrays and shared-memory)中引入的并行方法似乎是有效的,基本上是cython,prange,gil,openmp和其他调整。
https://stackoverflow.com/questions/42356248
复制相似问题