Week 3 practice lab: logistic regression

I am facing this error. Can anyone help?

Hello @M_Rezaeemanesh,

We can give you some hints but you will have to figure out the problem and resolve it yourself. The error indicates which line the problem lies, and the problem itself. There are 2 variables being indexed in the line, which is w, X, and X[i], and one of them has only a size of 2 but you are asking for the 3rd item (1st item has index 0, 2nd item has index 1, and 3rd item has index 2).

You need to understand the meaning for i, j, m, w, and X. For example, j is related to m, so what do each of them mean? What i is for? Would i or j go beyond the size of the variables w, X, or X[i]. Something must be wrong here.


Hi Dear @rmwkwok ,

I understand that m is “the number of training examples in the dataset”, and w lies in the sigmoid to predict the relationship between the data.
Actually, I think I didn’t get you. I’ve exactly followed the hints that are below the code, I wonder why it didn’t work. Shall I send you the code privately?
Please explain more if possible.


If m is the number of samples, then what is j, w[j], and X[i][j]?

I have figured out my mistake and I have corrected the code.
Thank you so much.
M. Rezaeemanesh

Great work @M_Rezaeemanesh. I shouldn’t be more explicit because it is your success. Code debugging is a skill that is crucial for doing machine learning but the skill takes opportunity and time to build up, and it’s your opportunity and your achievement :slight_smile:


I am also very happy. Thanks for your tips.
The course is over , but I really need to more practice and repeat :blush:

1 Like