Wk 2 Assignment: Exercise 5- Syntax Error


Any suggestions on how to debug this?

Yes: check the parentheses on your previous line. They don’t match, which is what triggers the syntax error on the next line.

You also have some problems in the cost calculation. Note that python is a case sensitive language. That means a is not the same thing as A. Also note that the way you are doing the transposes will result in the product being m x 1 times 1 x m. You will not be happy with the result of that. If you are using “*” as opposed to np.dot, then you don’t need any transposes.

Also please edit your post and remove the source code once you have this figured out. We are not supposed to leave solution source code sitting around for everyone to see.

Also you don’t need to import numpy again. It does no harm, but it is unnecessary. If you get an error about np not defined, it means you forgot to run the previous cells in the notebook. The imports are all done in the first cell in the notebook. Try “Cell → Run All Above” if that happens to you again. You must do this each time you close and reopen the notebook or do a Kernel Restart.