Python Numpy阵列上的简单多处理示例
有没有一种简单(但完整)的方法可以跨多个内核并行化以下循环?我还没有找到一个Python的多处理模块的示例/解释/教程来简洁地回答这个问题Python Numpy阵列上的简单多处理示例,python,numpy,parallel-processing,Python,Numpy,Parallel Processing,有没有一种简单(但完整)的方法可以跨多个内核并行化以下循环?我还没有找到一个Python的多处理模块的示例/解释/教程来简洁地回答这个问题 import numpy as np small = np.random.randn(1000, 50) big = np.random.randn(200000, 50) # note small and big are fixed before looping dist = np.empty(1000, 200000) for i in range
import numpy as np
small = np.random.randn(1000, 50)
big = np.random.randn(200000, 50) # note small and big are fixed before looping
dist = np.empty(1000, 200000)
for i in range(len(small)):
x = small[i]
dist[i] = np.linalg.norm(big - x, axis=1)
我尝试过,但遇到了问题,但我对别人会做什么感兴趣,而不是分享我所做的事情。除了多处理之外,其他并行化循环的方法也是值得的。也很感激,因为评论将是您最喜欢的关于多处理的简单教程。对于某些任务,文档(以及我所看到的其他资源)很复杂或过于详细。另外,对于您最喜欢的关于多处理的简单教程,请提供评论。对于某些任务,文档(以及我看到的其他资源)非常复杂或过于详细。