Efficient parallelization of operations on two dimensional array operations in python
问题 I'm trying to parallelize operations on two dimensional array using joblib library in python. Here is the code I have from joblib import Parallel, delayed import multiprocessing import numpy as np # The code below just aggregates the base_array to form a new two dimensional array base_array = np.ones((2**12, 2**12), dtype=np.uint8) def compute_average(i, j): return np.uint8(np.mean(base_array[i*4: (i+1)*4, j*4: (j+1)*4])) num_cores = multiprocessing.cpu_count() new_array = np.array(Parallel(n