I have error in compute gradient function

image
what should i do i just need a little help

Hi @abdallagamaljimmy, welcome to our community!

An error traceback should start from the word “Traceback”. Please share the whole error traceback.

Thanks.

Raymond

Hello @abdallagamaljimmy,

We have this error when we use subscript on an integer object such as

Screenshot from 2022-09-16 06-50-03

However, subscript can be used on a numpy array like:

Screenshot from 2022-09-16 06-50-20

From the traceback, subscript is used on these variables dj_dw, x, y, and x[i]. Now, to debug it yourself, you need to first identify which one is an array and which one is not by printing the type of each of them right before the erroneous line. For example, print(type(dj_dw)) will tell you the type of dj_dw.

As long as any one of them does not show itself as a numpy array nor a list, it is a cause of the problem and there can be more than one problematic variable, so please test all four of them.

Another piece of information you may want to take into consideration is this description because it tells you the expected data type of each variable and we should stick to it.

Screenshot from 2022-09-16 06-55-46

Good luck.

Raymond

1 Like

thanks a lot for this help lot :smiling_face_with_three_hearts:

1 Like

I am happy to hear that :slight_smile: I hope this particular error won’t ever bother you again in your future machine learning work

Raymond

1 Like