我必须为一叠图像的每个切片应用一个2D过滤器,我想并行化分析。但是,下面的代码比正常的for循环运行慢。同样,增加n_jobs
也会增加处理时间,对于n_jobs = 1
更快,而对于[[n_jobs = 6
则更慢。
import numpy as np
from joblib import Parallel, delayed
from skimage.restoration import denoise_tv_chambolle
arr = np.random.rand(50,50,50)
def f(arr):
arr_h = denoise_tv_chambolle(arr, weight=0.1, multichannel=True)
return arr_h
Parallel(n_jobs=6, backend="threading")(delayed(f)(i) for i in arr)
Q