简体   繁体   中英

How To Parallelize The Following Loop?

I want to run my function in parallel, however all examples contain only an i variable. I tried to apply all methods in Parallel for Loop in Python .

One of my function is below. If I can solve problem for this function, I can handle other functions too.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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