I have the following for loop:
for j in range(len(list_list_int)):
arr_1_, arr_2_, arr_3_ = foo(bar, list_of_ints[j])
arr_1[j,:] = arr_1_.data.numpy()
arr_2[j,:] = arr_2_.data.numpy()
arr_3[j,:] = arr_3_.data.numpy()
I would like to apply foo
with multiprocessing, mainly because it is taking a lot of time to finish. I tried to do it in batches with funcy's chunks method:
for j in chunks(1000, list_list_int):
arr_1_, arr_2_, arr_3_ = foo(bar, list_of_ints[j])
arr_1[j,:] = arr_1_.data.numpy()
arr_2[j,:] = arr_2_.data.numpy()
arr_3[j,:] = arr_3_.data.numpy()
However, I am getting list object cannot be interpreted as an integer
. What is the correct way of applying foo using multiprocessing?
for j in chunks(1000, list_list_int):
,j
is not integer, it is sublist oflist_list_int
, So, you need to iteratej
again. i.sstatic.net/JXDmZ.png – Curreyarr_1[j,:] = arr_1_.data.numpy()
, they don't do anything (the arr_1 variable is overwritten in the next iteration) – Washin