Can I parallelize this nested for loop? (Python 3.5) -
i found out bottleneck of code following block. n of order 10,000, , l (10,000)^2. rq_func function takes indices (tuples) , returns float v , dictionary sp_dist of {index : probability} format.
is there way can parallelize code? have access cluster computing can use 20 cores @ time , use option.
r = np.empty((l,)) q = scipy.sparse.lil_matrix((l, n)) traverser = 0 # populate r , q traversing array s_index in state_indices: a_index in action_indices: v, sp_dist = rq_func(s_index, a_index) r[traverser] = v sp_index, prob in sp_dist.items(): q[traverser, sp_index] = prob traverser += 1
Comments
Post a Comment