How to solve X[i,j] to be vectorized

I asked in this forum previously and mentors told me we didn’t use for loop as mush as possible because it’s insufficient in big data and we use vectorization. This code below from lab option. I tried to figure out how can remove a two nested loop but I can’t get it. the problem is how to solve X[i, j] if I use numpy vectorization?

# code removed

Hi @khaldon

{code removed}

This is the vectorized implementation of function def compute_gradient_logistic(X, y, w, b) of the optional lab C1_W3_Lab06_Gradient_Descent_Soln

Happy Ramadan :blush:
Best Regards,

1 Like

In brief, any time you are computing the sum of the products of the elements of a vector and a matrix, you can substitute a dot product.

1 Like

Note that in this code, there is a redundtant use of dj_dw.

The "dj_dw + " isn’t needed, as evidence that it was hard-coded to zero previously.

1 Like

IDK how did you know LOL. happy Ramadan for you bro

I have removed the code from this thread, as it relates too closely to some graded assignments.