0

I'm having a difficulty understanding how the loop in this logistic regression example from Numba's documentation (https://numba.readthedocs.io/en/stable/user/parallel.html#numba-parallel) could be parallelized:

@numba.jit(nopython=True, parallel=True)
def logistic_regression(Y, X, w, iterations):
    for i in range(iterations):
        w -= np.dot(((1.0 / (1.0 + np.exp(-Y * np.dot(X, w))) - 1.0) * Y), X)
    return w

I mean the dot product in each iteration of the loop clearly depends on the value of w computed in the previous iteration. so how is this parallelized and what am i missing in here?

mimain
  • 65
  • 4
  • "One can use Numba’s prange instead of range to specify that a loop can be parallelized." – Ori Yarden PhD Mar 22 '23 at 16:48
  • The loop isn't parallelized, nor should it. That doesn't mean that nothing gets done in parallel, the dot product within the loop for example could still qualify. Numba will warn if the attempt for parallelization isn't doing anything at all (showing a `NumbaPerformanceWarning`). – Rutger Kassies Mar 24 '23 at 07:39

0 Answers0