简体   繁体   English

如何并行化以下循环?

[英]How To Parallelize The Following Loop?

I want to run my function in parallel, however all examples contain only an i variable.我想并行运行我的 function,但是所有示例只包含一个i变量。 I tried to apply all methods in Parallel for Loop in Python .我尝试在 Python 中应用 Parallel for Loop 中的所有方法。

One of my function is below.下面是我的 function 之一。 If I can solve problem for this function, I can handle other functions too.如果我能解决这个 function 的问题,我也可以处理其他功能。

def forlooptest(testX,N,kernel_matrix):
    for i in range(0,10000):
        if i % 100 == 0:
            print(i)
        for j in range(0,3):
            img = testX[i,:,:,j]
            filtered_img = sr_cnn(img,N,kernel_matrix)
            testX_new[i,:,:,j]= filtered_img.astype(np.uint8)
    return testX_new

Could you help me?你可以帮帮我吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM