In exercise 2 of gradient descent part I am getting the error-
File “”, line 34
Theta -=(alpha/m)* (np.dot(x.T,(h - y)))
^
SyntaxError: invalid syntax
I named the given theta as Theta in the code. Please help!
please share screenshot of the error without sharing any grade cell codes
The variable there is “theta” not “Theta”, check the parenthesis how many you are using and in the line of code above. At this point is better to write it simple as a = x-b don’t use the short form!
I have just renamed theta as Theta. I am not getting how to write code for updated theta without assigning it to some other variable?
Here is the screenshot of the error.
Hi @PG_Coursera
The reason renaming won’t resolve your issue is because theta has been recalled as ‘theta’ as an argument in the cell, so it is probably causing the error.
Input
theta: weight vector of dimension (n+1,1)
Output
theta: your final weight vector
Another reason I am suspecting is because
this is incorrect due to incorrect tuple, it should (alpha * (x.T@(h-y)))/m
Regards
DP
I think you have a syntax error in the line before the one where you have “Theta = …”.
I am unable to figure out my mistake. Kindly help me.
What that error pointing at the beginning of the line means is that the real syntax error is on the previous (non-comment) line: there is probably a missing close parenthesis there. You can use the notebook editor to check your parentheses: just click on one and it will highlight the matching one. Or not!
When you can’t find the syntax error in python, it usually means you are looking in the wrong place.
@paulinpaloalto absolutely!