When you get a syntax error at the beginning of a line like that, it usually means there are mismatching parentheses on the previous (non-comment) code line. Most likely a missing “close paren”.
Note that the editor in the notebook is “syntax aware”: just click on a paren and it will highlight the matching one. Or not …
The “meta” point here is that if you can’t find the syntax error, it probably means you are looking in the wrong place.
The other way to get a syntax error at the beginning of a line is if there is an unexpected indentation. But in my experience, the python intepreter is pretty good about making the error message more specific in that case: it will mention that indentation is the problem.
The message you show is not about indentation, so it most likely means the error is before the line where it “throws”. The interpreter keeps looking forward hoping to find the close paren or close bracket that it is expecting and then it “throws” only when it sees something that conflicts with that.
To do A dot B, we need to match the last shape value of A with the first shape value of B, meaning that, for your case, with reference to the error message, you want to have (1, 3) and (3, 1).
This means you need to change the shape of the “B” that is in your code. To change the shape that way, we do transpose, and you have done it multiple times in this exercise by using the syntax .T. I understand that it was not shown in the equations, but we just need it. Try .T, but remember that there may be more than one “B” that you will need to transpose for the line of code marked in the error message, because you have more than one dot product.
What you want to do is take the elementwise products of two 1 x m vectors and then add up those products to get a scalar value. There are two ways you can do that:
Use * to do “elementwise” multiply, followed by np.sum to do the addition.
Use np.dot to do both operations in “one shot”, but if you do it that way, you’ll need to transpose the second vector so that you dot 1 x m with m x 1, giving a scalar result.
You’ve done a mixed strategy where you did it in two steps but used np.dot without the transpose as the first step.